Improving check-in process

mark user as present for the conference when user's registration ticket for that conference is scanned
This commit is contained in:
siddhantbajaj 2017-08-22 14:57:42 +05:30
parent ca5d139dc2
commit 69e30e7ba9
5 changed files with 49 additions and 2 deletions

View file

@ -47,7 +47,11 @@ class User < ActiveRecord::Base
has_many :event_users, dependent: :destroy
has_many :events, -> { uniq }, through: :event_users
has_many :presented_events, -> { joins(:event_users).where(event_users: {event_role: 'speaker'}).uniq }, through: :event_users, source: :event
has_many :registrations, dependent: :destroy
has_many :registrations, dependent: :destroy do
def for_conference conference
where(conference: conference).first
end
end
has_many :events_registrations, through: :registrations
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
@ -93,6 +97,12 @@ class User < ActiveRecord::Base
event_registration.attended
end
def mark_attendance_for_conference conference
registration = registrations.for_conference(conference)
registration.attended = true
registration.save
end
def name
self[:name].blank? ? username : self[:name]
end