This commit is contained in:
Stella Rouzi 2026-06-27 18:17:28 +02:00 committed by GitHub
commit e06a47820c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 118 additions and 25 deletions

View file

@ -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,31 @@ $(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') };
$.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)

View file

@ -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;
}
@ -254,6 +240,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{

View file

@ -81,11 +81,22 @@ class ProposalsController < ApplicationController
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(', ')}"
flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
render action: 'edit'
end
end
def toggle_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
authorize! :update, @event
@url = conference_program_proposal_path(@conference.short_title, params[:id])

View file

@ -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 }

View file

@ -109,6 +109,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)

View file

@ -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

View file

@ -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) }

View file

@ -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

View file

@ -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" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
"data-user" => current_user.id }
%span.h3
= event.title
%br

View file

@ -1,12 +1,18 @@
%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;"} |
= 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" => toggle_favorite_conference_program_proposal_path(@conference.short_title, event.id), |
"data-user" => current_user.id }
= event.title
- event.speakers_ordered.each do |speaker|
@ -14,4 +20,3 @@
:alt => speaker.name, |
:title => speaker.name, |
:style => "height: #{ speaker_height(@rooms) }px; width: #{ speaker_width(@rooms) }px;"

View file

@ -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))

View file

@ -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

View file

@ -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

View file

@ -166,6 +166,7 @@ Osem::Application.routes.draw do
patch '/withdraw' => 'proposals#withdraw'
patch '/confirm' => 'proposals#confirm'
patch '/restart' => 'proposals#restart'
patch :toggle_favorite
end
end
resources :tracks, except: :destroy do

View file

@ -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

View file

@ -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"