Add email notifications for events registrations, add switch-checkboxes, create EventsRegistrations controller, separate page for events that require registration
This commit is contained in:
parent
139a8565e2
commit
77af75f319
38 changed files with 1313 additions and 403 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue