Skip to content

Commit

Permalink
Merge 98349fc into 36045c5
Browse files Browse the repository at this point in the history
  • Loading branch information
feliciaan committed Jan 29, 2017
2 parents 36045c5 + 98349fc commit 00e9475
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 11 deletions.
8 changes: 6 additions & 2 deletions app/controllers/events_controller.rb
Expand Up @@ -151,10 +151,14 @@ def check_in
end

def event_params
params.require(:event).permit(:name, :club_id, :location, :website, :contact_email, :start_date, :end_date, :description, :registration_cancelable, :phone_number_state, :bank_number, :registration_close_date, :registration_open_date, :show_ticket_count, :signature)
params.require(:event).permit(:name, :club_id, :location, :website, :contact_email, :start_date, :end_date,
:description, :registration_cancelable, :extra_info, :phone_number_state,
:bank_number, :registration_close_date, :registration_open_date, :show_ticket_count,
:signature)
end

def event_create_params
params.require(:event).permit(:name, :club_id, :location, :website, :contact_email, :start_date, :end_date, :description, :registration_cancelable, :phone_number_state)
params.require(:event).permit(:name, :club_id, :location, :website, :contact_email, :start_date, :end_date,
:description, :registration_cancelable, :extra_info, :phone_number_state)
end
end
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Expand Up @@ -71,7 +71,7 @@ def basic
authorize! :register, requested_access_level

# Make the registration
@registration = @event.registrations.new params.require(:registration).permit(:email, :name, :student_number, :comment, :phone_number)
@registration = @event.registrations.new params.require(:registration).permit(:title, :email, :job_function, :name, :student_number, :comment, :phone_number)
@registration.access_levels << requested_access_level
@registration.price = requested_access_level.price
@registration.paid = 0
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -54,8 +54,9 @@ def form_number_field(f, tag)
render partial: "form_number_field", locals: {f: f, tag: tag}
end

def form_radio_field(f, tag, selected_state, states)
render partial: "form_radio_field", locals: {f: f, tag: tag, selected_state: selected_state, states: states}
def form_radio_field(f, tag, selected_state, states, show_label=true, do_translate=false, scope='')
render partial: "form_radio_field", locals: {f: f, tag: tag, selected_state: selected_state, states: states,
show_label: show_label, do_translate: do_translate, scope: scope }
end

def form_collection_select(f, *args)
Expand Down
1 change: 1 addition & 0 deletions app/models/event.rb
Expand Up @@ -27,6 +27,7 @@
# signature :text
# registration_cancelable :boolean
# phone_number_state :string default("optional")
# extra_info :boolean default(FALSE)
#

class Event < ActiveRecord::Base
Expand Down
24 changes: 24 additions & 0 deletions app/models/registration.rb
Expand Up @@ -17,6 +17,8 @@
# barcode_data :string
# payment_code :string
# phone_number :string
# title :string
# job_function :string
#

class Registration < ActiveRecord::Base
Expand All @@ -40,6 +42,8 @@ class Registration < ActiveRecord::Base
validates :payment_code, presence: true, uniqueness: true
validates :phone_number, presence: true, if: 'phone_number_required?'
validates :comment, presence: true, if: 'comment_required?'
validates :title, presence: true, if: 'extra_info_required?'
validates :job_function, presence: true, if: 'extra_info_required?'

has_paper_trail only: [:paid, :payment_code, :checked_in_at]

Expand Down Expand Up @@ -121,6 +125,22 @@ def deliver
end
end

def self.personal_titles
[:prof, :dr, :ms, :mr, :mx]
end

def self.personal_titles_scope
'registration.titles'
end

def salutation
unless title
return ''
end

I18n.t(title, scope: Registration.personal_titles_scope) + ' '
end

private

def from_cents(value)
Expand All @@ -147,4 +167,8 @@ def comment_required?
end
false
end

def extra_info_required?
event && event.extra_info
end
end
6 changes: 4 additions & 2 deletions app/views/application/_form_radio_field.html.erb
@@ -1,7 +1,9 @@
<div class="form-group btn-group" data-toggle="buttons">
<p><strong><%= tag.to_s.humanize %>:</strong></p>
<% if show_label %>
<p><strong><%= t(tag) %>:</strong></p>
<% end %>
<% states.each do |state, _| %>
<label class="btn btn-primary<%= ' active ' if state.to_s == selected_state %>"> <%= f.radio_button(tag, state) %><%= state.capitalize %></label>
<label class="btn btn-primary<%= ' active ' if state.to_s == selected_state %>"> <%= f.radio_button(tag, state) %><%= do_translate ? t(state.to_s, scope: scope) : state.capitalize %></label>
<% end %>
</div>
1 change: 1 addition & 0 deletions app/views/events/_general_form.html.erb
Expand Up @@ -9,6 +9,7 @@
<%= form_date_field f, :start_date, "start", datepicker_time(f.object.start_date) %>
<%= form_date_field f, :end_date, "end", datepicker_time(f.object.end_date) %>
<%= form_check_box f, :registration_cancelable %>
<%= form_check_box f, :extra_info %>
<%= form_radio_field f, :phone_number_state, @event.phone_number_state, Event.phone_number_states %>
<%= form_fancy_text_area f, :description %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/registration_mailer/ticket.html.erb
Expand Up @@ -68,7 +68,7 @@
<tbody>
<tr>
<td class="pr-15" style="padding: 0 30px 24px 0; font: 13px/18px Arial, Helvetica, sans-serif; color: #202020;">
<%= raw t('mail.ticket_start', :name => @registration.name, :mail=>@registration.event.contact_email)%>
<%= raw t('mail.ticket_start', :salutation => @registration.salutation, :name => @registration.name, :mail=>@registration.event.contact_email)%>
</td>
</tr>
<tr>
Expand Down
6 changes: 6 additions & 0 deletions app/views/registrations/_basic.html.erb
Expand Up @@ -4,7 +4,13 @@
<%= render partial: 'flash' %>
<%= form_for [@event, @registration], url: basic_event_registrations_path(@event) do |f| %>
<% if @registration.event.extra_info %>
<%= form_radio_field f, :title, @registration.title, Registration.personal_titles, false, true, Registration.personal_titles_scope %>
<% end %>
<%= form_text_field f, :name %>
<% if @registration.event.extra_info %>
<%= form_text_field f, :job_function %>
<% end %>
<%= form_email_field f, :email %>
<%= f.hidden_field :student_number %>
<% if @registration.event.ask_phone_number? %>
Expand Down
11 changes: 10 additions & 1 deletion config/locales/nl.yml
Expand Up @@ -2,6 +2,8 @@ nl:
activerecord:
attributes:
registration:
title: 'Titel'
job_function: 'Functie'
access_levels: "Ticket"
name: "Naam"
email: "E-mail"
Expand All @@ -25,6 +27,13 @@ nl:
deleted:
title: 'Ticket verwijderd'
click_here_website: 'Klik hier om naar de event website te gaan.'
registration:
titles:
prof: 'prof.'
dr: 'dr.'
ms: 'mevr.'
mr: 'dhr.'
mx: 'mx.'
forms:
field:
telephone:
Expand All @@ -36,7 +45,7 @@ nl:
login_cas: 'met CAS om de tickets te kunnen bestellen.'
no_available: 'No tickets available at the moment!'
mail:
ticket_start: "Beste %{name}<br/><br/>
ticket_start: "Beste %{salutation}%{name}<br/><br/>
Bedankt om uw aanwezigheid te bevestigen. Deze e-mail geldt als uw persoonlijk ticket voor dit event. Vergeet niet om deze e-mail af te drukken en dit ticket mee te nemen.<br/>
<br/>
Indien u door omstandigheden niet kan komen, vragen we u vriendelijk dit te laten weten via de onderstaande uitschrijflink. Bij vragen of problemen kan u terecht op %{mail}."
Expand Down
@@ -0,0 +1,7 @@
class AddExtraInformationToEventsAndRegistration < ActiveRecord::Migration
def change
add_column :events, :extra_info, :boolean, default: false
add_column :registrations, :title, :string
add_column :registrations, :job_function, :string
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170111204432) do
ActiveRecord::Schema.define(version: 20170128205146) do

create_table "access_levels", force: :cascade do |t|
t.string "name"
Expand Down Expand Up @@ -106,6 +106,7 @@
t.text "signature"
t.boolean "registration_cancelable"
t.string "phone_number_state", default: "optional"
t.boolean "extra_info", default: false
end

create_table "included_zones", force: :cascade do |t|
Expand Down Expand Up @@ -179,6 +180,8 @@
t.string "barcode_data"
t.string "payment_code"
t.string "phone_number"
t.string "title"
t.string "job_function"
end

add_index "registrations", ["event_id"], name: "index_registrations_on_event_id"
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/registrations_controller_test.rb
Expand Up @@ -164,7 +164,7 @@ def setup
assert_match(/Ticket voor/, email.subject)

email = ActionMailer::Base.deliveries[-1]
assert_match(/Overpayment for/, email.subject)
assert_match(/Teveel betaald voor/, email.subject)
end

end
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/events.yml
Expand Up @@ -27,6 +27,7 @@
# signature :text
# registration_cancelable :boolean
# phone_number_state :string default("optional")
# extra_info :boolean default(FALSE)
#

# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/registrations.yml
Expand Up @@ -17,6 +17,8 @@
# barcode_data :string
# payment_code :string
# phone_number :string
# title :string
# job_function :string
#

# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
Expand Down
1 change: 1 addition & 0 deletions test/models/event_test.rb
Expand Up @@ -27,6 +27,7 @@
# signature :text
# registration_cancelable :boolean
# phone_number_state :string default("optional")
# extra_info :boolean default(FALSE)
#

require 'test_helper'
Expand Down
2 changes: 2 additions & 0 deletions test/models/registration_test.rb
Expand Up @@ -17,6 +17,8 @@
# barcode_data :string
# payment_code :string
# phone_number :string
# title :string
# job_function :string
#

require 'test_helper'
Expand Down

0 comments on commit 00e9475

Please sign in to comment.