Introduces new RegistrationPeriod Object for Conference

#416
This commit is contained in:
Chrisbr 2014-08-18 14:33:02 +02:00
parent a620950383
commit ed55e2bf3a
25 changed files with 529 additions and 131 deletions

View file

@ -7,12 +7,12 @@ $(function () {
pickTime: false,
format: "YYYY-MM-DD"
});
$("#conference-reg-start-datepicker").datetimepicker({
$("#registration-period-start-datepicker").datetimepicker({
format: "YYYY-MM-DD",
pickTime: false,
pickSeconds: false
});
$("#conference-reg-end-datepicker").datetimepicker({
$("#registration-period-end-datepicker").datetimepicker({
format: "YYYY-MM-DD",
pickTime: false,
pickSeconds: false

View file

@ -73,7 +73,6 @@ $(function () {
$('#' + $(this).data('name')).toggle();
});
$(".comment-reply-link").click(function(){
$(".comment-reply", $(this).parent()).toggle();
return false;

View file

@ -80,12 +80,10 @@ 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_dates_change?
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
send_mail_on_conf_update = @conference.notify_on_dates_changed?
if @conference.update_attributes(params[:conference])
Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to(edit_admin_conference_path(id: @conference.short_title),
notice: 'Conference was successfully updated.')
else

View file

@ -0,0 +1,57 @@
module Admin
class RegistrationPeriodsController < ApplicationController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference, singleton: true
def new
@registration_period = @conference.build_registration_period
end
def create
@registration_period = @conference.build_registration_period(registration_period)
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
if @registration_period.save
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to admin_conference_registration_period_path(@conference.short_title),
notice: 'Registration Period successfully updated.'
else
flash[:alert] = "A error prohibited the Registration Period from being saved: #{@registration_period.errors.full_messages.join('. ')}."
render :new
end
end
def edit
end
def show
end
def update
@registration_period.assign_attributes(registration_period)
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
if @registration_period.update(registration_period)
Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update
redirect_to admin_conference_registration_period_path(@conference.short_title),
notice: 'Registration Period successfully updated.'
else
flash[:alert] = "A error prohibited the Registration Period from being saved: " \
"#{@registration_period.errors.full_messages.join('. ')}."
render :edit
end
end
def destroy
@registration_period.destroy
redirect_to admin_conference_registration_period_path,
notice: 'Registration Period was successfully destroyed.'
end
private
def registration_period
params[:registration_period]
end
end
end

View file

@ -106,6 +106,7 @@ class Ability
can :manage, Contact, conference_id: conf_ids_for_organizer
can :manage, Campaign, conference_id: conf_ids_for_organizer
can :manage, Photo, conference_id: conf_ids_for_organizer
can :manage, RegistrationPeriod, conference_id: conf_ids_for_organizer
end
def guest

View file

@ -10,11 +10,11 @@ class Conference < ActiveRecord::Base
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
:dietary_choices_attributes, :use_dietary_choices, :use_supporter_levels,
:supporter_levels_attributes, :social_events_attributes, :event_types_attributes,
:registration_start_date, :registration_end_date, :logo, :questions_attributes,
:logo, :questions_attributes,
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
:vpositions_attributes, :use_volunteers, :color,
:description, :registration_description, :ticket_description,
:description, :ticket_description,
:sponsorship_levels_attributes, :sponsors_attributes,
:sponsor_description, :sponsor_email, :lodging_description,
:include_registrations_in_splash, :include_sponsors_in_splash,
@ -29,7 +29,7 @@ class Conference < ActiveRecord::Base
has_and_belongs_to_many :questions
has_one :contact, dependent: :destroy
has_one :registration_period, dependent: :destroy
has_one :email_settings, dependent: :destroy
has_one :call_for_papers, dependent: :destroy
has_many :social_events, dependent: :destroy
@ -128,8 +128,8 @@ class Conference < ActiveRecord::Base
# * +true+ -> If today is in the registration period.
def registration_open?
today = Date.current
if registration_dates_given?
(registration_start_date..registration_end_date).cover?(today)
if registration_period && registration_dates_given?
(registration_period.start_date..registration_period.end_date).cover?(today)
else
false
end
@ -142,7 +142,7 @@ class Conference < ActiveRecord::Base
# * +false+ -> If the conference registration dates are not set
# * +true+ -> If conference registration dates are set
def registration_dates_given?
if registration_start_date.blank? || registration_end_date.blank?
if registration_period && (registration_period.start_date.blank? || registration_period.end_date.blank?)
false
else
true
@ -218,8 +218,9 @@ class Conference < ActiveRecord::Base
result = []
if registrations &&
registration_start_date &&
registration_end_date
registration_period &&
registration_period.start_date &&
registration_period.end_date
reg = registrations.group(:week).count
start_week = get_registration_start_week
@ -237,8 +238,10 @@ class Conference < ActiveRecord::Base
def registration_weeks
result = 0
weeks = 0
if registration_start_date && registration_end_date
weeks = Date.new(registration_start_date.year, 12, 31).
if registration_period &&
registration_period.start_date &&
registration_period.end_date
weeks = Date.new(registration_period.start_date.year, 12, 31).
strftime('%W').to_i
result = get_registration_end_week - get_registration_start_week + 1
@ -265,7 +268,11 @@ class Conference < ActiveRecord::Base
# ====Returns
# * +Integer+ -> start week
def get_registration_start_week
registration_start_date.strftime('%W').to_i
result = -1
if registration_period
result = registration_period.start_date.strftime('%W').to_i
end
result
end
##
@ -274,7 +281,11 @@ class Conference < ActiveRecord::Base
# ====Returns
# * +Integer+ -> start week
def get_registration_end_week
registration_end_date.strftime('%W').to_i
result = -1
if registration_period
result = registration_period.end_date.strftime('%W').to_i
end
result
end
##
@ -430,13 +441,11 @@ class Conference < ActiveRecord::Base
# * +ActiveRecord+
def self.get_active_conferences_for_dashboard
result = Conference.where('start_date > ?', Time.now).
select('id, short_title, color, start_date,
registration_end_date, registration_start_date')
select('id, short_title, color, start_date')
if result.length == 0
result = Conference.
select('id, short_title, color, start_date, registration_end_date,
registration_start_date').limit(2).
select('id, short_title, color, start_date').limit(2).
order(start_date: :desc)
end
result
@ -448,8 +457,7 @@ class Conference < ActiveRecord::Base
# ====Returns
# * +ActiveRecord+
def self.get_conferences_without_active_for_dashboard(active_conferences)
result = Conference.select('id, short_title, color, start_date,
registration_end_date, registration_start_date').order(start_date: :desc)
result = Conference.select('id, short_title, color, start_date').order(start_date: :desc)
result - active_conferences
end
@ -525,11 +533,11 @@ class Conference < ActiveRecord::Base
# ====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
def notify_on_dates_changed?
(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
##
@ -539,10 +547,11 @@ class Conference < ActiveRecord::Base
# * +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
registration_period &&
(registration_period.start_date_changed? || registration_period.end_date_changed?) &&
email_settings.send_on_updated_conference_registration_dates &&
!email_settings.updated_conference_registration_dates_subject.blank? &&
email_settings.updated_conference_registration_dates_template
end
private
@ -737,7 +746,7 @@ class Conference < ActiveRecord::Base
# * +True+ -> If conference has a start and a end date.
# * +False+ -> If conference has no start or end date.
def registration_date_set?
!!registration_start_date && !!registration_end_date
!!registration_period && !!registration_period.start_date && !!registration_period.end_date
end
# Calculates the distribution from events.

View file

@ -19,8 +19,6 @@ class EmailSettings < ActiveRecord::Base
'conference' => conference.title,
'conference_start_date' => conference.start_date,
'conference_end_date' => conference.end_date,
'registration_start_date' => conference.registration_start_date,
'registration_end_date' => conference.registration_end_date,
'venue' => conference.venue.name,
'venue_address' => conference.venue.address,
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(
@ -33,6 +31,11 @@ class EmailSettings < ActiveRecord::Base
conference.short_title, host: CONFIG['url_for_emails'])
}
if conference.registration_period
h['registration_start_date'] = conference.registration_period.start_date
h['registration_end_date'] = conference.registration_period.end_date
end
if !event.nil?
h['eventtitle'] = event.title
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_url(

View file

@ -0,0 +1,7 @@
class RegistrationPeriod < ActiveRecord::Base
attr_accessible :description, :start_date, :end_date
validates :start_date, :end_date, presence: true
belongs_to :conference
end

View file

@ -20,9 +20,6 @@
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
= f.inputs name: 'Registration' do
= f.input :include_registrations_in_splash, hint: 'On setting this true you will enable the registrations to be displayed on the splash page'
= f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" }
= f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" }
= f.input :registration_description, hint: markdown_hint("This description will appear in registration segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
= f.input :ticket_description, hint: markdown_hint("This will appear in the Tickets segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
= f.input :sponsor_description, hint: markdown_hint("This will appear in the sponsor segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
= f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers'

View file

@ -8,8 +8,8 @@
= conference_progress['process'] + '%'
%li{'class'=>class_for_todo(conference_progress['registration'])}
%span{'class'=>icon_for_todo(conference_progress['registration'])}
- if can? :update, @conference.registrations.build
= link_to 'Set up registration period', edit_admin_conference_path(conference_progress['short_title'], :anchor => 'conference-end-datepicker')
- if can? :update, @conference
= link_to 'Set up registration period', edit_admin_conference_registration_period_path(conference_progress['short_title'])
- else
Set up registration period
%li{'class'=>class_for_todo(conference_progress['cfp'])}

View file

@ -0,0 +1,8 @@
%h1 Registration Period
.row
.col-md-8
= semantic_form_for(@registration_period, url: admin_conference_registration_period_path(@conference.short_title)) do |f|
= f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', readonly: 'readonly' }
= f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' }
= f.input :description, hint: markdown_hint('This will appear in the Tickets segment of the splash.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } }
= f.submit 'Save Registration Period', class: 'btn btn-primary'

View file

@ -0,0 +1,27 @@
%h1 Registration Period
- if @registration_period
.row
.col-md-6
%dl.dl-horizontal
%dt
Start Date
%dd
= @registration_period.start_date
%dt
End Date
%dd
= @registration_period.end_date
%dt
Description
%dd
- if !@conference.registration_period.description.blank?
= markdown(@conference.registration_period.description)
- if can? :update, @registration_period
= link_to 'Edit', edit_admin_conference_registration_period_path, class: 'btn btn-primary'
- if can? :destroy, @registration_period
= link_to 'Delete', admin_conference_registration_period_path,
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
- else
- if can? :create, @conference
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'

View file

@ -4,14 +4,14 @@
%div.container.text-center
%div.row
%h1 Registration
- if !@conference.registration_description.blank?
- if @conference.registration_period && !@conference.registration_period.description.blank?
.lead
= markdown(@conference.registration_description)
= markdown(@conference.registration_period.description)
- if @conference.registration_dates_given?
-if @conference.registration_end_date >= Date.today
%h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
-if @conference.registration_period.end_date >= Date.today
%h4 Registration period #{ date_string(@conference.registration_period.start_date, @conference.registration_period.end_date) }
-else
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_period.start_date, @conference.registration_period.end_date) }
- if @conference.registration_open?
= link_to "Register for #{@conference.short_title}", conference_register_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
- if @conference.use_supporter_levels?

View file

@ -48,6 +48,11 @@
= link_to(admin_conference_photos_path(@conference.short_title)) do
%span.fa.fa-picture-o
Photos
- if can? :update, @conference
%li{:class=> active_nav_li( admin_conference_registration_period_path (@conference.short_title))}
= link_to( admin_conference_registration_period_path (@conference.short_title)) do
%span.fa.fa-male
Registration Period
- if can? :update, @conference.events.build
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
= link_to(admin_conference_events_path(@conference.short_title)) do