mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Fixed DeleteEventSchedules issue
Issues with DeleteEventSchedules method in conference controller: 1.It deletes EventSchedules of all the conferences that are not in the hours range. Instead it should delete EventSchedules of those events only that belong to that particular conference only. 2.If we set invalid start or end hour attribute of a conference then also EventSchedules gets deleted even though conference is not successfully updated. Fixed both the issues and added test for the same.
This commit is contained in:
parent
ec71b111fe
commit
7ce816e146
3 changed files with 34 additions and 10 deletions
|
|
@ -67,6 +67,7 @@ class Conference < ActiveRecord::Base
|
|||
before_create :create_email_settings
|
||||
|
||||
after_create :create_free_ticket
|
||||
after_update :delete_event_schedules
|
||||
|
||||
##
|
||||
# Checks if the user is registered to the conference
|
||||
|
|
@ -80,6 +81,20 @@ class Conference < ActiveRecord::Base
|
|||
user.present? && registrations.where(user_id: user.id).count > 0
|
||||
end
|
||||
|
||||
##
|
||||
# Delete all EventSchedules that are not in the hours range
|
||||
# After the conference has been successfully updated
|
||||
def delete_event_schedules
|
||||
if start_hour_changed? || end_hour_changed?
|
||||
event_schedules = program.event_schedules.select do |event_schedule|
|
||||
event_schedule.start_time.hour < start_hour ||
|
||||
event_schedule.end_time.hour > end_hour ||
|
||||
(event_schedule.end_time.hour == end_hour && event_schedule.end_time.minute > 0)
|
||||
end
|
||||
event_schedules.each(&:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the registration for the conference is currently open
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue