mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Removes dulplicate conference update action and moves methods out of private area
This commit is contained in:
parent
71bf793cdf
commit
d0e9805456
3 changed files with 35 additions and 55 deletions
|
|
@ -80,8 +80,8 @@ module Admin
|
|||
@conference = Conference.find_by(short_title: params[:id])
|
||||
short_title = @conference.short_title
|
||||
@conference.assign_attributes(params[:conference])
|
||||
send_mail_on_conf_update = @conference.notify_on_conf_dates_updates?
|
||||
send_mail_on_reg_update = @conference.notify_on_conf_reg_dates_updates?
|
||||
send_mail_on_conf_update = @conference.notify_on_dates_change?
|
||||
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
|
||||
|
||||
if @conference.update_attributes(params[:conference])
|
||||
Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update
|
||||
|
|
@ -95,33 +95,6 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@conference = Conference.find_by(short_title: params[:id])
|
||||
short_title = @conference.short_title
|
||||
@conference.assign_attributes(params[:conference])
|
||||
notify_on_conf_dates_updates = (@conference.start_date_changed? || @conference.end_date_changed?)\
|
||||
&& @conference.email_settings.send_on_updated_conference_dates\
|
||||
&& !@conference.email_settings.updated_conference_dates_subject.blank?\
|
||||
&& @conference.email_settings.updated_conference_dates_template
|
||||
|
||||
notify_on_conf_reg_dates_updates = (@conference.registration_start_date_changed? || @conference.registration_end_date_changed?)\
|
||||
&& @conference.email_settings.send_on_updated_conference_registration_dates\
|
||||
&& !@conference.email_settings.updated_conference_registration_dates_subject.blank?\
|
||||
&& @conference.email_settings.updated_conference_registration_dates_template
|
||||
|
||||
if @conference.update_attributes(params[:conference])
|
||||
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
|
||||
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
|
||||
|
||||
redirect_to(edit_admin_conference_path(id: @conference.short_title),
|
||||
notice: 'Conference was successfully updated.')
|
||||
else
|
||||
redirect_to(edit_admin_conference_path(id: short_title),
|
||||
alert: 'Updating conference failed. ' \
|
||||
"#{@conference.errors.full_messages.join('. ')}.")
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@conference = Conference.find_by(short_title: params[:id])
|
||||
|
||||
|
|
|
|||
|
|
@ -519,6 +519,32 @@ class Conference < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if conference is updated for email notifications.
|
||||
#
|
||||
# ====Returns
|
||||
# * +True+ -> If conference is updated and all other parameters are set
|
||||
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
||||
def notify_on_dates_change?
|
||||
(self.start_date_changed? || self.end_date_changed?)\
|
||||
&& self.email_settings.send_on_updated_conference_dates\
|
||||
&& !self.email_settings.updated_conference_dates_subject.blank?\
|
||||
&& self.email_settings.updated_conference_dates_template
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if registration dates are updated for email notifications.
|
||||
#
|
||||
# ====Returns
|
||||
# * +True+ -> If registration dates is updated and all other parameters are set
|
||||
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
||||
def notify_on_registration_dates_changed?
|
||||
(self.registration_start_date_changed? || self.registration_end_date_changed?)\
|
||||
&& self.email_settings.send_on_updated_conference_registration_dates\
|
||||
&& !self.email_settings.updated_conference_registration_dates_subject.blank?\
|
||||
&& self.email_settings.updated_conference_registration_dates_template
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
after_create do
|
||||
|
|
@ -933,30 +959,4 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
result
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if conference is updated for email notifications.
|
||||
#
|
||||
# ====Returns
|
||||
# * +True+ -> If conference is updated and all other parameters are set
|
||||
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
||||
def notify_on_conf_dates_updates?
|
||||
(self.start_date_changed? || self.end_date_changed?)\
|
||||
&& self.email_settings.send_on_updated_conference_dates\
|
||||
&& !self.email_settings.updated_conference_dates_subject.blank?\
|
||||
&& self.email_settings.updated_conference_dates_template
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if registration dates are updated for email notifications.
|
||||
#
|
||||
# ====Returns
|
||||
# * +True+ -> If registration dates is updated and all other parameters are set
|
||||
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
||||
def notify_on_reg_dates?
|
||||
(self.registration_start_date_changed? || self.registration_end_date_changed?)\
|
||||
&& self.email_settings.send_on_updated_conference_registration_dates\
|
||||
&& !self.email_settings.updated_conference_registration_dates_subject.blank?\
|
||||
&& self.email_settings.updated_conference_registration_dates_template
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,6 +52,13 @@ feature Conference do
|
|||
click_link 'Edit'
|
||||
fill_in 'conference_title', with: 'New Con'
|
||||
fill_in 'conference_short_title', with: 'NewCon'
|
||||
day = Date.today + 10
|
||||
page.
|
||||
execute_script("$('#conference-start-datepicker').val('" +
|
||||
"#{day.strftime('%d/%m/%Y')}')")
|
||||
page.
|
||||
execute_script("$('#conference-end-datepicker').val('" +
|
||||
"#{(day + 7).strftime('%d/%m/%Y')}')")
|
||||
|
||||
click_button 'Update Conference'
|
||||
expect(flash).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue