Allow scheduling volunteers for sessions.
Also fix a small bug for admin registrations edit.
This commit is contained in:
parent
b664639817
commit
8e1d03a318
12 changed files with 110 additions and 31 deletions
|
|
@ -18,6 +18,9 @@ class Event < ApplicationRecord
|
|||
has_one :submitter_event_user, -> { where(event_role: 'submitter') }, class_name: 'EventUser'
|
||||
has_one :submitter, through: :submitter_event_user, source: :user
|
||||
|
||||
has_many :volunteer_event_users, -> { where(event_role: 'volunteer') }, class_name: 'EventUser'
|
||||
has_many :volunteers, through: :volunteer_event_users, source: :user
|
||||
|
||||
has_many :votes, dependent: :destroy
|
||||
has_many :voters, through: :votes, source: :user
|
||||
has_many :commercials, as: :commercialable, dependent: :destroy
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class EventUser < ApplicationRecord
|
||||
# TODO: Do we need these roles?
|
||||
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator]]
|
||||
ROLES = [%w[Speaker speaker], %w[Submitter submitter], %w[Moderator moderator],
|
||||
%w[Volunteer volunteer]]
|
||||
|
||||
belongs_to :event, touch: true
|
||||
belongs_to :user
|
||||
|
|
|
|||
|
|
@ -256,6 +256,12 @@ class User < ApplicationRecord
|
|||
result
|
||||
end
|
||||
|
||||
# TODO: Use a real authorization in the right place....
|
||||
def manages_volunteers?(conference)
|
||||
organizer_roles = get_roles['organizer']
|
||||
organizer_roles&.include?(conference.short_title) # TODO or Volunteer Coorinator.
|
||||
end
|
||||
|
||||
def registered
|
||||
registrations = self.registrations
|
||||
if registrations.count == 0
|
||||
|
|
@ -290,6 +296,11 @@ class User < ApplicationRecord
|
|||
proposals(conference).count
|
||||
end
|
||||
|
||||
def volunteer_duties(conference)
|
||||
events.where(program_id: conference.program.id, 'event_users.event_role': 'volunteer')
|
||||
end
|
||||
|
||||
|
||||
def self.empty?
|
||||
User.count == 1 && User.first.email == 'deleted@localhost.osem'
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue