Add email notifications for events registrations, add switch-checkboxes, create EventsRegistrations controller, separate page for events that require registration

This commit is contained in:
Stella Rouzi 2016-06-06 12:31:57 +03:00
parent 139a8565e2
commit 77af75f319
38 changed files with 1313 additions and 403 deletions

View file

@ -30,7 +30,13 @@ module Admin
:send_on_conference_registration_dates_updated, :conference_registration_dates_updated_subject, :conference_registration_dates_updated_body,
:send_on_venue_updated, :venue_updated_subject, :venue_updated_body,
:send_on_cfp_dates_updated, :cfp_dates_updated_subject, :cfp_dates_updated_body,
:send_on_program_schedule_public, :program_schedule_public_subject, :program_schedule_public_body)
:send_on_program_schedule_public, :program_schedule_public_subject, :program_schedule_public_body,
:send_on_updated_max_attendees_automatically,
:updated_max_attendees_automatically_subject, :updated_max_attendees_automatically_body,
:send_on_deleted_event_registration_automatically, :deleted_event_registration_automatically_subject,
:deleted_event_registration_automatically_body,
:send_on_new_event_registration,
:new_event_registration_subject, :new_event_registration_body)
end
end
end

View file

@ -171,16 +171,6 @@ module Admin
@event_registrations = @event.events_registrations
end
def toggle_attendance
@events_registration.attended = !@events_registration.attended
if @events_registration.save
head :ok
else
head :unprocessable_entity
end
end
private
def event_params

View file

@ -0,0 +1,72 @@
module Admin
class EventsRegistrationsController < Admin::BaseController
load_resource :conference, find_by: :short_title
load_resource :program, through: :conference, singleton: true
load_resource :event
load_resource :registration, through: :conference
before_action :load_events_registration
authorize_resource only: :toggle_attendance
after_action :prepare_unobtrusive_flash, only: [:toggle, :toggle_attendance]
def show
authorize! :update, @event
end
def toggle_attendance
@events_registration = EventsRegistration.find_by(event_id: @event.id, registration_id: @registration.id)
@events_registration.attended = !@events_registration.attended
if @events_registration.attended
if @events_registration.save
flash[:notice] = "You have marked #{@registration.email} as attended."
else
flash[:error] = "Failed to mark #{@registration.email} as attended."
end
elsif @events_registration.save
flash[:notice] = "You have marked #{@registration.email} as NOT attended."
else
flash[:error] = "Failed to mark #{@registration.email} as NOT attended."
end
respond_to do |format|
format.js
end
end
def toggle
authorize! :toggle, @events_registration
if params[:state] == 'false'
# Destroy the registration to the event
if @events_registration.destroy
flash[:notice] = "You successfully unregistered #{@registration.email} from '#{@event.title}'"
else
flash[:error] = "Failed to unregister #{@registration.email} from '#{@event.title}'. Please try again."
end
elsif params[:state] == 'true'
# Create the registration to the event
if @events_registration.save
flash[:notice] = "You successfully registered #{@registration.email} to '#{@event.title}'"
else
flash[:error] = "Failed to register #{@registration.email} to '#{@event.title}'. Please try again."
end
else
flash[:error] = 'Something went wrong. Please take action again.'
end
respond_to do |format|
format.js
end
end
private
def events_registrations_params
params.require(:events_registrations).permit(:event_id, :registration_id)
end
def load_events_registration
@events_registration = EventsRegistration.find_or_initialize_by(event: @event, registration: @registration)
end
end
end

View file

@ -59,6 +59,21 @@ module Admin
start_time = DateTime.strptime(time, '%Y-%m-%d %k:%M')
event.start_time = start_time
event.save!
if event.require_registration && (event.registrations.length > room.size)
event_registrations = event.events_registrations.order(created_at: :desc).limit(event.registrations.length - room.size)
event_registrations.each do |er|
er.destroy!
DeletedEventRegistrationAutomaticallyJob.perform_later(event.program.conference, er.user, er.event) if er.send_email_on_deleted_event_registration_automatically?
end
event.max_attendees = room.size
event.save!
users_emails = event_registrations.map { |er| er.registration.email }.join(', ')
UpdatedMaxAttendeesAutomaticallyJob.perform_later(event, users_emails) if event.send_email_on_updated_max_attendees_automatically?
end
render json: { 'status' => 'ok' }
end

View file

@ -0,0 +1,89 @@
class EventsRegistrationsController < ApplicationController
load_resource :conference, find_by: :short_title
load_resource :program, through: :conference, singleton: true
load_resource :proposal, class: 'Event'
load_resource :registration, through: :conference
before_action :load_events_registration
authorize_resource only: [:index, :toggle_attendance]
after_action :prepare_unobtrusive_flash, only: [:toggle, :toggle_attendance]
def index
@registration = @conference.registrations.find_by(conference: @conference, user: current_user)
if @registration
@events = @registration.events_ordered
else
@events = @program.events.require_registration
end
# unless current_user.registered? @conference
# redirect_to conference_conference_registration_path(@conference), alert: 'You got to register to the conf'
# end
end
def show
authorize! :update, @proposal
end
def toggle_attendance
@events_registration = EventsRegistration.find_by(event_id: @proposal.id, registration_id: @registration.id)
@events_registration.attended = !@events_registration.attended
if @events_registration.attended
if @events_registration.save
flash[:notice] = "You have marked #{@registration.email} as attended."
else
flash[:error] = "Failed to mark #{@registration.email} as attended."
end
elsif @events_registration.save
flash[:notice] = "You have marked #{@registration.email} as NOT attended."
else
flash[:error] = "Failed to mark #{@registration.email} as NOT attended."
end
respond_to do |format|
format.js
end
end
def toggle
authorize! :toggle, @events_registration
if params[:state] == 'false'
# Destroy the registration to the event
if @events_registration.destroy
flash[:notice] = "You successfully unregistered from '#{@proposal.title}'"
else
flash[:error] = "Failed to unregister you from '#{@proposal.title}'. Please try again."
end
elsif params[:state] == 'true'
# Create the registration to the event
if @events_registration.save
flash[:notice] = "You successfully registered to '#{@proposal.title}'"
if params[:send_email] == 'true'
if @events_registration.send_email_on_new_event_registration?
@events_registration.send_event_registration_mail
end
end
else
flash[:error] = "Failed to register you to '#{@proposal.title}'. Please try again."
end
else
flash[:error] = 'Something went wrong. Please take action again.'
end
respond_to do |format|
format.js
end
end
private
def events_registrations_params
params.require(:events_registrations).permit(:event_id, :registration_id)
end
def load_events_registration
@events_registration = EventsRegistration.find_or_initialize_by(event: @proposal, registration: @registration)
end
end

View file

@ -3,8 +3,8 @@ module ApplicationHelper
# ====Returns
# * +String+ -> number of registrations / max allowed registrations
def registered_text(event)
return "Registered: #{event.registrations.count}/#{event.max_attendees}" if event.max_attendees
"Registered: #{event.registrations.count}"
return "#{event.registrations.count}/#{event.max_attendees}" if event.max_attendees
return "#{event.registrations.count}"
end
# Set resource_name for devise so that we can call the devise help links (views/devise/shared/_links) from anywhere (eg sign_up form in proposal#new)

View file

@ -0,0 +1,7 @@
class DeletedEventRegistrationAutomaticallyJob < ActiveJob::Base
queue_as :default
def perform(conference, user, event)
Mailbot.deleted_event_registration_automatically(conference, user, event).deliver_now
end
end

View file

@ -0,0 +1,13 @@
class UpdatedMaxAttendeesAutomaticallyJob < ActiveJob::Base
queue_as :default
def perform(event, users_emails=nil)
if users_emails.present?
event.program.conference.email_settings.updated_max_attendees_automatically_body << "\n\nThe following users have been unregistered from your event:\n #{users_emails}"
end
event.users.uniq.each do |user|
Mailbot.updated_max_attendees_automatically(event.program.conference, user, event).deliver_now
end
end
end

View file

@ -92,4 +92,34 @@ class Mailbot < ActionMailer::Base
template_name: 'comment_template',
subject: "New comment has been posted for #{@event.title}")
end
def updated_max_attendees_automatically(conference, user, event)
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.updated_max_attendees_automatically_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.updated_max_attendees_automatically_body,
event))
end
def deleted_event_registration_automatically(conference, user, event)
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.deleted_event_registration_automatically_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.deleted_event_registration_automatically_body,
event))
end
def event_registration_email(conference, user, event)
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.new_event_registration_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.new_event_registration_body,
event))
end
end

View file

@ -54,6 +54,9 @@ class Ability
registration.conference.registration_open? && registration.new_record?
end
# Can index Events that require registration
can :index, EventsRegistration
can :show, Event do |event|
event.new_record?
end
@ -92,6 +95,19 @@ class Ability
# can manage the commercials of their own events
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
# Can register/unregister to an event
can :toggle, EventsRegistration do |er|
user.registrations.include?(er.registration) && er.event.require_registration
end
# Proposal submitter can:
# - see the people who registered to the event
# - toggle registration of peope to the event
# - toggle their attendance
can [:show, :toggle, :toggle_attendance], EventsRegistration do |er|
er.event.event_users.pluck(:user_id).include? user.id
end
end
# Abilities for signed in users with roles
@ -117,6 +133,10 @@ class Ability
cannot :destroy, Venue do |venue|
venue.conference.program.events.where.not(room_id: nil).any?
end
cannot :toggle, EventsRegistration do |er|
!er.event.require_registration
end
end
def signed_in_with_organizer_role(user)
@ -148,6 +168,9 @@ class Ability
can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_organizer}
can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
can :manage, EventsRegistration do |er|
conf_ids_for_organizer.include? er.registration.conference.id
end
can :manage, Venue, conference_id: conf_ids_for_organizer
can :manage, Commercial, commercialable_type: 'Venue',
commercialable_id: Venue.where(conference_id: conf_ids_for_organizer).pluck(:id)
@ -182,6 +205,9 @@ class Ability
can :manage, Program, conference_id: conf_ids_for_cfp
can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
can :manage, EventsRegistration do |er|
conf_ids_for_cfp.include? er.registration.conference.id
end
can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)

View file

@ -51,8 +51,8 @@ class EmailSettings < ActiveRecord::Base
parse_template(event_template, values)
end
def generate_email_on_conf_updates(conference, user, conf_update_template)
values = get_values(conference, user)
def generate_email_on_conf_updates(conference, user, conf_update_template, event=nil)
values = get_values(conference, user, event)
parse_template(conf_update_template, values)
end

View file

@ -36,6 +36,7 @@ class Event < ActiveRecord::Base
validates :max_attendees, numericality: { only_integer: true, greater_than_or_equal_to: 1, allow_nil: true }
validate :max_attendees_no_more_than_room_size
validate :max_attendees_no_less_than_existing_registrations
scope :confirmed, -> { where(state: 'confirmed') }
scope :highlighted, -> { where(is_highlight: true) }
@ -68,6 +69,11 @@ class Event < ActiveRecord::Base
end
end
def send_email_on_updated_max_attendees_automatically?
program.conference.email_settings.send_on_updated_max_attendees_automatically &&
program.conference.email_settings.updated_max_attendees_automatically_subject && program.conference.email_settings.updated_max_attendees_automatically_body
end
##
# Checkes if the event has a start_time and a room
# ====Returns
@ -232,6 +238,13 @@ class Event < ActiveRecord::Base
errors.add(:max_attendees, "cannot be more than the room's capacity (#{room.size})") if max_attendees && (max_attendees > room.size)
end
##
# The value of max_attendees for an event cannot less than the number of existing registrations to that event
def max_attendees_no_less_than_existing_registrations
return unless max_attendees && max_attendees_changed?
errors.add(:max_attendees, 'cannot be less than existing registrations. You first need to unregister people, if you want to reduce this value.') if max_attendees < self.registrations.count
end
def abstract_limit
# If we don't have an event type, there is no need to count anything
return unless event_type && abstract

View file

@ -9,4 +9,19 @@ class EventsRegistration < ActiveRecord::Base
validates :event, :registration, presence: true
validates :event, uniqueness: { scope: :registration }
def send_event_registration_mail
return unless send_email_on_new_event_registration?
Mailbot.event_registration_email(event.program.conference, registration.user, event).deliver_later
end
def send_email_on_new_event_registration?
event.program.conference.email_settings.send_on_new_event_registration &&
event.program.conference.email_settings.new_event_registration_subject && event.program.conference.email_settings.new_event_registration_body
end
def send_email_on_deleted_event_registration_automatically?
event.program.conference.email_settings.send_on_deleted_event_registration_automatically &&
event.program.conference.email_settings.deleted_event_registration_automatically_subject && event.program.conference.email_settings.deleted_event_registration_automatically_body
end
end

View file

@ -14,6 +14,9 @@
%a{"aria-controls" => "notifications", "data-toggle" => "tab", :href => "#notifications", :role => "tab"} Update Notifications
%li{:role => "presentation"}
%a{"aria-controls" => "cfp", "data-toggle" => "tab", :href => "#cfp", :role => "tab"} Call for Papers
%li{:role => "presentation"}
%a{"aria-controls" => "events_registration", "data-toggle" => "tab", :href => "#events_registrations", :role => "tab"} Events Registrations
/ Tab panes
.tab-content
#onboarding.tab-pane.active{:role => "tabpanel"}
@ -83,6 +86,32 @@
"data-name"=>"email_settings_cfp_dates_updated_body"} Load Template
%a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_cfp_help"} Show Help
= render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false}
#events_registrations.tab-pane{:role => "tabpanel"}
= f.input :send_on_updated_max_attendees_automatically, hint: "This will notify event users about automatic changes on max_attendees attribute. This refers to events marked with require_registration"
= f.input :updated_max_attendees_automatically_subject
= f.input :updated_max_attendees_automatically_body, input_html: { rows: 10, cols: 20 }
%a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nThe maximum number of attendees that can attend your session {eventtitle} has been modified.\n That is usually due to scheduling your session in a room with less available seats.\n\nFeel free to contact us with any questions or concerns.\n\nWe look forward to seeing you there.\n\nBest wishes\n\n{conference} Team",
"data-name"=>"email_settings_updated_max_attendees_automatically_body"} Load Template
%a.btn.btn-link.control_label.template_help_link{"data-name"=>"updated_max_attendees_automatically_help"} Show Help
= render partial: 'help', locals: { id: 'updated_max_attendees_automatically_help', show_event_variables: true }
= f.input :send_on_deleted_event_registration_automatically, hint: "This will notify all user that they have been unregistered from an event. This occurs when someone else, except for the user, deletes the registration (eg. event submitter, conference organizer)"
= f.input :deleted_event_registration_automatically_subject
= f.input :deleted_event_registration_automatically_body, input_html: { rows: 10, cols: 20 }
%a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nWe are sorry to inform you that you have been unregistered from the session {eventtitle}.\n That might have occured due to technical difficulties or room limitations. You can check online for any future changes.\n\nFeel free to contact us with any questions or concerns.\n\nWe look forward to seeing you there.\n\nBest wishes\n\n{conference} Team",
"data-name"=>"email_settings_deleted_event_registration_automatically_body"} Load Template
%a.btn.btn-link.control_label.template_help_link{"data-name"=>"deleted_event_registration_automatically_help"} Show Help
= render partial: 'help', locals: { id: 'deleted_event_registration_automatically_help', show_event_variables: true }
= f.input :send_on_new_event_registration, hint: "This will notify every user that registers to an event that the registration was successful"
= f.input :new_event_registration_subject
= f.input :new_event_registration_body, input_html: { rows: 10, cols: 20 }
%a.btn.btn-link.control_label.load_template{"data-template"=>"Dear {name},\n\nYou have successfully registered to attend session {eventtitle}. This session requires all attendees to register in advance. This is usually due to limited resources needed during the session, or room limitations. If for any reason you cannot make it, please unregister yourself to free up your slot for other visitors that wish to attend.\n\nFeel free to contact us with any questions or concerns.\n\nWe look forward to seeing you there.\n\nBest wishes\n\n{conference} Team",
"data-name"=>"email_settings_new_event_registration_body"} Load Template
%a.btn.btn-link.control_label.template_help_link{"data-name"=>"new_event_registration_help"} Show Help
= render partial: 'help', locals: { id: 'new_event_registration_help', show_event_variables: true }
.row
.col-md-12
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -97,7 +97,7 @@
on_text: 'Yes',
off_text: 'No' }
- if @event.require_registration
= registered_text(@event)
Registered: #{registered_text(@event)}
-if @program.languages.present?
%tr
@ -105,7 +105,6 @@
%b Language
%td
= @event.language
- if !@event.room.nil?
%tr
%td

View file

@ -99,7 +99,7 @@
off_text: 'No' }
- if event.require_registration
%br
= link_to registered_text(event), registrations_admin_conference_program_event_path(@conference.short_title, event), class: 'btn btn-xs btn-default'
= link_to "Registered: #{registered_text(event)}", admin_conference_program_event_events_registrations_path(@conference.short_title, event), class: 'btn btn-xs btn-default'
%td.text-center{'data-order' => "#{event.is_highlight}"}
= check_box_tag @conference.short_title, event.id, event.is_highlight,

View file

@ -0,0 +1,46 @@
.unobtrusive-flash-container
.container
.row
.col-md-10
.page-header
%h1
Registrations (#{@event.registrations.length}/#{@event.max_attendees})
.text-muted
for
= @event.title
.well
%table.table.table-hover.table-borderd.table-striped.datatable#registrations
%thead
%th
%th Registered
%th Name
%th Email
%th Created At
%th Attended
%th Attended Conference
%tbody
- @event.registrations.each.with_index(1) do |registration, index|
- event_registration = EventsRegistration.find_by(event_id: @event.id, registration_id: registration.id)
%tr
%td= index
%td
= check_box_tag "toggle-#{@conference.short_title}", registration.id, registration.events.include?(@event), method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{@event.id}/registrations/toggle?events_registrations[event_id]=#{@event.id}&&events_registrations[registration_id]=#{registration.id}&&registration_id=#{registration.id}&&state=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
%td= event_registration.name
%td= event_registration.email
%td= event_registration.created_at
%td
//We don't send the ID of the events_registration in the url of the switch-checkbox because
//the ID might have changed through the above switch-checkbox (which destroys or creates an events_registration).
//In that case the ID here would be invalid, before we would reload the page (to grab the new ID)
= check_box_tag "toggle_attendance-#{@conference.short_title}", @event.id, event_registration.attended, class: 'switch-checkbox', method: :patch, url: "/admin/conference/#{@conference.short_title}/program/events/#{@event.id}/registrations/toggle_attendance?registration_id=#{registration.id}&&event_registration[attended]=",
data: { size: 'small',
off_color: 'danger',
on_text: 'Yes',
off_text: 'No' }
%td
- if event_registration.registration.attended
%i.fa.fa-check.text-success
-else
%i.fa.fa-times.text-danger

View file

@ -0,0 +1 @@
$('.unobtrusive-flash-container').html('');

View file

@ -0,0 +1 @@
$('.unobtrusive-flash-container').html('');

View file

@ -0,0 +1,8 @@
.row
.col-md-10
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-edit.fa-stack-1x
There are #{@conference.program.events.require_registration.length} sessions that require you to #{link_to 'register', conference_program_events_registrations_path(@conference.short_title)}. Check them out!

View file

@ -1,20 +1,5 @@
- if @conference.questions.any?
= render partial: 'conference_registrations/questions', locals: { f: f }
- if @conference.program.events.with_registration_open.any? || @registration.events.any?
= f.inputs 'Pre-registration required for the following:' do
- @registration.events_ordered.each do |event|
%label
= hidden_field_tag "registration[event_ids][]", nil
= check_box_tag "registration[event_ids][]", event.id, event.registrations.include?(@registration)
= event.title
.text-muted
= registered_text(event)
- if event.scheduled?
(Scheduled on: #{event.start_time.to_date})
%br
= f.inputs 'Your Travel Info' do
= f.input :arrival, as: :string, label: 'Your arrival time', input_html: { value: (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), id: 'registration-arrival-datepicker',start_date: @conference.start_date,end_date: @conference.end_date,readonly: 'readonly' }

View file

@ -1,6 +1,7 @@
.container
.row
.col-md-12
.unobtrusive-flash-container
.page-header
%h1
Registration for
@ -54,33 +55,9 @@
= qa.answer.title
- else
You haven't answered
- if @registration.events.any?
.row
.col-md-12
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-check.fa-stack-1x
Registered to the following event(s)
%ul
- @registration.events.each do |event|
%li
= link_to event.title, conference_program_proposal_path(@conference.short_title, event.id)
= '(' + registered_text(event) + ')'
- if @registration.conference.program.events.remaining_for_registration(@registration).any?
.row
.col-md-12
%h4
%span.fa-stack
%i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-question.fa-stack-1x
Events that require registration
%ul
- @registration.conference.program.events.remaining_for_registration(@registration).each do |event|
%li
= link_to event.title, conference_program_proposal_path(@conference.short_title, event.id)
= '(' + registered_text(event) + ')'
- if @conference.program.events.require_registration.any?
.events-with-registration
= render partial: 'events_with_registration'
- if @conference.tickets.any?
.row
@ -117,6 +94,7 @@
.col-md-12
-if @registration
.btn-group-vertical.pull-right
= link_to 'Edit your Registration', edit_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-success', disabled: @conference.end_date < Date.today
= link_to 'Unregister', conference_conference_registrations_path(@conference.short_title),
method: :delete, class: 'btn btn-danger btn-xs', confirm: 'Are you sure you want to unregister?', disabled: @conference.end_date < Date.today

View file

@ -0,0 +1,54 @@
.container
.row
.col-md-11.col-md-offset-1
.unobtrusive-flash-container
.page-header
%h1
Sessions that require registration
= "(#{@program.events.require_registration.length})"
.text-muted
Some of the sessions require participants to pre-register. That gives us an idea about the amount of people interested in a particular session, and helps the speaker prepare for the amount of people that will show up. The speaker can limit the maximum number of attendees at any point, so if you are really interested in a session, go ahead and register for it!
- unless @registration
%br
Attention!!
You need to #{link_to 'register', new_conference_conference_registrations_path(@conference.short_title)} to attend the conference, before you can register to individual sessions.
.well
%table.table.table-hover.table-borderd.table-striped.datatable#registrations
%thead
%th
%th Registered
%th Title
%th Total Registrations
%th Scheduled
%tbody
- @events.each.with_index(1) do |event, index|
%tr
%td= index
%td.text-center
- if @registration
= check_box_tag "toggle-#{@conference.short_title}", event.id, event.registrations.include?(@registration), method: :patch, url: "/conference/#{@conference.short_title}/program/proposal/#{event.id}/registrations/toggle?events_registrations[event_id]=#{event.id}&&events_registrations[registration_id]=#{@registration.id}&&registration_id=#{@registration.id}&&state=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
- else
No
%td
.col-md-12
= link_to event.title, conference_program_proposal_path(@conference.short_title, event)
.text-muted
.col-md-10
= "by #{event.speakers.first.name}"
.col-md-2
= image_tag event.speakers.first.gravatar_url(size: 25), class: 'img-responsive img-rounded'
%td.text-center= registered_text(event)
%td
- if event.start_time
= event.start_time.strftime('%Y-%m-%d')
%br
= event.start_time.strftime('%H:%M')
- if event.room
%br
In room
= event.room.name

View file

@ -0,0 +1,43 @@
.container
.row
.col-md-10.col-md-offset-1
.unobtrusive-flash-container
.page-header
%h1
Registrations (#{@proposal.registrations.length}/#{@proposal.max_attendees})
.text-muted
for
= @proposal.title
.well
%table.table.table-hover.table-borderd.table-striped.datatable#registrations
%thead
%th
%th Registered
%th Name
%th Email
%th Created At
%th Attended
%th Attended Conference
%tbody
- @proposal.registrations.each.with_index(1) do |registration, index|
- event_registration = EventsRegistration.find_by(event_id: @proposal.id, registration_id: registration.id)
%tr
%td= index
%td
= check_box_tag "toggle-#{@conference.short_title}", registration.id, registration.events.include?(@proposal), method: :patch, url: "/conference/#{@conference.short_title}/program/proposal/#{@proposal.id}/registrations/toggle?events_registrations[event_id]=#{@proposal.id}&&events_registrations[registration_id]=#{registration.id}&&registration_id=#{registration.id}&&state=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
%td= event_registration.name
%td= event_registration.email
%td= event_registration.created_at
%td
= check_box_tag "toggle_attendance-#{@conference.short_title}", @proposal.id, event_registration.attended, class: 'switch-checkbox', method: :patch, url: "/conference/#{@conference.short_title}/program/proposal/#{@proposal.id}/registrations/toggle_attendance?&&registration_id=#{registration.id}&&event_registration[attended]=",
data: { size: 'small',
off_color: 'danger',
on_text: 'Yes',
off_text: 'No' }
%td
- if event_registration.registration.attended
%i.fa.fa-check.text-success
-else
%i.fa.fa-times.text-danger

View file

@ -0,0 +1 @@
$('.unobtrusive-flash-container').html('');

View file

@ -0,0 +1 @@
$('.unobtrusive-flash-container').html('');

View file

@ -48,8 +48,8 @@
words.
= f.inputs 'Enable pre-registration' do
= f.input :require_registration, label: 'Require participants to register to your event'
- message = @event.room ? "Value must be between 1 and #{@event.room.size}" : 'Check room capacity after scheduling.'
= f.input :require_registration, label: 'Require participants to register to your event', input_html: { disabled: @event.registrations.any? }, hint: 'If you enable this option, you must set the max number of attendees. You cannot disable this option, if there are registations.'
- message = @event.room ? "Value must be between 1 and #{@event.room.size}" : 'Check room capacity after scheduling, organizers might automatically reduce this number based on room capacity.'
= f.input :max_attendees, hint: 'The maximum number of participants. ' + message
- if current_user.has_any_role? :admin, { name: :organizer, resource: @conference }, { name: :cfp, resource: @conference }

View file

@ -70,7 +70,8 @@
= "in #{event.track.name}" if event.track
- if event.require_registration
%br
= link_to registered_text(event), registrations_conference_program_proposal_path(@conference.short_title, event), class: 'btn btn-xs btn-danger'
= link_to "Registered: #{registered_text(event)}",
conference_program_proposal_events_registrations_path(@conference.short_title, event), class: 'btn btn-xs btn-info'
%td.col-md-2{style: "padding:20px 8px 20px 8px;"}
= link_to 'Complete your proposal', 'javascript: void(0)', "type"=>"button", "data-trigger"=>"focus", "data-toggle"=>"popover", "title"=>"Your todo list", "data-content"=>"#{render partial: 'tooltip', locals: { event: event} }"

View file

@ -9,7 +9,7 @@
= @event.subtitle
.btn-group.pull-right
- if can? :update, @event
= link_to 'Registrations', registrations_conference_program_proposal_path(@conference.short_title, @event), class: 'btn btn-mini btn-success'
= link_to 'Registrations', conference_program_proposal_events_registrations_path(@conference.short_title, @event), class: 'btn btn-mini btn-success'
- if can? :edit, @event
= link_to "Edit", edit_conference_program_proposal_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary"
- if can? :schedule, @conference
@ -83,4 +83,4 @@
.col-md-12
%dt Requires Registration:
%dd
= link_to "Yes (#{registered_text(@event)})", new_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-xs btn-danger', disabled: !@event.registration_possible?
= link_to "Yes (Registered: #{registered_text(@event)})", conference_conference_registrations_path(@conference.short_title), class: 'btn btn-xs btn-info', disabled: !@event.registration_possible?