From 39e05a29faf903ddf36aa68c2048446b47e350fc Mon Sep 17 00:00:00 2001 From: Ana Date: Thu, 11 Aug 2016 16:38:39 +0200 Subject: [PATCH 1/6] Introduce an association between User and Event 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. --- app/models/event.rb | 3 +++ app/models/user.rb | 2 ++ db/migrate/20160811143427_create_events_users.rb | 8 ++++++++ db/schema.rb | 5 +++++ 4 files changed, 18 insertions(+) create mode 100644 db/migrate/20160811143427_create_events_users.rb diff --git a/app/models/event.rb b/app/models/event.rb index 82f8204b..14d82e77 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -34,9 +34,12 @@ class Event < ApplicationRecord belongs_to :difficulty_level belongs_to :program + has_and_belongs_to_many :favourite_users, class_name: 'User' + accepts_nested_attributes_for :event_users, allow_destroy: true accepts_nested_attributes_for :speakers, allow_destroy: true accepts_nested_attributes_for :users + accepts_nested_attributes_for :favourite_users before_create :generate_guid diff --git a/app/models/user.rb b/app/models/user.rb index 4cbac281..1bb43315 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -86,6 +86,8 @@ class User < ApplicationRecord has_many :booths, through: :booth_requests has_many :survey_replies has_many :survey_submissions + has_and_belongs_to_many :favourite_events, class_name: 'Event' + accepts_nested_attributes_for :roles scope :admin, -> { where(is_admin: true) } diff --git a/db/migrate/20160811143427_create_events_users.rb b/db/migrate/20160811143427_create_events_users.rb new file mode 100644 index 00000000..64a7fa6e --- /dev/null +++ b/db/migrate/20160811143427_create_events_users.rb @@ -0,0 +1,8 @@ +class CreateEventsUsers < ActiveRecord::Migration + def change + create_table :events_users, id: false do |t| + t.references :event + t.references :user + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 298e77a3..22184144 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -263,6 +263,11 @@ ActiveRecord::Schema[7.0].define(version: 2024_11_21_114727) do t.datetime "created_at" end + create_table "events_users", id: false, force: :cascade do |t| + t.integer "event_id" + t.integer "user_id" + end + create_table "lodgings", force: :cascade do |t| t.string "name" t.text "description" From c6906675f98b4c16a69049b8ab4ea032a9561611 Mon Sep 17 00:00:00 2001 From: Ana Date: Fri, 12 Aug 2016 00:41:02 +0200 Subject: [PATCH 2/6] Make it possible to select favourites 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. --- app/assets/javascripts/osem-schedule.js | 30 +++++++++++++++ app/assets/stylesheets/osem-schedule.scss | 9 +++++ app/controllers/proposals_controller.rb | 40 +++++++++++++------- app/views/schedules/_event.html.haml | 8 +++- app/views/schedules/_schedule_item.html.haml | 10 ++++- 5 files changed, 80 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/osem-schedule.js b/app/assets/javascripts/osem-schedule.js index 5f1e7728..1582ba1b 100644 --- a/app/assets/javascripts/osem-schedule.js +++ b/app/assets/javascripts/osem-schedule.js @@ -1,3 +1,5 @@ +// ADMIN SCHEDULE + var url; // Should be initialize in Schedule.initialize var schedule_id; // Should be initialize in Schedule.initialize @@ -114,6 +116,34 @@ $(document).ready( function() { }); }); + +// PUBLIC SCHEDULE + +function starClicked(e){ + // stops the click from propagating + if (!e) var e = window.event; + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var callback = function(data) { + $(e.target).toggleClass('fa-star fa-star-o'); + } + + var params = { favourite_user_id: $(e.target).data('user') }; + if($(e.target).hasClass('fa-star-o')){ + params['add'] = true; + } + + $.ajax({ + url: $(e.target).data('url'), + type: 'PATCH', + data: params, + success: callback, + dataType : 'json' + }); +} + function eventClicked(e, element){ var url = $(element).data('url'); if(e.ctrlKey) diff --git a/app/assets/stylesheets/osem-schedule.scss b/app/assets/stylesheets/osem-schedule.scss index 1cf1efec..3c4bb4b2 100644 --- a/app/assets/stylesheets/osem-schedule.scss +++ b/app/assets/stylesheets/osem-schedule.scss @@ -254,6 +254,15 @@ td.no-padding{ opacity: 0.5; } +#star{ + margin-top: 8px; +} + +#star-events{ + margin-right: 5px; + vertical-align: text-top; +} + /* Small devices (tablets, 768px and up) */ @media (min-width: 768px) { .room, .event-title{ diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 54ca58c9..efdfa887 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -68,21 +68,35 @@ class ProposalsController < ApplicationController end def update - @url = conference_program_proposal_path(@conference.short_title, params[:id]) + respond_to do |format| + format.html do + @url = conference_program_proposal_path(@conference.short_title, params[:id]) - track = Track.find_by(id: params[:event][:track_id]) - if track && !track.cfp_active - flash.now[:error] = 'You have selected a track that doesn\'t accept proposals' - render action: 'edit' - return - end + track = Track.find_by(id: params[:event][:track_id]) + if track && !track.cfp_active + flash.now[:error] = 'You have selected a track that doesn\'t accept proposals' + render action: 'edit' + return + end - if @event.update(event_params) - redirect_to conference_program_proposals_path(conference_id: @conference.short_title), - notice: 'Proposal was successfully updated.' - else - flash.now[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'edit' + if @event.update(event_params) + redirect_to conference_program_proposals_path(conference_id: @conference.short_title), + notice: 'Proposal was successfully updated.' + else + flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" + render action: 'edit' + end + end + format.json do + user = User.find(params[:favourite_user_id]) + users = @event.favourite_users + if users.include? user + @event.favourite_users.delete(user) + else + @event.favourite_users << User.find(params[:favourite_user_id]) + end + render json: {} + end end end diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 25f4e1a0..41eca5b8 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -4,11 +4,15 @@ = image_tag speaker.gravatar_url, :class => "img-circle pull-right all-speaker-pic", | :alt => speaker.name, | :title => speaker.name | - %p = canceled_replacement_event_label(event, event_schedule) = replacement_event_notice(event_schedule) - + - 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", | + "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | + "data-user" => current_user.id } %span.h3 = event.title %br diff --git a/app/views/schedules/_schedule_item.html.haml b/app/views/schedules/_schedule_item.html.haml index b6d8708e..9e9d855f 100644 --- a/app/views/schedules/_schedule_item.html.haml +++ b/app/views/schedules/_schedule_item.html.haml @@ -1,7 +1,7 @@ %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))}" } %div{ class: "elipsis break-words event-title", | style: "-webkit-line-clamp: #{ event_lines(@rooms) }; height: #{ event_height(@rooms) }px;"} | @@ -9,9 +9,15 @@ = event.title + - 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", | + "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | + "data-user" => current_user.id } + - event.speakers_ordered.each do |speaker| = image_tag speaker.gravatar_url, :class => "img-circle pull-right speaker-pic", | :alt => speaker.name, | :title => speaker.name, | :style => "height: #{ speaker_height(@rooms) }px; width: #{ speaker_width(@rooms) }px;" - From 059b5cbf84e7bfe1138a3e1051dc5cbe5d98822c Mon Sep 17 00:00:00 2001 From: Ana Date: Sat, 13 Aug 2016 02:26:02 +0200 Subject: [PATCH 3/6] Show the individual User schedule Show the current user favourites events for both schedule and all events. Unsed css removed. --- app/assets/javascripts/osem-schedule.js | 3 --- app/assets/stylesheets/osem-schedule.scss | 16 +--------------- app/controllers/schedules_controller.rb | 17 +++++++++++++++-- app/views/schedules/_carousel.html.haml | 3 ++- app/views/schedules/_schedule_item.html.haml | 6 ++++++ app/views/schedules/_schedule_tabs.html.haml | 4 ++-- app/views/schedules/events.html.haml | 7 +++++++ app/views/schedules/show.html.haml | 7 +++++++ 8 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/osem-schedule.js b/app/assets/javascripts/osem-schedule.js index 1582ba1b..155b9ef7 100644 --- a/app/assets/javascripts/osem-schedule.js +++ b/app/assets/javascripts/osem-schedule.js @@ -131,9 +131,6 @@ function starClicked(e){ } var params = { favourite_user_id: $(e.target).data('user') }; - if($(e.target).hasClass('fa-star-o')){ - params['add'] = true; - } $.ajax({ url: $(e.target).data('url'), diff --git a/app/assets/stylesheets/osem-schedule.scss b/app/assets/stylesheets/osem-schedule.scss index 3c4bb4b2..87849148 100644 --- a/app/assets/stylesheets/osem-schedule.scss +++ b/app/assets/stylesheets/osem-schedule.scss @@ -114,7 +114,7 @@ a.unstyled-link { .program-dropdown, .schedule-dropdown{ margin-left: 20%; margin-right: 20%; - margin-top: 40px; + margin-top: 10px; margin-bottom: 20px; } @@ -221,20 +221,6 @@ td.no-padding{ cursor: pointer; } -.program-dropdown{ - margin-left: 20%; - margin-right: 20%; - margin-top: 40px; -} - -.program-dropdown > button{ - width: 100%; -} - -.program-dropdown > .dropdown-menu{ - width: 100%; -} - .no-events-day{ color: #D8D8D8 !important; } diff --git a/app/controllers/schedules_controller.rb b/app/controllers/schedules_controller.rb index 5f68c27c..5935322d 100644 --- a/app/controllers/schedules_controller.rb +++ b/app/controllers/schedules_controller.rb @@ -3,6 +3,7 @@ class SchedulesController < ApplicationController load_and_authorize_resource before_action :respond_to_options + before_action :favourites load_resource :conference, find_by: :short_title load_resource :program, through: :conference, singleton: true, except: :index before_action :load_withdrawn_event_schedules, only: [:show, :events] @@ -58,9 +59,17 @@ class SchedulesController < ApplicationController @events_schedules = @program.selected_event_schedules( includes: [:room, { event: %i[track event_type speakers submitter] }] ) - @events_schedules = [] unless @events_schedules - @unscheduled_events = @program.events.confirmed - @events_schedules.map(&:event) + @events_schedules = @events_schedules.select{ |e| e.event.favourite_users.exists?(current_user.id) } if @events_schedules && current_user && @favourites + @events_schedules = [] unless @events_schedules + @favourites = params[:favourites] == 'true' + + @unscheduled_events = if @program.selected_schedule + @program.events.confirmed - @events_schedules.map(&:event) + else + @program.events.confirmed + end + @unscheduled_events = @unscheduled_events.select{ |e| e.favourite_users.exists?(current_user.id) } if current_user && @favourites day = @conference.current_conference_day @tag = day.strftime('%Y-%m-%d') if day @@ -72,6 +81,10 @@ class SchedulesController < ApplicationController private + def favourites + @favourites = params[:favourites] == 'true' + end + def respond_to_options respond_to do |format| format.html { head :ok } diff --git a/app/views/schedules/_carousel.html.haml b/app/views/schedules/_carousel.html.haml index 785a0681..fc94883c 100644 --- a/app/views/schedules/_carousel.html.haml +++ b/app/views/schedules/_carousel.html.haml @@ -29,9 +29,10 @@ %td.room{ style: "height: #{ td_height(@rooms) }px;" } .room.elipsis.break-words{ style: "-webkit-line-clamp: #{ room_lines(@rooms) }; height: #{ room_height(@rooms) }px;" } = room.name - - event_schedules = (@event_schedules_by_room_id[room.id] || []).select{ |e| (e.end_time > start_time) && (e.start_time <= (start_time + hrs_per_slide.hour)) } + - event_schedules = event_schedules.select{ |e| e.event.favourite_users.exists?(current_user.id) } if current_user && @favourites + - interval_count.times do |offset| - if span > 1 - span -= 1 diff --git a/app/views/schedules/_schedule_item.html.haml b/app/views/schedules/_schedule_item.html.haml index 9e9d855f..97ee0317 100644 --- a/app/views/schedules/_schedule_item.html.haml +++ b/app/views/schedules/_schedule_item.html.haml @@ -7,6 +7,12 @@ = 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' }", | + "aria-hidden" =>"true", | + "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | + "data-user" => current_user.id } = event.title - if current_user diff --git a/app/views/schedules/_schedule_tabs.html.haml b/app/views/schedules/_schedule_tabs.html.haml index 0317f8bc..30dd5ab7 100644 --- a/app/views/schedules/_schedule_tabs.html.haml +++ b/app/views/schedules/_schedule_tabs.html.haml @@ -2,6 +2,6 @@ / Nav tabs %ul.nav.nav-tabs{ role: "tablist" } %li{ class: "schedule #{ 'active' if active == 'schedule' }", role: "presentation" } - = link_to('Schedule', conference_schedule_path(@conference.short_title)) + = link_to('Schedule', conference_schedule_path(@conference.short_title, favourites: @favourites)) %li{ class: "program #{ 'active' if active == 'program' }", role: "presentation" } - = link_to('All events', events_conference_schedule_path(@conference.short_title)) + = link_to('All events', events_conference_schedule_path(@conference.short_title, favourites: @favourites)) diff --git a/app/views/schedules/events.html.haml b/app/views/schedules/events.html.haml index b6e87e31..1ccd3b80 100644 --- a/app/views/schedules/events.html.haml +++ b/app/views/schedules/events.html.haml @@ -5,6 +5,13 @@ %h1.text-center Program for = @conference.title + - if current_user + .row + .col-md-12.text-center + = button_to (@favourites ? 'All events' : 'Only favourites events'), + events_conference_schedule_path(@conference.short_title), + params: { favourites: !@favourites }, + method: :get, class: 'btn btn-success' .dropdown.program-dropdown %button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" } Dates diff --git a/app/views/schedules/show.html.haml b/app/views/schedules/show.html.haml index 8000b1ad..7c80c52c 100644 --- a/app/views/schedules/show.html.haml +++ b/app/views/schedules/show.html.haml @@ -5,6 +5,13 @@ %h1.text-center Schedule for = @conference.title + - if current_user + .row + .col-md-12.text-center + = button_to (@favourites ? 'All events' : 'Only favourites events'), + conference_schedule_path(@conference.short_title), + params: { favourites: !@favourites }, + method: :get, class: 'btn btn-success' .dropdown.schedule-dropdown %button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" } = @day From 24859233193fffa5cb729e1c768254923121cf4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Sun, 19 Mar 2017 10:34:14 +0100 Subject: [PATCH 4/6] Move update favorites to a separate action Introduce a separate action `toggle_favorite` to update user favorites events. Otherwise users with permissions to update the event can have it as favorite. --- app/controllers/proposals_controller.rb | 54 +++++++++----------- app/views/schedules/_event.html.haml | 2 +- app/views/schedules/_schedule_item.html.haml | 2 +- config/routes.rb | 1 + 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index efdfa887..a64832e1 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -6,7 +6,7 @@ class ProposalsController < ApplicationController load_resource :program, through: :conference, singleton: true load_and_authorize_resource :event, parent: false, through: :program # We authorize manually in these actions - skip_authorize_resource :event, only: [:confirm, :restart, :withdraw] + skip_authorize_resource :event, only: [:confirm, :restart, :toogle_favorite, :withdraw] def index @event = @program.events.new @@ -68,36 +68,32 @@ class ProposalsController < ApplicationController end def update - respond_to do |format| - format.html do - @url = conference_program_proposal_path(@conference.short_title, params[:id]) + @url = conference_program_proposal_path(@conference.short_title, params[:id]) - track = Track.find_by(id: params[:event][:track_id]) - if track && !track.cfp_active - flash.now[:error] = 'You have selected a track that doesn\'t accept proposals' - render action: 'edit' - return - end - - if @event.update(event_params) - redirect_to conference_program_proposals_path(conference_id: @conference.short_title), - notice: 'Proposal was successfully updated.' - else - flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'edit' - end - end - format.json do - user = User.find(params[:favourite_user_id]) - users = @event.favourite_users - if users.include? user - @event.favourite_users.delete(user) - else - @event.favourite_users << User.find(params[:favourite_user_id]) - end - render json: {} - end + track = Track.find_by(id: params[:event][:track_id]) + if track && !track.cfp_active + flash.now[:error] = 'You have selected a track that doesn\'t accept proposals' + render action: 'edit' + return end + + if @event.update(event_params) + redirect_to conference_program_proposals_path(conference_id: @conference.short_title), + notice: 'Proposal was successfully updated.' + else + flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}" + render action: 'edit' + end + end + def toogle_favorite + user = User.find(params[:favourite_user_id]) + users = @event.favourite_users + if users.include? user + @event.favourite_users.delete(user) + else + @event.favourite_users << user + end + render json: {} end def withdraw diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 41eca5b8..e5d9a5b0 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -11,7 +11,7 @@ = 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", | - "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | + "data-url" => toogle_favorite_conference_program_proposal_path(@conference.short_title, event.id), | "data-user" => current_user.id } %span.h3 = event.title diff --git a/app/views/schedules/_schedule_item.html.haml b/app/views/schedules/_schedule_item.html.haml index 97ee0317..b7d01f7a 100644 --- a/app/views/schedules/_schedule_item.html.haml +++ b/app/views/schedules/_schedule_item.html.haml @@ -11,7 +11,7 @@ = 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", | - "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | + "data-url" => toogle_favorite_conference_program_proposal_path(@conference.short_title, event.id), | "data-user" => current_user.id } = event.title diff --git a/config/routes.rb b/config/routes.rb index 730d43cf..53171e44 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -166,6 +166,7 @@ Osem::Application.routes.draw do patch '/withdraw' => 'proposals#withdraw' patch '/confirm' => 'proposals#confirm' patch '/restart' => 'proposals#restart' + patch :toogle_favorite end end resources :tracks, except: :destroy do From 91629d9b925d4e1b94eddc8ebceef6082d7b3a37 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 20 Sep 2018 00:45:50 +0300 Subject: [PATCH 5/6] Add authorization for toggle_favorite and rename route --- app/controllers/proposals_controller.rb | 6 ++++-- app/models/ability.rb | 4 ++++ app/views/schedules/_event.html.haml | 2 +- app/views/schedules/_schedule_item.html.haml | 2 +- config/routes.rb | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index a64832e1..63483066 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -6,7 +6,8 @@ class ProposalsController < ApplicationController load_resource :program, through: :conference, singleton: true load_and_authorize_resource :event, parent: false, through: :program # We authorize manually in these actions - skip_authorize_resource :event, only: [:confirm, :restart, :toogle_favorite, :withdraw] + skip_authorize_resource :event, only: [:confirm, :restart, :withdraw] + def index @event = @program.events.new @@ -85,7 +86,8 @@ class ProposalsController < ApplicationController render action: 'edit' end end - def toogle_favorite + + def toggle_favorite user = User.find(params[:favourite_user_id]) users = @event.favourite_users if users.include? user diff --git a/app/models/ability.rb b/app/models/ability.rb index 913c97ff..5882b273 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -108,6 +108,10 @@ class Ability event.users.include?(user) end + can :toggle_favorite, Event do |event| + event.scheduled? + end + # can manage the commercials of their own events can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id) diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index e5d9a5b0..92f0dd1e 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -11,7 +11,7 @@ = 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", | - "data-url" => toogle_favorite_conference_program_proposal_path(@conference.short_title, event.id), | + "data-url" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), | "data-user" => current_user.id } %span.h3 = event.title diff --git a/app/views/schedules/_schedule_item.html.haml b/app/views/schedules/_schedule_item.html.haml index b7d01f7a..785bb678 100644 --- a/app/views/schedules/_schedule_item.html.haml +++ b/app/views/schedules/_schedule_item.html.haml @@ -11,7 +11,7 @@ = 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", | - "data-url" => toogle_favorite_conference_program_proposal_path(@conference.short_title, event.id), | + "data-url" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), | "data-user" => current_user.id } = event.title diff --git a/config/routes.rb b/config/routes.rb index 53171e44..a3b3d4d4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -166,7 +166,7 @@ Osem::Application.routes.draw do patch '/withdraw' => 'proposals#withdraw' patch '/confirm' => 'proposals#confirm' patch '/restart' => 'proposals#restart' - patch :toogle_favorite + patch :toggle_favorite end end resources :tracks, except: :destroy do From efdb2cd63be471e4aadbcd0c4130b05ff360a9d3 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Tue, 2 Oct 2018 21:29:49 +0300 Subject: [PATCH 6/6] Remove duplicate code and style fixes --- app/controllers/proposals_controller.rb | 1 - app/views/schedules/_schedule_item.html.haml | 7 ------- 2 files changed, 8 deletions(-) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 63483066..f1c15ad2 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -8,7 +8,6 @@ class ProposalsController < ApplicationController # We authorize manually in these actions skip_authorize_resource :event, only: [:confirm, :restart, :withdraw] - def index @event = @program.events.new @event.event_users.new(user: current_user, event_role: 'submitter') diff --git a/app/views/schedules/_schedule_item.html.haml b/app/views/schedules/_schedule_item.html.haml index 785bb678..d72f5e33 100644 --- a/app/views/schedules/_schedule_item.html.haml +++ b/app/views/schedules/_schedule_item.html.haml @@ -15,13 +15,6 @@ "data-user" => current_user.id } = event.title - - 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", | - "data-url" => conference_program_proposal_path(@conference.short_title, event.id), | - "data-user" => current_user.id } - - event.speakers_ordered.each do |speaker| = image_tag speaker.gravatar_url, :class => "img-circle pull-right speaker-pic", | :alt => speaker.name, |