diff --git a/app/assets/javascripts/osem-datepickers.js b/app/assets/javascripts/osem-datepickers.js
index d79a905d..919d638c 100644
--- a/app/assets/javascripts/osem-datepickers.js
+++ b/app/assets/javascripts/osem-datepickers.js
@@ -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
diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js
index e44d5ae5..1afb2c3a 100644
--- a/app/assets/javascripts/osem.js
+++ b/app/assets/javascripts/osem.js
@@ -73,7 +73,6 @@ $(function () {
$('#' + $(this).data('name')).toggle();
});
-
$(".comment-reply-link").click(function(){
$(".comment-reply", $(this).parent()).toggle();
return false;
diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb
index 472eaf77..813e13b7 100644
--- a/app/controllers/admin/conference_controller.rb
+++ b/app/controllers/admin/conference_controller.rb
@@ -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
diff --git a/app/controllers/admin/registration_periods_controller.rb b/app/controllers/admin/registration_periods_controller.rb
new file mode 100644
index 00000000..aa9ba661
--- /dev/null
+++ b/app/controllers/admin/registration_periods_controller.rb
@@ -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
diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb
deleted file mode 100644
index a6ba21b8..00000000
--- a/app/controllers/admin/stats_controller.rb
+++ /dev/null
@@ -1,232 +0,0 @@
-module Admin
- class StatsController < Admin::BaseController
- load_and_authorize_resource
- load_and_authorize_resource :conference, find_by: :short_title
-
- def index
- @registrations = @conference.registrations.includes(:user)
- @registrations = @registrations.order('registrations.created_at ASC')
- @registered = @conference.registrations.count
- @attendees = @conference.registrations.where('attended = ?', true).count
- @pre_registered = @conference.registrations
- @pre_registered = @pre_registered.where('created_at < ?', @conference.start_date).count
- @pre_registered_attended = @conference.registrations.where('created_at < ? AND attended = ?',
- @conference.start_date, true).count
-
- @registered_with_partner = @conference.registrations.where('attending_with_partner = ?',
- true).count
- @attended_with_partner = @conference.registrations.where(
- 'attending_with_partner = ? AND attended = ?', true, true).count
-
- @handicapped_access = @conference.registrations.where(handicapped_access_required: true).count
- @handicapped_access_attended = @conference.registrations.where(handicapped_access_required:
- true)
- @handicapped_access_attended = @handicapped_access_attended.where(attended: true).count
- @suggested_hotel_stay = @conference.registrations.where('using_affiliated_lodging = ?',
- true).count
-
- @events = @conference.events
- # Events charts
- @machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'],
- ['new', 'review'], ['unconfirmed', 'accepted']]
- # Types distribution per state
- @type_state = {}
- @machine_states.each do |state|
- @type_state[state[0]] = var_state_func(@conference.event_types, 'event_type', state)
- end
-
- # Tracks distribution per state
- @no_track_all = @events.where(track_id: nil)
- @no_track_new = @events.where(track_id: nil).where(state: ['new', 'review'])
- @no_track_unconfirmed = @events.where(track_id: nil).where(state: 'unconfirmed')
- @no_track_confirmed = @events.where(track_id: nil).where(state: 'confirmed')
- @track_state = {}
- @machine_states.each do |state|
- @track_state[state[0]] = var_state_func(@conference.tracks, 'track', state)
- end
-
- # Events_time chart
- if @events.count > 0
- start_date = @events.minimum('created_at').strftime('%Y-%m-%d')
- end_date = @events.maximum('created_at').strftime('%Y-%m-%d')
- unless start_date.nil? || end_date.nil?
- @events_time = var_time(start_date, end_date, @events, 'created_at')
- end
- end
-
- # Code for the table in events
- @mystates = []
- @mytypes = []
- @eventstats = {}
- @totallength = 0
- # Get totals per state
- @events.state_machine.states.map.each do |mystate|
- length = 0
- events_mystate = @events.where('state' => mystate.name)
- if events_mystate.count > 0
- @mystates << mystate
- events_mystate.each do |myevent|
- length += myevent.event_type.length
- end
- @eventstats["#{mystate.name}"] = { 'count' => events_mystate.count, 'length' => length }
- end
- end
-
- @conference.event_types.each do |mytype|
- events_mytype = @events.where('event_type_id' => mytype.id)
- if events_mytype.count > 0
- @mytypes << mytype
- end
- end
- @mytypes.each do |mytype|
- @mystates.each do |mystate|
- events_mytype = @events.where('event_type_id' => mytype.id)
- events_mytype_mystate = events_mytype.where('state' => mystate.name)
- typelength = 0
- if events_mytype_mystate.count > 0
- events_mytype_mystate.each do |myevent|
- typelength += myevent.event_type.length
- @totallength += myevent.event_type.length
- end
- if @eventstats[mytype.title].nil?
- @eventstats[mytype.title] = { 'count' => events_mytype.count,
- 'length' => events_mytype.count * mytype.length }
- end
-
- tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count,
- 'type_state_length' => typelength } }
- @eventstats[mytype.title].merge!(tmp)
- end
- end
- end
- @eventstats['totallength'] = @totallength
-
- # SPEAKERS stats
- @speakers = User.joins(:events).where('events.conference_id = ? AND events.state LIKE ?',
- @conference.id, 'confirmed').uniq
- @speaker_fields_user = %w(name email affiliation)
- @speaker_fields_reg = %w(arrival departure)
- # TICKETS stats
- @supporter_levels = @conference.supporter_levels
- @tickets = @conference.registrations.joins(supporter_registration: :supporter_level)
- @tickets = @tickets.where('supporter_levels.title NOT LIKE ? ', '%Free%')
-
- @tickets_time = []
-
- if @conference.registration_start_date && @conference.end_date && @registered > 0 && @supporter_levels
- start_date = @conference.registration_start_date
- end_date = @conference.end_date
- levels = []
- @conference.supporter_levels.each do |level|
- @tickets_time << { 'key' => level.title, 'values' => [] }
- levels << ["#{level.title}"]
- end
-
- (start_date..end_date).each do |day|
- if @tickets.where('supporter_registrations.created_at LIKE ?', "%#{day}%").where(
- 'supporter_levels.title' => levels).count != 0
- @conference.supporter_levels.each do |level|
-
- day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ?
- AND supporter_levels.title LIKE ?',
- "%#{day}%", "%#{level.title}%").count
-
- index = @tickets_time.index { |v| v['key'] == "#{level.title}" }
- @tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count }
- end
- end
- end
- end
- @tickets_distribution = []
- @tickets_time.each do |ticket|
- value = ticket['values'].map { |x| x['value'] }.sum
- percent = (value.to_f / @tickets.count * 100).round(2)
- @tickets_distribution << { 'status' => ticket['key'],
- 'value' => value, 'percent' => percent }
- end
-
- # OTHER_INFO chart / To be 'Questions'
- @other_info = [
- { 'status' => 'with partner (registered)', 'value' => @registered_with_partner },
- { 'status' => 'with partner (attended)', 'value' => @attended_with_partner },
- { 'status' => 'handicapped (registered)', 'value' => @handicapped_access },
- { 'status' => 'handicapped (attended)', 'value' => @handicapped_access_attended },
- { 'status' => 'stay at suggested hotel', 'value' => @suggested_hotel_stay }
- ]
-
- # REGISTRATIONS, registered_time
- if @conference.registration_start_date && @conference.end_date && @registered > 0
- start_date = @conference.registration_start_date
- end_date = @conference.end_date
- @registered_time = var_time(start_date, end_date, @registrations, 'created_at')
- end
-
- respond_to do |format|
- format.html
- format.json { render json: @tickets_time.to_json }
- end
- end
- # FUNCTIONS
- def var_time(start_date, end_date, var, field)
- result = []
- (start_date..end_date).each do |day|
- day_var_count = var.where("#{field} LIKE ?", "%#{day}%").count
- if day_var_count != 0
- result << { 'status' => "#{day}", 'value' => day_var_count }
- end
- end
- result
- end
-
- def var_state_func(vars, field, mystate)
- result = []
-
- vars.each do |myvar|
- # Find events per track and state
- value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count
- # Find all events in that state
- total = @conference.events.where(state: mystate).count
- status = "#{myvar.name}"
-
- percent = 0 # rubocop:disable Lint/UselessAssignment
- if value != 0
- percent = (value.to_f / total * 100).round(2)
- result << { 'status' => status, 'value' => value, 'percent' => percent }
- end
- end
- # Get no of events for which the field is not set (So that pie shows half piece for 50%)
- sum = result.inject(0) { |s, hash| s + hash['value'] }
- value = total - sum
- if sum != 0 && value != 0
- percent = (value.to_f / total * 100).round(2)
- result << { 'status' => "no #{field} set", 'value' => value, 'percent' => percent }
- end
-
- result
- end
-
- def speaker_reg(speaker)
- speaker.registrations.where('conference_id = ? AND user_id = ?',
- @conference.id, speaker.id).first
- end
-
- def speaker_diet(reg)
- @conference.dietary_choices.find(reg.dietary_choice_id)
- end
-
- def diet_count(diet)
- @conference.registrations.where('dietary_choice_id = ?', diet)
- end
-
- def social_event_count(event)
- @conference.registrations.joins(:social_events).where(
- 'registrations_social_events.social_event_id = ?', event).count
- end
-
- helper_method :speaker_reg
- helper_method :speaker_diet
- helper_method :diet_count
- helper_method :social_event_count
- end
-end
-
diff --git a/app/models/ability.rb b/app/models/ability.rb
index a7fb93e6..e0395047 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -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
diff --git a/app/models/conference.rb b/app/models/conference.rb
index 171b79bb..e9953172 100644
--- a/app/models/conference.rb
+++ b/app/models/conference.rb
@@ -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.
diff --git a/app/models/email_settings.rb b/app/models/email_settings.rb
index 6ada5ca6..a11ee750 100644
--- a/app/models/email_settings.rb
+++ b/app/models/email_settings.rb
@@ -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(
diff --git a/app/models/registration_period.rb b/app/models/registration_period.rb
new file mode 100644
index 00000000..f37b5f2f
--- /dev/null
+++ b/app/models/registration_period.rb
@@ -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
diff --git a/app/views/admin/conference/_edit_form.html.haml b/app/views/admin/conference/_edit_form.html.haml
index ce71e6b2..010a8b48 100644
--- a/app/views/admin/conference/_edit_form.html.haml
+++ b/app/views/admin/conference/_edit_form.html.haml
@@ -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'
diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml
index acb0155e..ffb4d096 100644
--- a/app/views/admin/conference/_todo_list.html.haml
+++ b/app/views/admin/conference/_todo_list.html.haml
@@ -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'])}
diff --git a/app/views/admin/registration_periods/_form.html.haml b/app/views/admin/registration_periods/_form.html.haml
new file mode 100644
index 00000000..a724c7ae
--- /dev/null
+++ b/app/views/admin/registration_periods/_form.html.haml
@@ -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'
diff --git a/app/views/admin/registration_periods/show.html.haml b/app/views/admin/registration_periods/show.html.haml
new file mode 100644
index 00000000..c828a095
--- /dev/null
+++ b/app/views/admin/registration_periods/show.html.haml
@@ -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'
diff --git a/app/views/admin/stats/_events.html.haml b/app/views/admin/stats/_events.html.haml
deleted file mode 100644
index 04c07c4b..00000000
--- a/app/views/admin/stats/_events.html.haml
+++ /dev/null
@@ -1,41 +0,0 @@
--if @events.count > 0
- %h2{:style => "text-align: center"}
- = "Events (#{@events.count})"
-
- .row-fluid
- %h3
- %u Types per event state
- - if !@conference.event_types.empty?
- = render :partial => "events_types"
- - else
- %h4
- %i There are no tracks defined for this conference!
-
- .row-fluid
- %h3
- %u Tracks per event state
- - if @no_track_all.count > 0
- %i= " (#{pluralize(@no_track_all.count, 'event')} not assigned to a track)"
- - if !@conference.tracks.empty?
- = render :partial => "events_tracks"
- - else
- %h4
- %i There are no tracks defined for this conference!
-
- .row-fluid
- .span12
- %h3 Proposal Submissions over time
- .row-fluid
- .span12#events_time
- = render :partial => "events_time"
-
- .row-fluid
- .span12
- %br
- %h3 Overview of all events
- .row-fluid
- .span12#events_table
- = render :partial => "events_table"
-
-- else
- %h5 There are no submitted events yet.
diff --git a/app/views/admin/stats/_events_table.html.haml b/app/views/admin/stats/_events_table.html.haml
deleted file mode 100644
index 0477f18a..00000000
--- a/app/views/admin/stats/_events_table.html.haml
+++ /dev/null
@@ -1,34 +0,0 @@
-%table.table.table-bordered.table-striped
- %thead
- %th
- - @mystates.each do |state|
- %th{:colspan => 2, :style => "text-align:center"}
- State "#{state.name}"
- %th{:colspan => 2, :style => "text-align:center"}
- Total
- %br
- No & Time
-
- %tr
- %td
- %b Total
- - @mystates.each do |mystate|
- %td
- %b
- = @eventstats["#{mystate.name}"]["count"]
- %td
- %b
- #{@eventstats["#{mystate.name}"]["length"] / 60} h #{@eventstats["#{mystate.name}"]["length"] - @eventstats["#{mystate.name}"]["length"] / 60 * 60} m
- %td
- %b= @events.count
- %td
- %b= show_time(@eventstats["totallength"])
-
- - @mytypes.each do |mytype|
- %tr
- %td= "#{mytype.title} (#{show_time(mytype.length)})"
- - @mystates.each do |mystate|
- %td= @eventstats["#{mytype.title}"]["#{mystate.name}"]["type_state_count"] unless @eventstats["#{mytype.title}"]["#{mystate.name}"] == nil
- %td= show_time(@eventstats["#{mytype.title}"]["#{mystate.name}"]["type_state_length"]) unless @eventstats["#{mytype.title}"]["#{mystate.name}"] == nil
- %td= @eventstats["#{mytype.title}"]["count"]
- %td= show_time(@eventstats["#{mytype.title}"]["length"])
diff --git a/app/views/admin/stats/_events_time.html b/app/views/admin/stats/_events_time.html
deleted file mode 100644
index 25f18d6b..00000000
--- a/app/views/admin/stats/_events_time.html
+++ /dev/null
@@ -1,71 +0,0 @@
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_tracks.html.haml b/app/views/admin/stats/_events_tracks.html.haml
deleted file mode 100644
index 6ecef217..00000000
--- a/app/views/admin/stats/_events_tracks.html.haml
+++ /dev/null
@@ -1,35 +0,0 @@
-.row-fluid
- - if !@track_state['new'].empty?
- .span4
- %h4 New Submissions
- - if @no_track_new.count > 0
- %h5= "#{pluralize(@no_track_new.count, 'event')} not assigned to a track"
- - else
- %h5
- .row-fluid
- .span12#events_tracks_new
- = render :partial => "events_tracks_new"
-
- - if !@track_state['unconfirmed'].empty?
- .span4
- %h4 Accepted (Unconfirmed)
- - if @no_track_unconfirmed.count > 0
- %h5= "#{pluralize(@no_track_unconfirmed.count, 'event')} not assigned to a track"
- - else
- %h5 All events assigned to track!
-
- .row-fluid
- .span12#events_tracks_unconfirmed
- = render :partial => "events_tracks_unconfirmed"
-
- - if !@track_state['confirmed'].empty?
- .span4
- %h4 Accepted (Confirmed)
- - if @no_track_confirmed.count > 0
- %h5= "#{pluralize(@no_track_confirmed.count, 'event')} not assigned to a track"
- - else
- %h5 All events assigned to track!
-
- .row-fluid
- .span12#events_tracks_confirmed
- = render :partial => "events_tracks_confirmed"
diff --git a/app/views/admin/stats/_events_tracks_confirmed.html b/app/views/admin/stats/_events_tracks_confirmed.html
deleted file mode 100644
index d031ed30..00000000
--- a/app/views/admin/stats/_events_tracks_confirmed.html
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_tracks_new.html b/app/views/admin/stats/_events_tracks_new.html
deleted file mode 100644
index d8d4e81c..00000000
--- a/app/views/admin/stats/_events_tracks_new.html
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_tracks_unconfirmed.html b/app/views/admin/stats/_events_tracks_unconfirmed.html
deleted file mode 100644
index 1af6b1ad..00000000
--- a/app/views/admin/stats/_events_tracks_unconfirmed.html
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_types.html.haml b/app/views/admin/stats/_events_types.html.haml
deleted file mode 100644
index 3d6ac9fd..00000000
--- a/app/views/admin/stats/_events_types.html.haml
+++ /dev/null
@@ -1,19 +0,0 @@
-.row-fluid
- - if !@type_state['new'].empty?
- .span4
- %h4 New Submissions: #{@type_state['new'].map{|x| x["value"]}.sum}
- .row-fluid
- .span12#events_types_new
- = render :partial => "events_types_new"
- - if !@type_state['unconfirmed'].empty?
- .span4
- %h4 Accepted (Unconfirmed): #{@type_state['unconfirmed'].map{|x| x["value"]}.sum}
- .row-fluid
- .span12#events_types_unconfirmed
- = render :partial => "events_types_unconfirmed"
- - if !@type_state['confirmed'].empty?
- .span4
- %h4 Accepted (Confirmed): #{@type_state['confirmed'].map{|x| x["value"]}.sum}
- .row-fluid
- .span12#events_types_confirmed
- = render :partial => "events_types_confirmed"
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_types_confirmed.html b/app/views/admin/stats/_events_types_confirmed.html
deleted file mode 100644
index 247e8a14..00000000
--- a/app/views/admin/stats/_events_types_confirmed.html
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_types_new.html b/app/views/admin/stats/_events_types_new.html
deleted file mode 100644
index fc560371..00000000
--- a/app/views/admin/stats/_events_types_new.html
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_events_types_unconfirmed.html b/app/views/admin/stats/_events_types_unconfirmed.html
deleted file mode 100644
index 4335eab0..00000000
--- a/app/views/admin/stats/_events_types_unconfirmed.html
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_other_info.html b/app/views/admin/stats/_other_info.html
deleted file mode 100644
index 33dd56eb..00000000
--- a/app/views/admin/stats/_other_info.html
+++ /dev/null
@@ -1,70 +0,0 @@
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_preregistered_onsite.html b/app/views/admin/stats/_preregistered_onsite.html
deleted file mode 100644
index f8b9038e..00000000
--- a/app/views/admin/stats/_preregistered_onsite.html
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_registered_attended.html b/app/views/admin/stats/_registered_attended.html
deleted file mode 100644
index 67c9006c..00000000
--- a/app/views/admin/stats/_registered_attended.html
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_registered_time.html b/app/views/admin/stats/_registered_time.html
deleted file mode 100644
index e3de08e0..00000000
--- a/app/views/admin/stats/_registered_time.html
+++ /dev/null
@@ -1,71 +0,0 @@
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_registrations.html.haml b/app/views/admin/stats/_registrations.html.haml
deleted file mode 100644
index d57b2620..00000000
--- a/app/views/admin/stats/_registrations.html.haml
+++ /dev/null
@@ -1,41 +0,0 @@
-.row
- .col-md-4
- - if @registered > 0
- - if @attendees > 0
- %h4{:style => "text-indent: 25px"}= "Registrations - Attendees (#{(@attendees.to_f / @registered * 100).round }%)"
- - else
- %h4{:style => "text-indent: 25px"}= "Registrations - Attendees"
- .row-fluid
- .span12#registrations_attendees
- = render :partial => "registrations_attendees"
- - else
- %h5 There are no registrations yet.
-
- .col-md-4
- - if @registered > 0
- %h4{:style => "text-indent: 10px"}= "Attendance of pre-registered"
- .row-fluid
- .span12#registered_attended
- = render :partial => "registered_attended"
-
- .col-md-4
- - if @registered > 0
- %h4{:style => "text-indent: 25px"}= "% of pre-registered"
- .row-fluid
- .span12#preregistered_onsite
- = render :partial => "preregistered_onsite"
-
-.row
- .col-md-6
- - if @registered > 0
- %h4= "Other Info"
- .row-fluid
- .span12#other_info
- = render :partial => "other_info"
-
- .col-md-6
- - if @registered > 0
- %h4{:style => "text-indent: 98px"}= "Registrations over time"
- .row-fluid
- .span12#registered_time
- = render :partial => "registered_time"
diff --git a/app/views/admin/stats/_registrations_attendees.html b/app/views/admin/stats/_registrations_attendees.html
deleted file mode 100644
index 89079236..00000000
--- a/app/views/admin/stats/_registrations_attendees.html
+++ /dev/null
@@ -1,77 +0,0 @@
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_speakers.html.haml b/app/views/admin/stats/_speakers.html.haml
deleted file mode 100644
index 1525126c..00000000
--- a/app/views/admin/stats/_speakers.html.haml
+++ /dev/null
@@ -1,37 +0,0 @@
-- count =0
-%h3
- Speakers (#{@speakers.length})
-%table.table.table-striped.table-bordered.table-hover#speakertable
- %thead
- %th
- ID
- - (@speaker_fields_user + @speaker_fields_reg).each do |field|
- %th
- = field.capitalize
- - @speakers.each do |speaker|
- %tr
- %td
- = count +=1
- - @speaker_fields_user.each do |field|
- %td
- = speaker.send(field.to_sym)
- - @speaker_fields_reg.each do |field|
- %td
- - reg = speaker_reg(speaker)
- - if !reg.nil?
- - if field == "diet"
- - if reg.dietary_choice_id
- = speaker_diet(reg).title
- %br
- = reg.other_dietary_choice
- - elsif field == 'arrival' || field == 'departure'
- = getdatetime(reg, field)
- - else
- = reg.send(field.to_sym)
-
-:javascript
- $(document).ready(function(){
- $('#speakertable').dataTable({
- "bPaginate": false
- });
- });
\ No newline at end of file
diff --git a/app/views/admin/stats/_tickets.html.haml b/app/views/admin/stats/_tickets.html.haml
deleted file mode 100644
index f9e25c39..00000000
--- a/app/views/admin/stats/_tickets.html.haml
+++ /dev/null
@@ -1,22 +0,0 @@
-- if @tickets.length > 0
- .row-fluid
- .span12
- %h2
- = "Non-Free Tickets (#{@tickets.count})"
- .row-fluid
- .span4
- %h4 Ticket distribution
- .row-fluid
- .span12#tickets_distribution
- = render :partial => "tickets_distribution"
- .row-fluid
- .span10
- %h4 Ticket sales over time
- .row-fluid
- .span12#tickets_time
- = render :partial => "tickets_time"
-- else
- - if @conference.use_supporter_levels
- %h5 No tickets have been bought yet.
- - else
- %h5 There are no tickets set for this conference.
\ No newline at end of file
diff --git a/app/views/admin/stats/_tickets_distribution.html b/app/views/admin/stats/_tickets_distribution.html
deleted file mode 100644
index b12163d1..00000000
--- a/app/views/admin/stats/_tickets_distribution.html
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/app/views/admin/stats/_tickets_time.html b/app/views/admin/stats/_tickets_time.html
deleted file mode 100644
index 6e0b8d44..00000000
--- a/app/views/admin/stats/_tickets_time.html
+++ /dev/null
@@ -1 +0,0 @@
-(Not yet implemented)
\ No newline at end of file
diff --git a/app/views/admin/stats/index.html.haml b/app/views/admin/stats/index.html.haml
deleted file mode 100644
index a18f9642..00000000
--- a/app/views/admin/stats/index.html.haml
+++ /dev/null
@@ -1,27 +0,0 @@
-.row
- .col-md-12
- %ul.nav.nav-tabs#myTab
- %li.active
- %a{:href=>"#registrations", "data-toggle"=>"tab"} Registrations
- %li
- %a{:href=>"#events", "data-toggle"=>"tab"} Events
- %li
- %a{:href=>"#speakers", "data-toggle"=>"tab"} Speakers
- %li
- %a{:href=>"#tickets", "data-toggle"=>"tab"} Tickets
-
- .tab-content
- .tab-pane.active#registrations
- = render :partial => 'registrations'
- .tab-pane#events
- = render :partial => 'events'
- .tab-pane#speakers
- = render :partial => 'speakers'
- .tab-pane#tickets
- = render :partial => 'tickets'
-
-:javascript
- $('#myTab a').click(function (e) {
- e.preventDefault();
- $(this).tab('show');
- })
diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml
index 6b91ad77..7448ba8c 100644
--- a/app/views/conference/_registration.html.haml
+++ b/app/views/conference/_registration.html.haml
@@ -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?
diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml
index 00db00b4..fee18ecc 100644
--- a/app/views/layouts/_admin_sidebar.html.haml
+++ b/app/views/layouts/_admin_sidebar.html.haml
@@ -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
diff --git a/config/routes.rb b/config/routes.rb
index 89fc6e9e..3bbe4cf4 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -30,6 +30,8 @@ Osem::Application.routes.draw do
patch '/registrations/change_field' => 'registrations#change_field'
resources :registrations
+ resource :registration_period
+
resources :difficulty_levels, only: [:show, :update, :index]
resources :rooms, only: [:show, :update, :index]
diff --git a/db/migrate/20140804185823_create_registration_periods.rb b/db/migrate/20140804185823_create_registration_periods.rb
new file mode 100644
index 00000000..4906144a
--- /dev/null
+++ b/db/migrate/20140804185823_create_registration_periods.rb
@@ -0,0 +1,16 @@
+class CreateRegistrationPeriods < ActiveRecord::Migration
+ def up
+ create_table :registration_periods do |t|
+ t.integer :conference_id
+ t.date :start_date
+ t.date :end_date
+ t.text :description
+
+ t.timestamps
+ end
+ end
+
+ def down
+ drop_table :registration_periods
+ end
+end
diff --git a/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb b/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb
new file mode 100644
index 00000000..87ada43f
--- /dev/null
+++ b/db/migrate/20140812065531_move_conference_registration_data_to_registration_periods.rb
@@ -0,0 +1,33 @@
+class MoveConferenceRegistrationDataToRegistrationPeriods < ActiveRecord::Migration
+ class TempConference < ActiveRecord::Base
+ self.table_name = 'conferences'
+ end
+
+ class TempRegistrationPeriod < ActiveRecord::Base
+ self.table_name = 'registration_periods'
+ attr_accessible :conference_id, :start_date, :end_date, :description
+ end
+
+ def up
+ # Move all the settings to the new object
+ TempConference.all.each do |conference|
+ unless TempRegistrationPeriod.exists?(conference_id: conference.id)
+ TempRegistrationPeriod.create(conference_id: conference.id,
+ start_date: conference.registration_start_date,
+ end_date: conference.registration_end_date,
+ description: conference.registration_description)
+ end
+ end
+
+ # Remove Columns
+ remove_column :conferences, :registration_start_date
+ remove_column :conferences, :registration_end_date
+ remove_column :conferences, :registration_description
+ end
+
+ def down
+ add_column :conferences, :registration_start_date, :date
+ add_column :conferences, :registration_end_date, :date
+ add_column :conferences, :registration_description, :text
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 99e48eb8..812ebbd1 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140801170430) do
+ActiveRecord::Schema.define(version: 20140812065531) do
create_table "ahoy_events", force: true do |t|
t.uuid "visit_id"
@@ -94,8 +94,6 @@ ActiveRecord::Schema.define(version: 20140801170430) do
t.integer "venue_id"
t.datetime "created_at"
t.datetime "updated_at"
- t.date "registration_start_date"
- t.date "registration_end_date"
t.string "logo_file_name"
t.string "logo_content_type"
t.integer "logo_file_size"
@@ -109,17 +107,16 @@ ActiveRecord::Schema.define(version: 20140801170430) do
t.boolean "use_volunteers"
t.string "color"
t.text "description"
- t.text "registration_description"
t.text "ticket_description"
t.text "sponsor_description"
t.string "sponsor_email"
t.text "lodging_description"
- t.boolean "make_conference_public", default: false
t.boolean "include_registrations_in_splash", default: false
t.boolean "include_sponsors_in_splash", default: false
t.boolean "include_tracks_in_splash", default: false
t.boolean "include_tickets_in_splash", default: false
t.boolean "include_program_in_splash", default: false
+ t.boolean "make_conference_public", default: false
t.string "banner_photo_file_name"
t.string "banner_photo_content_type"
t.integer "banner_photo_file_size"
@@ -213,12 +210,12 @@ ActiveRecord::Schema.define(version: 20140801170430) do
create_table "event_attachments", force: true do |t|
t.integer "event_id"
- t.string "title", null: false
+ t.string "title", null: false
t.string "attachment_file_name"
t.string "attachment_content_type"
t.integer "attachment_file_size"
t.datetime "attachment_updated_at"
- t.boolean "public", default: true
+ t.boolean "public", default: false
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -332,6 +329,15 @@ ActiveRecord::Schema.define(version: 20140801170430) do
t.datetime "updated_at"
end
+ create_table "registration_periods", force: true do |t|
+ t.integer "conference_id"
+ t.date "start_date"
+ t.date "end_date"
+ t.text "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "registrations", force: true do |t|
t.integer "conference_id"
t.boolean "attending_social_events", default: true
@@ -363,11 +369,11 @@ ActiveRecord::Schema.define(version: 20140801170430) do
create_table "roles", force: true do |t|
t.string "name"
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "description"
t.integer "resource_id"
t.string "resource_type"
- t.datetime "created_at"
- t.datetime "updated_at"
end
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
@@ -463,8 +469,8 @@ ActiveRecord::Schema.define(version: 20140801170430) do
end
create_table "users", force: true do |t|
- t.string "email", default: "", null: false
- t.string "encrypted_password", default: "", null: false
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
@@ -514,8 +520,8 @@ ActiveRecord::Schema.define(version: 20140801170430) do
create_table "venues", force: true do |t|
t.string "guid"
- t.text "name"
- t.text "address"
+ t.text "name", limit: 255
+ t.text "address", limit: 255
t.string "website"
t.text "description"
t.string "offline_map_url"
@@ -526,8 +532,8 @@ ActiveRecord::Schema.define(version: 20140801170430) do
t.string "photo_content_type"
t.integer "photo_file_size"
t.datetime "photo_updated_at"
- t.boolean "include_venue_in_splash", default: false
- t.boolean "include_lodgings_in_splash", default: false
+ t.boolean "include_venue_in_splash", default: false
+ t.boolean "include_lodgings_in_splash", default: false
end
create_table "versions", force: true do |t|
diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb
index f3e179ab..d6a93804 100644
--- a/spec/controllers/admin/conferences_controller_spec.rb
+++ b/spec/controllers/admin/conferences_controller_spec.rb
@@ -48,16 +48,6 @@ describe Admin::ConferenceController do
conference.reload
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
end
-
- it 'sends email notification on conference registration date update' do
- mailer = double
- allow(mailer).to receive(:deliver)
- conference.email_settings = create(:email_settings)
- patch :update, id: conference.short_title, conference:
- attributes_for(:conference, registration_start_date: Date.today + 2.days, registration_end_date: Date.today + 4.days)
- conference.reload
- allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
- end
end
context 'invalid attributes' do
@@ -141,13 +131,13 @@ describe Admin::ConferenceController do
describe 'GET #edit' do
it 'assigns the requested conference to conference' do
- get :show, id: conference.short_title
+ get :edit, id: conference.short_title
expect(assigns(:conference)).to eq conference
end
it 'renders the show template' do
- get :show, id: conference.short_title
- expect(response).to render_template :show
+ get :edit, id: conference.short_title
+ expect(response).to render_template :edit
end
end
diff --git a/spec/controllers/admin/registration_periods_controller_spec.rb b/spec/controllers/admin/registration_periods_controller_spec.rb
new file mode 100644
index 00000000..53d6be38
--- /dev/null
+++ b/spec/controllers/admin/registration_periods_controller_spec.rb
@@ -0,0 +1,165 @@
+require 'spec_helper'
+
+describe Admin::RegistrationPeriodsController do
+
+ # It is necessary to use bang version of let to build roles before user
+ let(:conference) { create(:conference) }
+ let!(:first_user) { create(:user) }
+ let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) }
+
+ let(:organizer) { create(:user, role_ids: organizer_role.id) }
+ let(:organizer2) { create(:user, email: 'organizer2@email.osem', role_ids: organizer_role.id) }
+ let(:participant) { create(:user) }
+
+ shared_examples 'access as administration or organizer' do
+
+ before do
+ conference.registration_period = create(:registration_period)
+ end
+
+ describe 'PATCH #update' do
+
+ context 'valid attributes' do
+
+ it 'locates the requested audience object' do
+ patch :update, conference_id: conference.short_title, conference: attributes_for(:registration_period)
+ expect(assigns(:registration_period)).to eq(conference.registration_period)
+ end
+
+ it 'changes audience attributes' do
+ patch :update, conference_id: conference.short_title, registration_period:
+ attributes_for(:registration_period,
+ description: 'Test')
+
+ conference.reload
+ expect(conference.registration_period.description).to eq('Test')
+ end
+
+ it 'redirects to the updated conference' do
+ patch :update, conference_id: conference.short_title, registration_period:
+ attributes_for(:registration_period)
+ conference.reload
+ expect(response).to redirect_to admin_conference_registration_period_path(
+ conference.short_title)
+ end
+
+ it 'sends email notification on conference registration date update' do
+ mailer = double
+ allow(mailer).to receive(:deliver)
+ conference.email_settings = create(:email_settings)
+ conference.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 2.days)
+
+ patch :update, conference_id: conference.short_title, registration_period:
+ attributes_for(:registration_period,
+ start_date: Date.today + 2.days,
+ end_date: Date.today + 4.days)
+ conference.reload
+ allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
+ end
+ end
+ end
+
+ describe 'POST #create' do
+ context 'with valid attributes' do
+ it 'saves the registration period to the database' do
+ expected = expect do
+ post :create,
+ conference_id: conference.short_title,
+ registration_period: attributes_for(:registration_period)
+ end
+ expected.to change { RegistrationPeriod.count }.by 1
+ end
+
+ it 'redirects to registration_periods#show' do
+ post :create,
+ conference_id: conference.short_title,
+ registration_period: attributes_for(:registration_period)
+
+ expect(response).to redirect_to admin_conference_registration_period_path(
+ assigns[:conference].short_title)
+ end
+ end
+
+ context 'with invalid attributes' do
+ it 'does not save the conference to the database' do
+ expected = expect do
+ post :create,
+ conference_id: conference.short_title,
+ registration_period: attributes_for(:registration_period,
+ start_date: nil,
+ end_date: nil)
+ end
+ expected.to_not change { Conference.count }
+ end
+
+ it 're-renders the new template' do
+ post :create,
+ conference_id: conference.short_title,
+ registration_period: attributes_for(:registration_period,
+ start_date: nil,
+ end_date: nil)
+ expect(response).to be_success
+ end
+ end
+ end
+
+ describe 'GET #edit' do
+ it 'assigns the requested conference to conference' do
+ get :edit, conference_id: conference.short_title
+ expect(assigns(:registration_period)).to eq conference.registration_period
+ end
+
+ it 'renders the show template' do
+ get :edit, conference_id: conference.short_title
+ expect(response).to render_template :edit
+ end
+ end
+
+ describe 'GET #show' do
+ it 'assigns the requested registration period to registration period' do
+ get :show, conference_id: conference.short_title
+ expect(assigns(:registration_period)).to eq conference.registration_period
+ end
+
+ it 'renders the show template' do
+ get :show, conference_id: conference.short_title
+ expect(response).to render_template :show
+ end
+ end
+
+ describe 'GET #new' do
+ it 'assigns a new conference to conference' do
+ get :new, conference_id: conference.short_title
+ expect(assigns(:registration_period)).to be_a_new(RegistrationPeriod)
+ end
+
+ it 'renders the :new template' do
+ get :new, conference_id: conference.short_title
+ expect(response).to render_template :new
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'it deletes the registration period' do
+ expect { delete :destroy, conference_id: conference.short_title }.to change(RegistrationPeriod, :count).by(-1)
+ end
+ it 'redirects to users#show' do
+ delete :destroy, conference_id: conference.short_title
+ expect(response).to redirect_to admin_conference_registration_period_path
+ end
+ end
+ end
+
+ describe 'organizer access' do
+
+ before(:each) do
+ sign_in(organizer)
+ end
+
+ it_behaves_like 'access as administration or organizer'
+
+ end
+end
+
diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb
index 2ebde9f5..97f7348e 100644
--- a/spec/factories/conferences.rb
+++ b/spec/factories/conferences.rb
@@ -7,8 +7,6 @@ FactoryGirl.define do
timezone 'Amsterdam'
start_date { Date.today }
end_date { 6.days.from_now }
- registration_start_date { 3.days.from_now }
- registration_end_date { 5.days.from_now }
make_conference_public true
venue
end
diff --git a/spec/factories/registration_periods.rb b/spec/factories/registration_periods.rb
new file mode 100644
index 00000000..afd2e9ad
--- /dev/null
+++ b/spec/factories/registration_periods.rb
@@ -0,0 +1,9 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :registration_period do
+ start_date { 3.days.from_now }
+ end_date { 5.days.from_now }
+ description 'Lorem ipsum dolorem ...'
+ end
+end
diff --git a/spec/features/registration_periods_spec.rb b/spec/features/registration_periods_spec.rb
new file mode 100644
index 00000000..c904a33f
--- /dev/null
+++ b/spec/features/registration_periods_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+feature RegistrationPeriod do
+
+ # It is necessary to use bang version of let to build roles before user
+ let!(:conference) { create(:conference) }
+ let!(:organizer_role) { create(:organizer_role, resource: conference) }
+ let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
+
+ shared_examples 'successfully' do
+ scenario 'create and update registration period', js: true do
+ sign_in organizer
+ visit admin_conference_registration_period_path(
+ conference_id: conference.short_title)
+
+ click_link 'New Registration Period'
+ fill_in 'registration_period_description', with: 'The description'
+
+ click_button 'Save Registration Period'
+ expect(flash).
+ to eq("A error prohibited the Registration Period from being saved: " \
+ "Start date can't be blank. End date can't be blank.")
+
+ page.
+ execute_script("$('#registration-period-start-datepicker').val('" +
+ "#{Date.today.strftime('%d/%m/%Y')}')")
+ page.
+ execute_script("$('#registration-period-end-datepicker').val('" +
+ "#{(Date.today + 7).strftime('%d/%m/%Y')}')")
+
+ click_button 'Save Registration Period'
+
+ expect(flash).to eq('Registration Period successfully updated.')
+ expect(current_path).to eq(admin_conference_registration_period_path(conference.short_title))
+
+ registration_period = RegistrationPeriod.where(conference_id: conference.id).first
+ registration_period.reload
+ expect(registration_period.start_date).to eq(Date.today)
+ expect(registration_period.end_date).to eq(Date.today + 7)
+ expect(registration_period.description).to eq('The description')
+ end
+ end
+
+ describe 'organizer' do
+ it_behaves_like 'successfully'
+ end
+end
diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb
index 4336ef80..9015ee61 100644
--- a/spec/models/conference_spec.rb
+++ b/spec/models/conference_spec.rb
@@ -964,8 +964,6 @@ describe Conference do
end
it 'calculates correct for new conference' do
- subject.registration_start_date = nil
- subject.registration_end_date = nil
subject.call_for_papers = nil
subject.venue = nil
subject.rooms = []
@@ -978,8 +976,9 @@ describe Conference do
end
it 'calculates correct for conference with registration' do
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.call_for_papers = nil
subject.rooms = []
subject.tracks = []
@@ -994,8 +993,9 @@ describe Conference do
end
it 'calculates correct for conference with registration, cfp' do
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.rooms = []
subject.tracks = []
@@ -1011,8 +1011,9 @@ describe Conference do
end
it 'calculates correct for conference with registration, cfp, venue' do
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
subject.rooms = []
@@ -1031,8 +1032,9 @@ describe Conference do
it 'calculates correct for conference with registration, cfp, venue, rooms' do
subject.rooms = [create(:room)]
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
subject.tracks = []
@@ -1052,8 +1054,9 @@ describe Conference do
it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do
subject.rooms = [create(:room)]
subject.tracks = [create(:track)]
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
subject.event_types = []
@@ -1075,8 +1078,9 @@ describe Conference do
subject.rooms = [create(:room)]
subject.tracks = [create(:track)]
subject.event_types = [create(:event_type)]
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
subject.difficulty_levels = []
@@ -1098,8 +1102,9 @@ describe Conference do
subject.tracks = [create(:track)]
subject.event_types = [create(:event_type)]
subject.difficulty_levels = [create(:difficulty_level)]
- subject.registration_start_date = Date.today
- subject.registration_end_date = Date.today + 14
+ subject.registration_period = create(:registration_period,
+ start_date: Date.today,
+ end_date: Date.today + 14)
subject.venue = create(:venue)
subject.call_for_papers = create(:call_for_papers)
subject.venue = create(:venue)
@@ -1112,26 +1117,30 @@ describe Conference do
describe '#registration_weeks' do
it 'calculates new year' do
- subject.registration_start_date = Date.new(2013, 12, 31)
- subject.registration_end_date = Date.new(2013, 12, 30) + 6
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2013, 12, 31),
+ end_date: Date.new(2013, 12, 30) + 6)
expect(subject.registration_weeks).to eq(1)
end
it 'is one if start and end are 6 days apart' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 6
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 6)
expect(subject.registration_weeks).to eq(1)
end
it 'is one if start and end date are the same' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26)
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26))
expect(subject.registration_weeks).to eq(1)
end
it 'is two if start and end are 10 days apart' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 10
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 10)
expect(subject.registration_weeks).to eq(2)
end
end
@@ -1263,15 +1272,17 @@ describe Conference do
describe '#get_registrations_per_week' do
it 'pads with zeros if there are no registrations' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 21
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 21)
expect(subject.get_registrations_per_week).to eq([0, 0, 0, 0])
end
it 'summarized correct if there are no registrations in one week' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 28
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 28)
create(:registration, conference: subject,
created_at: Date.new(2014, 05, 26) + 7)
@@ -1284,8 +1295,9 @@ describe Conference do
end
it 'returns [1] if there is one registration on the first day' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 7
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 7)
create(:registration, conference: subject,
created_at: Date.new(2014, 05, 26))
@@ -1293,8 +1305,9 @@ describe Conference do
end
it 'summarized correct if there are registrations every week' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 21
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 21)
create(:registration, conference: subject, created_at: Date.new(2014, 05, 26))
create(:registration, conference: subject,
@@ -1306,8 +1319,9 @@ describe Conference do
end
it 'summarized correct if there are registrations every week except the first' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 28
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 28)
create(:registration, conference: subject,
created_at: Date.new(2014, 05, 26) + 7)
@@ -1320,8 +1334,9 @@ describe Conference do
end
it 'pads left' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 35
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 35)
create(:registration, conference: subject,
created_at: Date.new(2014, 05, 26) + 21)
@@ -1334,8 +1349,9 @@ describe Conference do
end
it 'pads middle' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 35
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 35)
create(:registration, conference: subject,
created_at: Date.new(2014, 05, 26))
@@ -1346,8 +1362,9 @@ describe Conference do
end
it 'pads right' do
- subject.registration_start_date = Date.new(2014, 05, 26)
- subject.registration_end_date = Date.new(2014, 05, 26) + 35
+ subject.registration_period = create(:registration_period,
+ start_date: Date.new(2014, 05, 26),
+ end_date: Date.new(2014, 05, 26) + 35)
create(:registration, conference: subject,
created_at: Date.new(2014, 05, 26))
@@ -1389,8 +1406,10 @@ describe Conference do
context 'open registration' do
before do
- subject.registration_start_date = Date.today - 1
- subject.registration_end_date = Date.today + 7
+ enrollment = create(:registration_period,
+ start_date: Date.today - 1,
+ end_date: Date.today + 7)
+ subject.registration_period = enrollment
end
it '#registration_open? is true' do
diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb
index cdc1db3a..ec41e7a9 100644
--- a/spec/views/conference/show.html.haml_spec.rb
+++ b/spec/views/conference/show.html.haml_spec.rb
@@ -2,24 +2,26 @@ require 'spec_helper'
describe 'conference/show.html.haml' do
before(:each) do
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
- @conference = create(:conference, registration_description: 'Lorem Ipsum Dolor',
- registration_start_date: Date.today,
- registration_end_date: Date.tomorrow,
- description: 'Lorem Ipsum',
- sponsor_description: 'Lorem Ipsum Dolor',
- sponsor_email: 'example@example.com',
- include_registrations_in_splash: true,
- include_program_in_splash: true,
- include_sponsors_in_splash: true,
- include_tracks_in_splash: true,
- include_tickets_in_splash: true,
- include_banner_in_splash: true)
+ @conference = create(:conference,
+ description: 'Lorem Ipsum',
+ sponsor_description: 'Lorem Ipsum Dolor',
+ sponsor_email: 'example@example.com',
+ include_registrations_in_splash: true,
+ include_program_in_splash: true,
+ include_sponsors_in_splash: true,
+ include_tracks_in_splash: true,
+ include_tickets_in_splash: true,
+ include_banner_in_splash: true)
@conference.contact.update(facebook: 'http://www.fbexample.com',
googleplus: 'http://www.google-example.com',
instagram: 'http://instagram.com',
twitter: 'http://twitter.com',
public: true
)
+ @conference.registration_period = create(:registration_period,
+ description: 'Lorem Ipsum Dolor',
+ start_date: Date.today,
+ end_date: Date.tomorrow)
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
include_cfp_in_splash: true)
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
@@ -45,7 +47,7 @@ describe 'conference/show.html.haml' do
end
it 'renders registration partial' do
- expect(view.content_for(:splash)).to include("#{@conference.registration_description}")
+ expect(view.content_for(:splash)).to include("#{@conference.registration_period.description}")
expect(view).to render_template(partial: 'conference/_registration')
end