From b4b18cd569284ecd4a3e3b3bd550af628a21374a Mon Sep 17 00:00:00 2001
From: Feliciaan De Palmenaer
Date: Sun, 29 Jan 2017 13:32:29 +0100
Subject: [PATCH 1/5] Add locale
---
app/controllers/application_controller.rb | 9 +++++++++
app/views/layouts/_login.html.erb | 6 ++++++
app/views/registrations/_basic.html.erb | 2 +-
config/locales/en.yml | 1 +
config/locales/nl.yml | 1 +
5 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e0b73800..112693a6 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -5,6 +5,15 @@ class ApplicationController < ActionController::Base
after_filter :store_location
+ before_action :set_locale
+
+ def set_locale
+ I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
+ if params[:locale]
+ session[:locale] = params[:locale]
+ end
+ end
+
def store_location
# store last url as long as it isn't a /users path
session[:previous_url] = request.fullpath unless request.fullpath =~ /\/users/
diff --git a/app/views/layouts/_login.html.erb b/app/views/layouts/_login.html.erb
index f6076958..eb719d1f 100644
--- a/app/views/layouts/_login.html.erb
+++ b/app/views/layouts/_login.html.erb
@@ -1,4 +1,10 @@
+ <% if I18n.locale == :en %>
+ - <%= t('dutch') %>
+ <% end %>
+ <% if I18n.locale == :nl %>
+ - <%= t('english') %>
+ <% end %>
<% if user_signed_in? %>
- Logged in as <%= current_user.display_name %>
- <%= link_to destroy_user_session_path(current_user), method: :delete do %>Logout<% end %>
diff --git a/app/views/registrations/_basic.html.erb b/app/views/registrations/_basic.html.erb
index 4726ad5a..e1a1684b 100644
--- a/app/views/registrations/_basic.html.erb
+++ b/app/views/registrations/_basic.html.erb
@@ -15,7 +15,7 @@
<%= javascript_tag do %>
window.ticketsWithComments = <%= @event.access_levels.find_all(&:has_comment).map(&:id).to_json %>
<% end %>
- <%= f.submit t('event.register'), class: 'btn btn-group btn-primary' %>
+ <%= f.submit t('event.register', default: 'Register'), class: 'btn btn-group btn-primary' %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1f43ef3e..fde838a1 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -19,6 +19,7 @@
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
+ dutch: 'Nederlands'
activerecord:
attributes:
registration:
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 0e316431..5f4a082f 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -1,4 +1,5 @@
nl:
+ english: 'English'
activerecord:
attributes:
registration:
From 63e57ff0a49dd58475f042af2d9a11d0f8f087c3 Mon Sep 17 00:00:00 2001
From: Feliciaan De Palmenaer
Date: Sun, 29 Jan 2017 13:53:42 +0100
Subject: [PATCH 2/5] Installed i18n tasks
---
Gemfile | 3 ++
Gemfile.lock | 23 ++++++++++
config/locales/en.yml | 85 +++++++++++++++++++++++--------------
config/locales/nl.yml | 97 +++++++++++++++++++++----------------------
4 files changed, 128 insertions(+), 80 deletions(-)
diff --git a/Gemfile b/Gemfile
index 83f7e128..30100d09 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,9 @@ gem 'rails', '~> 4.0'
# I18N
gem 'rails-i18n', '~> 4.0'
+# I18n tasks, simplify the process, find missing keys
+gem 'i18n-tasks', '~> 0.9.9'
+
# We <3 New Relic
gem 'newrelic_rpm'
diff --git a/Gemfile.lock b/Gemfile.lock
index caf25991..0317f449 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -55,6 +55,7 @@ GEM
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
arel (6.0.4)
+ ast (2.3.0)
bcrypt (3.1.11)
builder (3.2.2)
byebug (9.0.6)
@@ -128,6 +129,10 @@ GEM
devise (>= 1.2.0)
rubycas-client (>= 2.2.1)
docile (1.1.5)
+ easy_translate (0.5.0)
+ json
+ thread
+ thread_safe
erubis (2.7.0)
execjs (2.7.0)
faraday (0.10.1)
@@ -136,10 +141,21 @@ GEM
activesupport (>= 4.1.0)
hashdiff (0.3.2)
hashie (3.4.6)
+ highline (1.7.8)
hike (1.2.3)
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.7.0)
+ i18n-tasks (0.9.9)
+ activesupport (>= 4.0.2)
+ ast (>= 2.1.0)
+ easy_translate (>= 0.5.0)
+ erubis
+ highline (>= 1.7.3)
+ i18n
+ parser (>= 2.2.3.0)
+ term-ansicolor (>= 1.3.2)
+ terminal-table (>= 1.5.1)
iban-tools (1.1.0)
jbuilder (1.5.3)
activesupport (>= 3.0.0)
@@ -197,6 +213,8 @@ GEM
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
+ parser (2.3.3.1)
+ ast (~> 2.2)
pdf-core (0.6.1)
poltergeist (1.12.0)
capybara (~> 2.1)
@@ -305,10 +323,13 @@ GEM
net-ssh (>= 2.8.0)
term-ansicolor (1.4.0)
tins (~> 1.0)
+ terminal-table (1.7.3)
+ unicode-display_width (~> 1.1.1)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.19.4)
+ thread (0.2.2)
thread_safe (0.3.5)
tilt (1.4.1)
timeliness (0.3.8)
@@ -325,6 +346,7 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
+ unicode-display_width (1.1.3)
warden (1.2.6)
rack (>= 1.0)
webmock (2.3.2)
@@ -366,6 +388,7 @@ DEPENDENCIES
devise
devise_cas_authenticatable
httparty
+ i18n-tasks (~> 0.9.9)
iban-tools
jbuilder (~> 1.2)
jc-validates_timeliness
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fde838a1..9624190d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,39 +1,62 @@
-# Files in the config/locales directory are used for internationalization
-# and are automatically loaded by Rails. If you want to use locales other
-# than English, add the necessary files in this directory.
-#
-# To use the locales, use `I18n.t`:
-#
-# I18n.t 'hello'
-#
-# In views, this is aliased to just `t`:
-#
-# <%= t('hello') %>
-#
-# To use a different locale, set it with `I18n.locale`:
-#
-# I18n.locale = :es
-#
-# This would use the information in config/locales/es.yml.
-#
-# To learn more, please read the Rails Internationalization guide
-# available at http://guides.rubyonrails.org/i18n.html.
+---
en:
- dutch: 'Nederlands'
activerecord:
attributes:
registration:
- access_levels: "Ticket"
- tickets:
- left: 'over'
- login_required: "Some tickets of this event can only be registered for if you are a member of the organiser's organisation."
- login: 'Login'
- login_cas: 'using CAS to register for these tickets.'
- no_available: 'No tickets available at the moment!'
+ access_levels: Ticket
+ comment: Afstudeerjaar en -richting
+ email: E-mail
+ name: Naam
+ phone_number: Telefoonnummer
+ register: Registreer
+ datagrid:
+ table:
+ order:
+ asc: "↑"
+ desc: "↓"
+ dutch: Nederlands
+ english: English
+ event:
+ barcode_number: Barcode nummer
+ cancel:
+ button: Schrijf mij nu uit!
+ closed: Sorry, uitschrijven is niet meer mogelijk.
+ deleted:
+ click_here_website: Klik hier om naar de event website te gaan.
+ title: Ticket verwijderd
+ title: Schrijf u uit voor %{event}
+ contact_mail: Contact e-mail
+ description: Beschrijving
+ end_date: Einddatum
+ location: Locatie
+ organisation: Organisatie
+ register: Registreer
+ start_date: Startdatum
+ website: Website
flash:
- succes: "Registration successful. Please check your mailbox for your ticket."
-
+ succes: Registration successful. Please check your mailbox for your ticket.
+ forms:
+ field:
+ telephone:
+ privacy_declaration: Uw telefoonnummer wordt vertrouwelijk gehouden, en zal enkel gebruikt worden om uw persoonlijke eindscore te sms'en.
helpers:
label:
event:
- club_id: "Organisation"
+ club_id: Organisation
+ mail:
+ cancel: Klik hier om u uit te schrijven.
+ more_info: Meer info
+ ticket_start: Beste %{name}
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.
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}.
+ mailers:
+ registration:
+ subjects:
+ cancel: Uitschrijven voor %{event}
+ confirm: Registratie voor %{event}
+ overpayment: Teveel betaald voor %{event}
+ ticket: Ticket voor %{event}
+ tickets:
+ left: over
+ login: Login
+ login_cas: using CAS to register for these tickets.
+ login_required: Some tickets of this event can only be registered for if you are a member of the organiser's organisation.
+ no_available: No tickets available at the moment!
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 5f4a082f..4a4cc4f0 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -1,63 +1,62 @@
+---
nl:
- english: 'English'
activerecord:
attributes:
registration:
- access_levels: "Ticket"
- name: "Naam"
- email: "E-mail"
- phone_number: "Telefoonnummer"
- register: 'Registreer'
- comment: 'Afstudeerjaar en -richting'
+ access_levels: Ticket
+ comment: Afstudeerjaar en -richting
+ email: E-mail
+ name: Naam
+ phone_number: Telefoonnummer
+ register: Registreer
+ datagrid:
+ table:
+ order:
+ asc: "↑"
+ desc: "↓"
+ dutch: Nederlands
+ english: English
event:
- description: 'Beschrijving'
- organisation: 'Organisatie'
- location: 'Locatie'
- start_date: 'Startdatum'
- end_date: 'Einddatum'
- website: 'Website'
- contact_mail: 'Contact e-mail'
- register: 'Registreer'
- barcode_number: 'Barcode nummer'
+ barcode_number: Barcode nummer
cancel:
- title: 'Schrijf u uit voor %{event}'
- button: 'Schrijf mij nu uit!'
- closed: 'Sorry, uitschrijven is niet meer mogelijk.'
+ button: Schrijf mij nu uit!
+ closed: Sorry, uitschrijven is niet meer mogelijk.
deleted:
- title: 'Ticket verwijderd'
- click_here_website: 'Klik hier om naar de event website te gaan.'
+ click_here_website: Klik hier om naar de event website te gaan.
+ title: Ticket verwijderd
+ title: Schrijf u uit voor %{event}
+ contact_mail: Contact e-mail
+ description: Beschrijving
+ end_date: Einddatum
+ location: Locatie
+ organisation: Organisatie
+ register: Registreer
+ start_date: Startdatum
+ website: Website
+ flash:
+ succes: Registratie succesvol. Uw ticket zou nu in uw mailbox toegekomen moeten zijn.
forms:
field:
telephone:
- privacy_declaration: "Uw telefoonnummer wordt vertrouwelijk gehouden, en zal enkel gebruikt worden om uw persoonlijke eindscore te sms'en."
- tickets:
- left: 'over'
- login_required: 'Studenten en personeel moeten zich eerst inloggen.'
- login: 'Log in'
- login_cas: 'met CAS om de tickets te kunnen bestellen.'
- no_available: 'No tickets available at the moment!'
+ privacy_declaration: Uw telefoonnummer wordt vertrouwelijk gehouden, en zal enkel gebruikt worden om uw persoonlijke eindscore te sms'en.
+ helpers:
+ label:
+ event:
+ club_id: Organisatie
mail:
- ticket_start: "Beste %{name}
- 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.
-
- 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}."
- more_info: "Meer info"
- cancel: "Klik hier om u uit te schrijven."
- flash:
- succes: "Registratie succesvol. Uw ticket zou nu in uw mailbox toegekomen moeten zijn."
+ cancel: Klik hier om u uit te schrijven.
+ more_info: Meer info
+ ticket_start: Beste %{name}
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.
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}.
mailers:
registration:
subjects:
- confirm: "Registratie voor %{event}"
- ticket: "Ticket voor %{event}"
- overpayment: "Teveel betaald voor %{event}"
- cancel: "Uitschrijven voor %{event}"
- helpers:
- label:
- event:
- club_id: "Organisatie"
- datagrid:
- table:
- order:
- asc: '↑'
- desc: '↓'
+ cancel: Uitschrijven voor %{event}
+ confirm: Registratie voor %{event}
+ overpayment: Teveel betaald voor %{event}
+ ticket: Ticket voor %{event}
+ tickets:
+ left: over
+ login: Log in
+ login_cas: met CAS om de tickets te kunnen bestellen.
+ login_required: Studenten en personeel moeten zich eerst inloggen.
+ no_available: No tickets available at the moment!
From ad06d1e2f02a78e191144e97b2a8e74f2d16285a Mon Sep 17 00:00:00 2001
From: Feliciaan De Palmenaer
Date: Sun, 29 Jan 2017 13:54:55 +0100
Subject: [PATCH 3/5] Forgot to add config file
---
config/i18n-tasks.yml | 121 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 121 insertions(+)
create mode 100644 config/i18n-tasks.yml
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml
new file mode 100644
index 00000000..00c83239
--- /dev/null
+++ b/config/i18n-tasks.yml
@@ -0,0 +1,121 @@
+# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
+
+# The "main" locale.
+base_locale: nl
+## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
+locales: [nl, en]
+## Reporting locale, default: en. Available: en, ru.
+# internal_locale: en
+
+# Read and write translations.
+data:
+ ## Translations are read from the file system. Supported format: YAML, JSON.
+ ## Provide a custom adapter:
+ # adapter: I18n::Tasks::Data::FileSystem
+
+ # Locale files or `File.find` patterns where translations are read from:
+ read:
+ ## Default:
+ - config/locales/%{locale}.yml
+ ## More files:
+ # - config/locales/**/*.%{locale}.yml
+ ## Another gem (replace %#= with %=):
+ # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
+
+ # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
+ # `i18n-tasks normalize -p` will force move the keys according to these rules
+ write:
+ ## For example, write devise and simple form keys to their respective files:
+ # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
+ ## Catch-all default:
+ # - config/locales/%{locale}.yml
+
+ ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
+ # router: convervative_router
+
+ yaml:
+ write:
+ # do not wrap lines at 80 characters
+ line_width: -1
+
+ ## Pretty-print JSON:
+ # json:
+ # write:
+ # indent: ' '
+ # space: ' '
+ # object_nl: "\n"
+ # array_nl: "\n"
+
+# Find translate calls
+search:
+ ## Paths or `File.find` patterns to search in:
+ # paths:
+ # - app/
+
+ ## Root directories for relative keys resolution.
+ # relative_roots:
+ # - app/controllers
+ # - app/helpers
+ # - app/mailers
+ # - app/presenters
+ # - app/views
+
+ ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
+ ## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
+ exclude:
+ - app/assets/images
+ - app/assets/fonts
+ - app/assets/videos
+
+ ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
+ ## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
+ # only: ["*.rb", "*.html.slim"]
+
+ ## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
+ # strict: true
+
+ ## Multiple scanners can be used. Their results are merged.
+ ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
+ ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
+
+## Google Translate
+# translation:
+# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
+# api_key: "AbC-dEf5"
+
+## Do not consider these keys missing:
+# ignore_missing:
+# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
+# - '{devise,simple_form}.*'
+
+## Consider these keys used:
+# ignore_unused:
+# - 'activerecord.attributes.*'
+# - '{devise,kaminari,will_paginate}.*'
+# - 'simple_form.{yes,no}'
+# - 'simple_form.{placeholders,hints,labels}.*'
+# - 'simple_form.{error_notification,required}.:'
+
+## Exclude these keys from the `i18n-tasks eq-base' report:
+# ignore_eq_base:
+# all:
+# - common.ok
+# fr,es:
+# - common.brand
+
+## Ignore these keys completely:
+# ignore:
+# - kaminari.*
+
+## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
+## e.g. in case of a relative key defined in a helper method.
+## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
+#
+# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
+# only: %w(*.html.haml *.html.slim),
+# patterns: [['= title\b', '.page_title']] %>
+#
+# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
+#
+# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
+# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
From 6872b1818970b75b010d020ba11e66671281da8b Mon Sep 17 00:00:00 2001
From: Feliciaan De Palmenaer
Date: Sun, 29 Jan 2017 14:51:43 +0100
Subject: [PATCH 4/5] Fix hacks with less dirty hacks...
---
app/helpers/application_helper.rb | 8 ++++----
app/models/event.rb | 14 ++++++++++++++
.../application/_form_telephone_field.html.erb | 5 ++++-
app/views/application/_form_text_area.html.erb | 2 +-
app/views/registrations/_basic.html.erb | 4 ++--
config/locales/nl.yml | 2 +-
6 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 83f27abd..0d3df0a1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -30,8 +30,8 @@ def form_url_field(f, tag)
render partial: "form_url_field", locals: {f: f, tag: tag}
end
- def form_text_area(f, tag)
- render partial: "form_text_area", locals: {f: f, tag: tag}
+ def form_text_area(f, tag, label_text=nil)
+ render partial: "form_text_area", locals: {f: f, tag: tag, label_text: label_text}
end
def form_fancy_text_area(f, tag)
@@ -42,8 +42,8 @@ def form_email_field(f, tag)
render partial: "form_email_field", locals: {f: f, tag: tag}
end
- def form_telephone_field(f, tag)
- render partial: "form_telephone_field", locals: {f: f, tag: tag}
+ def form_telephone_field(f, tag, show_disclaimer)
+ render partial: "form_telephone_field", locals: {f: f, tag: tag, show_disclaimer: show_disclaimer}
end
def form_date_field(f, tag, id, value)
diff --git a/app/models/event.rb b/app/models/event.rb
index d3ca97cc..06169c7d 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -77,6 +77,20 @@ def prettify_bank_number
self.bank_number = IBANTools::IBAN.new(self.bank_number).prettify if bank_number_changed?
end
+ def comment_title
+ if id == 1
+ return 'Afstudeerjaar en -richting' #TODO: maybe add to database if this used in more cases
+ end
+ nil
+ end
+
+ def show_telephone_disclaimer
+ if id == 1
+ return true
+ end
+ false
+ end
+
def generate_xls
self.export_status = 'generating'
self.save
diff --git a/app/views/application/_form_telephone_field.html.erb b/app/views/application/_form_telephone_field.html.erb
index 98728ee0..da07b354 100644
--- a/app/views/application/_form_telephone_field.html.erb
+++ b/app/views/application/_form_telephone_field.html.erb
@@ -1,5 +1,8 @@
<%= f.label tag %>:
<%= f.telephone_field tag, class: 'form-control' %>
- <%= t('forms.field.telephone.privacy_declaration') %>
+
+ <% if show_disclaimer %>
+ <%= t('forms.field.telephone.privacy_declaration') %>
+ <% end %>
diff --git a/app/views/application/_form_text_area.html.erb b/app/views/application/_form_text_area.html.erb
index 256bfb76..3183d138 100644
--- a/app/views/application/_form_text_area.html.erb
+++ b/app/views/application/_form_text_area.html.erb
@@ -1,4 +1,4 @@
- <%= f.label tag %>:
+ <%= f.label tag, label_text %>:
<%= f.text_area tag, class: 'form-control' %>
diff --git a/app/views/registrations/_basic.html.erb b/app/views/registrations/_basic.html.erb
index e1a1684b..adec6f8a 100644
--- a/app/views/registrations/_basic.html.erb
+++ b/app/views/registrations/_basic.html.erb
@@ -8,10 +8,10 @@
<%= form_email_field f, :email %>
<%= f.hidden_field :student_number %>
<% if @registration.event.ask_phone_number? %>
- <%= form_telephone_field f, :phone_number %>
+ <%= form_telephone_field f, :phone_number, @event.show_telephone_disclaimer %>
<% end %>
<%= form_collection_select f, :access_levels, @event.access_levels.find_all { |al| can? :register, al }, :id, :name_with_price %>
- <%= form_text_area f, :comment %>
+ <%= form_text_area f, :comment, @event.comment_title %>
<%= javascript_tag do %>
window.ticketsWithComments = <%= @event.access_levels.find_all(&:has_comment).map(&:id).to_json %>
<% end %>
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 4a4cc4f0..6e8f99a9 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -4,7 +4,7 @@ nl:
attributes:
registration:
access_levels: Ticket
- comment: Afstudeerjaar en -richting
+ comment: Opmerkingen
email: E-mail
name: Naam
phone_number: Telefoonnummer
From 16da59abc2554c6439be2a6e0ee4f52e0bb5f3ad Mon Sep 17 00:00:00 2001
From: Feliciaan De Palmenaer
Date: Sun, 29 Jan 2017 14:59:29 +0100
Subject: [PATCH 5/5] Add comment_title and show telephone disclaimer as fields
---
app/models/event.rb | 67 ++++++++-----------
app/models/registration.rb | 2 +
...and_show_telephone_disclaimer_to_events.rb | 6 ++
db/schema.rb | 13 ++--
test/fixtures/events.yml | 53 ++++++++-------
test/fixtures/registrations.yml | 2 +
test/models/event_test.rb | 53 ++++++++-------
test/models/registration_test.rb | 2 +
8 files changed, 105 insertions(+), 93 deletions(-)
create mode 100644 db/migrate/20170129135614_add_comment_title_and_show_telephone_disclaimer_to_events.rb
diff --git a/app/models/event.rb b/app/models/event.rb
index 06169c7d..8cf29406 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -2,31 +2,34 @@
#
# Table name: events
#
-# id :integer not null, primary key
-# name :string
-# start_date :datetime
-# end_date :datetime
-# location :string
-# website :string
-# description :text
-# created_at :datetime
-# updated_at :datetime
-# registration_open_date :datetime
-# registration_close_date :datetime
-# bank_number :string
-# show_ticket_count :boolean default(TRUE)
-# contact_email :string
-# export_file_name :string
-# export_content_type :string
-# export_file_size :integer
-# export_updated_at :datetime
-# show_statistics :boolean
-# export_status :string
-# club_id :integer
-# registration_open :boolean default(TRUE)
-# signature :text
-# registration_cancelable :boolean
-# phone_number_state :string default("optional")
+# id :integer not null, primary key
+# name :string
+# start_date :datetime
+# end_date :datetime
+# location :string
+# website :string
+# description :text
+# created_at :datetime
+# updated_at :datetime
+# registration_open_date :datetime
+# registration_close_date :datetime
+# bank_number :string
+# show_ticket_count :boolean default(TRUE)
+# contact_email :string
+# export_file_name :string
+# export_content_type :string
+# export_file_size :integer
+# export_updated_at :datetime
+# show_statistics :boolean
+# export_status :string
+# club_id :integer
+# registration_open :boolean default(TRUE)
+# signature :text
+# registration_cancelable :boolean
+# phone_number_state :string default("optional")
+# extra_info :boolean default(FALSE)
+# comment_title :string
+# show_telephone_disclaimer :boolean default(FALSE)
#
class Event < ActiveRecord::Base
@@ -77,20 +80,6 @@ def prettify_bank_number
self.bank_number = IBANTools::IBAN.new(self.bank_number).prettify if bank_number_changed?
end
- def comment_title
- if id == 1
- return 'Afstudeerjaar en -richting' #TODO: maybe add to database if this used in more cases
- end
- nil
- end
-
- def show_telephone_disclaimer
- if id == 1
- return true
- end
- false
- end
-
def generate_xls
self.export_status = 'generating'
self.save
diff --git a/app/models/registration.rb b/app/models/registration.rb
index e58f549c..bf06cbaf 100644
--- a/app/models/registration.rb
+++ b/app/models/registration.rb
@@ -17,6 +17,8 @@
# barcode_data :string
# payment_code :string
# phone_number :string
+# title :string
+# job_function :string
#
class Registration < ActiveRecord::Base
diff --git a/db/migrate/20170129135614_add_comment_title_and_show_telephone_disclaimer_to_events.rb b/db/migrate/20170129135614_add_comment_title_and_show_telephone_disclaimer_to_events.rb
new file mode 100644
index 00000000..597c052b
--- /dev/null
+++ b/db/migrate/20170129135614_add_comment_title_and_show_telephone_disclaimer_to_events.rb
@@ -0,0 +1,6 @@
+class AddCommentTitleAndShowTelephoneDisclaimerToEvents < ActiveRecord::Migration
+ def change
+ add_column :events, :comment_title, :string
+ add_column :events, :show_telephone_disclaimer, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6fc76c88..26879c00 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: 20170111204432) do
+ActiveRecord::Schema.define(version: 20170129135614) do
create_table "access_levels", force: :cascade do |t|
t.string "name"
@@ -93,7 +93,7 @@
t.datetime "registration_open_date"
t.datetime "registration_close_date"
t.string "bank_number"
- t.boolean "show_ticket_count", default: true
+ t.boolean "show_ticket_count", default: true
t.string "contact_email"
t.string "export_file_name"
t.string "export_content_type"
@@ -102,10 +102,13 @@
t.boolean "show_statistics"
t.string "export_status"
t.integer "club_id"
- t.boolean "registration_open", default: true
+ t.boolean "registration_open", default: true
t.text "signature"
t.boolean "registration_cancelable"
- t.string "phone_number_state", default: "optional"
+ t.string "phone_number_state", default: "optional"
+ t.boolean "extra_info", default: false
+ t.string "comment_title"
+ t.boolean "show_telephone_disclaimer", default: false
end
create_table "included_zones", force: :cascade do |t|
@@ -179,6 +182,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"
diff --git a/test/fixtures/events.yml b/test/fixtures/events.yml
index 7458acd6..cea2cdcb 100644
--- a/test/fixtures/events.yml
+++ b/test/fixtures/events.yml
@@ -2,31 +2,34 @@
#
# Table name: events
#
-# id :integer not null, primary key
-# name :string
-# start_date :datetime
-# end_date :datetime
-# location :string
-# website :string
-# description :text
-# created_at :datetime
-# updated_at :datetime
-# registration_open_date :datetime
-# registration_close_date :datetime
-# bank_number :string
-# show_ticket_count :boolean default(TRUE)
-# contact_email :string
-# export_file_name :string
-# export_content_type :string
-# export_file_size :integer
-# export_updated_at :datetime
-# show_statistics :boolean
-# export_status :string
-# club_id :integer
-# registration_open :boolean default(TRUE)
-# signature :text
-# registration_cancelable :boolean
-# phone_number_state :string default("optional")
+# id :integer not null, primary key
+# name :string
+# start_date :datetime
+# end_date :datetime
+# location :string
+# website :string
+# description :text
+# created_at :datetime
+# updated_at :datetime
+# registration_open_date :datetime
+# registration_close_date :datetime
+# bank_number :string
+# show_ticket_count :boolean default(TRUE)
+# contact_email :string
+# export_file_name :string
+# export_content_type :string
+# export_file_size :integer
+# export_updated_at :datetime
+# show_statistics :boolean
+# export_status :string
+# club_id :integer
+# registration_open :boolean default(TRUE)
+# signature :text
+# registration_cancelable :boolean
+# phone_number_state :string default("optional")
+# extra_info :boolean default(FALSE)
+# comment_title :string
+# show_telephone_disclaimer :boolean default(FALSE)
#
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
diff --git a/test/fixtures/registrations.yml b/test/fixtures/registrations.yml
index 1a297cd2..86aecb21 100644
--- a/test/fixtures/registrations.yml
+++ b/test/fixtures/registrations.yml
@@ -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
diff --git a/test/models/event_test.rb b/test/models/event_test.rb
index 088e1c71..1fec599b 100644
--- a/test/models/event_test.rb
+++ b/test/models/event_test.rb
@@ -2,31 +2,34 @@
#
# Table name: events
#
-# id :integer not null, primary key
-# name :string
-# start_date :datetime
-# end_date :datetime
-# location :string
-# website :string
-# description :text
-# created_at :datetime
-# updated_at :datetime
-# registration_open_date :datetime
-# registration_close_date :datetime
-# bank_number :string
-# show_ticket_count :boolean default(TRUE)
-# contact_email :string
-# export_file_name :string
-# export_content_type :string
-# export_file_size :integer
-# export_updated_at :datetime
-# show_statistics :boolean
-# export_status :string
-# club_id :integer
-# registration_open :boolean default(TRUE)
-# signature :text
-# registration_cancelable :boolean
-# phone_number_state :string default("optional")
+# id :integer not null, primary key
+# name :string
+# start_date :datetime
+# end_date :datetime
+# location :string
+# website :string
+# description :text
+# created_at :datetime
+# updated_at :datetime
+# registration_open_date :datetime
+# registration_close_date :datetime
+# bank_number :string
+# show_ticket_count :boolean default(TRUE)
+# contact_email :string
+# export_file_name :string
+# export_content_type :string
+# export_file_size :integer
+# export_updated_at :datetime
+# show_statistics :boolean
+# export_status :string
+# club_id :integer
+# registration_open :boolean default(TRUE)
+# signature :text
+# registration_cancelable :boolean
+# phone_number_state :string default("optional")
+# extra_info :boolean default(FALSE)
+# comment_title :string
+# show_telephone_disclaimer :boolean default(FALSE)
#
require 'test_helper'
diff --git a/test/models/registration_test.rb b/test/models/registration_test.rb
index 93e92e3e..3fb9d6d2 100644
--- a/test/models/registration_test.rb
+++ b/test/models/registration_test.rb
@@ -17,6 +17,8 @@
# barcode_data :string
# payment_code :string
# phone_number :string
+# title :string
+# job_function :string
#
require 'test_helper'