Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User schedule #2185

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

differentreality
Copy link
Contributor

User can select favorite events, and show only their individual schedule
Continuing #1142 by @Ana06

  • Introduce an association between User and Event
  • Show individual User schedule

@Ana06
Copy link
Member

Ana06 commented Sep 19, 2018

@differentreality thanks for taking care of this! 💘

@bear454
Copy link
Contributor

bear454 commented Sep 20, 2018

Just a little lint to remove:

app/models/event.rb:35:3: C: Rails/HasAndBelongsToMany: Prefer has_many :through to has_and_belongs_to_many.
  has_and_belongs_to_many :favourite_users, class_name: 'User'
  ^^^^^^^^^^^^^^^^^^^^^^^
app/models/user.rb:79:3: C: Rails/HasAndBelongsToMany: Prefer has_many :through to has_and_belongs_to_many.
  has_and_belongs_to_many :favourite_events, class_name: 'Event'
  ^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/proposals_controller.rb:11:1: C: Layout/EmptyLines: Extra blank line detected.

@hennevogel
Copy link
Member

hennevogel commented Sep 20, 2018

I know it feels weird but try out code-review-by-commit. It makes things so much faster 🤠

@codecov
Copy link

codecov bot commented Oct 2, 2018

Codecov Report

Merging #2185 into master will increase coverage by 3.27%.
The diff coverage is 40.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2185      +/-   ##
==========================================
+ Coverage   78.74%   82.01%   +3.27%     
==========================================
  Files         146      146              
  Lines        4826     4798      -28     
==========================================
+ Hits         3800     3935     +135     
+ Misses       1026      863     -163
Impacted Files Coverage Δ
app/models/user.rb 95% <100%> (+0.67%) ⬆️
app/models/event.rb 92.35% <100%> (+0.13%) ⬆️
app/controllers/proposals_controller.rb 86.79% <25%> (-5.13%) ⬇️
app/controllers/schedules_controller.rb 43.39% <33.33%> (-1.05%) ⬇️
app/models/ability.rb 96.51% <50%> (-1.11%) ⬇️
app/controllers/commercials_controller.rb 96.42% <0%> (+3.57%) ⬆️
app/serializers/conference_serializer.rb 94.73% <0%> (+5.26%) ⬆️
app/helpers/users_helper.rb 92.85% <0%> (+7.14%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 109cb7b...1e53e9a. Read the comment docs.

@hennevogel
Copy link
Member

@differentreality once more! You can make it! ;-)

@bear454
Copy link
Contributor

bear454 commented Dec 29, 2018

@differentreality: do you think you'll get this wrapped up soon? I'd love to have this in by mid-February, for LFNW2019!

@differentreality
Copy link
Contributor Author

Yes, I will! I had completely forgotten about this 😞

@hennevogel
Copy link
Member

go stella, go stella

Im rooting for you

@Ana06 Ana06 added the feature 💡 For something new in the app label Mar 8, 2019
@differentreality
Copy link
Contributor Author

Rebased 😀

@differentreality
Copy link
Contributor Author

What else would we need for this?

@bennettscience
Copy link
Contributor

Any chance of having this merged in soon-ish? We're hosting an event on Feb 6th and this would really help out!

@differentreality
Copy link
Contributor Author

Yeah I'd love to see this merged as well! Still pending review though..
I should probably take a look at it again too.

@bennettscience
Copy link
Contributor

bennettscience commented Jan 13, 2020

@differentreality If I manually pull this commit into my local copy, I should just be able to migrate the database with the new relationship, right? The only failure in the CI build was a linter, so I'm not too worried...but I wanted to see what you thought first.

Copy link
Contributor

@cycomachead cycomachead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this idea!

I left some comments in terms of web accessibility with the front-end piece. Feel free to ignore it and just merge -- this seems great to me to have. (I'm hoping to make some small accessibility-related PRs soon.)

- if current_user
= link_to('#', onClick: 'starClicked();') do
%span#star-events{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
"aria-hidden" => "true", |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of accessibility, something like this would be provide a better description to anyone with a screen reader.

Suggested change
"aria-hidden" => "true", |
"aria-label" => "#{event.favourite_users.exists?(current_user.id) ? "un-" : ""}favourite event", |


- if current_user
= link_to('#', onClick: 'starClicked();') do
%span#star-events{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a class, not an id? (Since it seems like this partial is reusable)

%div{ class: "elipsis break-words event-title", |
style: "-webkit-line-clamp: #{ event_lines(@rooms) }; height: #{ event_height(@rooms) }px;"} |

= canceled_replacement_event_label(event, event_schedule, 'schedule-label')

- if current_user
= link_to('#', onClick: 'starClicked();') do
%span#star{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, this should be a class, since it appears multiple times on the page.

- if current_user
= link_to('#', onClick: 'starClicked();') do
%span#star{ class: "fa fa-lg #{ event.favourite_users.exists?(current_user.id) ? 'fa-star' : 'fa-star-o' }", |
"aria-hidden" =>"true", |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. :)

Suggested change
"aria-hidden" =>"true", |
"aria-label" => "#{event.favourite_users.exists?(current_user.id) ? "un-" : ""}favourite event", |

@@ -1,17 +1,22 @@
%td.event{ width: "#{ width * span }%" , |
colspan: span, |
role: "button" }
%a.unstyled-link{href: url_for(conference_program_proposal_path(@conference.short_title, event.id))}
%div{ onClick: 'eventClicked(event, this);', "data-url" => "#{url_for(conference_program_proposal_path(@conference.short_title, event.id))}" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of accessibility (both screen readers and keyboards), this is better as an a element. Otherwise, it needs role: 'button', tabindex: 0, onKeyPress: 'function(event) { if (event.charCode === 10 || event.charCode === 32) { eventCicked(event, this); } }' -- well, that last function is better put elsewhere, but that makes the div accept keypresses like a normal button.

render action: 'edit'
end
end

def toggle_favorite
user = User.find(params[:favourite_user_id])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've finally started working on merging this into my own fork for an event this summer. It seems to me that this allows anyone to toggle anyone else's favorite events. Should it not just use current_user? Since you should be logged in and have a cookie?

I can't really see a use case as well for someone else (such as an admin) toggling another user's favorites so I think the favourite_user_id parameter could probably just be removed, but I might be missing something.

@@ -52,9 +53,17 @@ def events
@events_schedules = @program.selected_event_schedules(
includes: [:room, { event: %i[track event_type speakers submitter] }]
)

@events_schedules = @events_schedules.select{ |e| e.event.favourite_users.exists?(current_user.id) } if @events_schedules && current_user && @favourites
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a slightly different use case, but I think related enough...
How would you feel about showing a schedule which is favorite events + events where you are speaking?

I am thinking about creating an event_schedule_for_user(user) method, which is essentially your personal conference agenda. My app has assigned volunteers which could also how up there.

Ana06 added 3 commits April 14, 2021 11:22
Introduce an association between User and Event for the user schedule. As there was already a relation call users in Event the new relation is called public_users. And for the same reason the relation in Event is called public_events.
Make it possible for users to select events which they want to see in the public schedule and in the All events section of the public schedule.
Show the current user favourites events for both schedule and all events.

Unsed css removed.
Ana06 and others added 3 commits April 14, 2021 11:22
Introduce a separate action `toggle_favorite` to update user favorites events.
Otherwise users with permissions to update the event can have it as favorite.
@@ -5,6 +5,13 @@
%h1.text-center
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above line -if @events_schedules.any? probably should be removed if this is merged in. It leads to a weird looking case when you have no events in your favorites schedule and the tabs disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 💡 For something new in the app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants