Skip to content

Commit

Permalink
Merge branch 'dev' into 430-ui-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cmfcmf committed Feb 1, 2017
2 parents d054401 + 15342a3 commit 3258001
Show file tree
Hide file tree
Showing 36 changed files with 88 additions and 129 deletions.
6 changes: 3 additions & 3 deletions app/controllers/application_letters_controller.rb
Expand Up @@ -30,7 +30,7 @@ def new
last_application_letter = ApplicationLetter.where(user: current_user).order("created_at").last
if last_application_letter
attrs_to_fill_in = last_application_letter.attributes
.slice("grade", "coding_skills", "emergency_number", "vegetarian", "vegan", "allergic", "allergies")
.slice("grade", "coding_skills", "emergency_number", "vegetarian", "vegan", "allergies")
@application_letter.attributes = attrs_to_fill_in
flash.now[:notice] = I18n.t('application_letters.fields_filled_in')
end
Expand Down Expand Up @@ -123,8 +123,8 @@ def set_application
# Only allow a trusted parameter "white list" through.
# Don't allow user_id as you shouldn't be able to set the user from outside of create/update.
def application_params
params.require(:application_letter).permit(:grade, :experience, :motivation, :coding_skills, :emergency_number, :organisation,
:vegetarian, :vegan, :allergic, :allergies, :annotation, :user_id, :event_id)
params.require(:application_letter).permit(:grade, :motivation, :coding_skills, :emergency_number, :organisation,
:vegetarian, :vegan, :allergies, :annotation, :user_id, :event_id)
.merge({:custom_application_fields => params[:custom_application_fields]})
end

Expand Down
3 changes: 1 addition & 2 deletions app/controllers/events_controller.rb
Expand Up @@ -252,8 +252,7 @@ def set_event
end

def event_params
params.require(:event).permit(:name, :description, :max_participants, :participants_are_unlimited, :organizer, :knowledge_level, :application_deadline, :published, :hidden, :custom_application_fields => [], date_ranges_attributes: [:start_date, :end_date, :id])

params.require(:event).permit(:name, :description, :max_participants, :organizer, :knowledge_level, :application_deadline, :published, :hidden, :custom_application_fields => [], date_ranges_attributes: [:start_date, :end_date, :id])
end

def add_event_query_conditions(query)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -63,7 +63,7 @@ def dropdown_items
end
# pupils get their applications
if current_user.role == "pupil"
o << (menu_item t(:my_application_letters, scope: 'navbar'), application_letters_path)
o << (menu_item t(:my_events, scope: 'navbar'), application_letters_path)
end
# admins get user management
if current_user.role == "admin" || current_user.role == "organizer"
Expand Down
12 changes: 8 additions & 4 deletions app/models/application_letter.rb
Expand Up @@ -19,11 +19,11 @@ class ApplicationLetter < ActiveRecord::Base

VALID_GRADES = 5..13

validates :user, :event, :experience, :motivation, :coding_skills, :emergency_number,:organisation, presence: true
validates :user, :event, :motivation, :coding_skills, :emergency_number,:organisation, presence: true
validates :grade, presence: true, numericality: { only_integer: true }
validates_inclusion_of :grade, :in => VALID_GRADES
validates :vegetarian, :vegan, :allergic, inclusion: { in: [true, false] }
validates :vegetarian, :vegan, :allergic, exclusion: { in: [nil] }
validates :vegetarian, :vegan, inclusion: { in: [true, false] }
validates :vegetarian, :vegan, exclusion: { in: [nil] }
validate :deadline_cannot_be_in_the_past, :if => Proc.new { |letter| !(letter.status_changed?) }
validate :status_cannot_be_changed, :if => Proc.new { |letter| letter.status_changed?}

Expand Down Expand Up @@ -114,7 +114,11 @@ def eating_habits
habits = Array.new
habits.push(ApplicationLetter.human_attribute_name(:vegetarian)) if vegetarian
habits.push(ApplicationLetter.human_attribute_name(:vegan)) if vegan
habits.push(ApplicationLetter.human_attribute_name(:allergic)) if allergic
habits.push(ApplicationLetter.human_attribute_name(:allergies)) if allergic
habits
end

def allergic
not allergies.empty?
end
end
18 changes: 0 additions & 18 deletions app/models/event.rb
Expand Up @@ -34,24 +34,6 @@ class Event < ActiveRecord::Base
validates :published, inclusion: { in: [true, false] }
validates :published, exclusion: { in: [nil] }

# Setter for max_participants
# @param [Int Float] the max number of participants for the event or infinity if it is not limited
# @return none
def max_participants=(value)
if value == Float::INFINITY
self[:participants_are_unlimited] = true
else
self[:participants_are_unlimited] = false
self[:max_participants] = value
end
end

# Getter for max_participants
# @param none
# @return [Int Float] the max number of participants for the event or infinity if it is not limited
def max_participants
participants_are_unlimited ? Float::INFINITY : self[:max_participants]
end

# Returns all participants for this event in following order:
# 1. All participants that have to submit an letter of agreement but did not yet do so, ordered by name.
Expand Down
12 changes: 7 additions & 5 deletions app/views/application/index.html.erb
Expand Up @@ -23,11 +23,13 @@
<%= glyph 'calendar' %> <%= t "start_page.all_events" %>
</a>
</li>
<li>
<a class="btn btn-default" href="<%= new_user_registration_path %>">
<%= glyph 'user' %> <%= t 'start_page.register_now' %>
</a>
</li>
<% unless user_signed_in? %>
<li>
<a class="btn btn-default" href="<%= new_user_registration_path %>">
<%= glyph 'user' %> <%= t 'start_page.register_now' %>
</a>
</li>
<% end %>
</ul>
</div>
</div>
Expand Down
19 changes: 1 addition & 18 deletions app/views/application_letters/_form.html.erb
Expand Up @@ -15,12 +15,6 @@
</div>

</div>
<div class="form-group">
<%= f.label :experience, :class => 'control-label col-lg-2 required' %>
<div class="col-lg-10">
<%= f.text_area :experience, :class => 'form-control' %> <%=f.error_span(:experience) %>
</div>
</div>
<div class="form-group">
<%= f.label :motivation, :class => 'control-label col-lg-2 required' %>
<div class="col-lg-10">
Expand Down Expand Up @@ -53,23 +47,12 @@
<div class="col-sm-offset-2 col-sm-10">
<%= f.check_box :vegetarian%>
<%= f.label :vegetarian, :class => 'control-label' %>
<%=f.error_span(:vegetarian) %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.check_box :vegan%>
<%= f.label :vegan, :class => 'control-label' %>
<%=f.error_span(:vegetarian) %>
<%=f.error_span(:vegan) %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<%= f.check_box :allergic%>
<%= f.label :allergic, :class => 'control-label' %>
<%=f.error_span(:allergic) %>
</div>
</div>
<div class="form-group">
<%= f.label :allergies, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
Expand Down
2 changes: 0 additions & 2 deletions app/views/application_letters/check.html.erb
Expand Up @@ -23,8 +23,6 @@
<%= @application_letter.grade %><br/>
<strong><%= ApplicationLetter.human_attribute_name(:motivation) %>:</strong><br/>
<%= @application_letter.motivation %><br/>
<strong><%= ApplicationLetter.human_attribute_name(:experience) %>:</strong><br/>
<%= @application_letter.experience %><br/>
<strong><%= ApplicationLetter.human_attribute_name(:coding_skills) %>:</strong><br/>
<%= @application_letter.coding_skills %><br/>
<strong><%= ApplicationLetter.human_attribute_name(:emergency_number) %>:</strong>
Expand Down
7 changes: 2 additions & 5 deletions app/views/events/_applicants_overview.html.erb
@@ -1,10 +1,7 @@
<div class="container-fluid" id="applicants_overview">
<h3><%= t '.title', title: @event.name %></h3>
<% if @free_places == Float::INFINITY %>
<%= Event.human_attribute_name(:participants_are_unlimited) %>
<% else %>
<div id="free_places"><%= t '.free_places', count: @free_places %></div>
<% end %>

<div id="free_places"><%= t '.free_places', count: @free_places %></div>
<div id="occupied_places"><%= t '.occupied_places', count: @occupied_places %></div>

<table id="applicants" class="table table-striped">
Expand Down
2 changes: 0 additions & 2 deletions app/views/events/_form.html.erb
Expand Up @@ -68,8 +68,6 @@
<div class="col-lg-10">
<%= f.text_field :max_participants, :class => 'form-control' %>
<%=f.error_span(:max_participants) %>
<%= f.label :participants_are_unlimited %>
<%= f.check_box :participants_are_unlimited, :class => 'form_control' %>
</div>
</div>
<div class="form-group">
Expand Down
6 changes: 1 addition & 5 deletions app/views/events/_show_event.html.erb
Expand Up @@ -5,11 +5,7 @@
<dt><strong><%= model_class.human_attribute_name(:description) %>:</strong></dt>
<dd><%= markdown @event.description %></dd>
<dt><strong><%= model_class.human_attribute_name(:max_participants) %>:</strong></dt>
<%if @free_places == Float::INFINITY %>
<dd><%= model_class.human_attribute_name(:participants_are_unlimited) %></dd>
<%else%>
<dd><%= @event.max_participants %></dd>
<% end %>
<dd><%= @event.max_participants %></dd>
<dt><strong><%= model_class.human_attribute_name(:date_ranges, count: @event.date_ranges.count) %>:</strong></dt>
<dd>
<ul>
Expand Down
2 changes: 2 additions & 0 deletions app/views/profiles/show.html.erb
Expand Up @@ -12,6 +12,8 @@
<dd><%= @profile.public_send(attr_name) %></dd>
<% end %>
<% end %>
<dt><strong><%= model_class.human_attribute_name('email') %>:</strong></dt>
<dd><%= mail_to @profile.user.email %></dd>
</dl>

<%= link_to t('.edit', :default => t("helpers.links.edit")),
Expand Down
4 changes: 1 addition & 3 deletions config/locales/de.application_letters.yml
Expand Up @@ -51,14 +51,12 @@ de:
attributes:
application_letter:
grade: "Klassenstufe"
experience: "Wie hast du von uns erfahren?"
motivation: "Motivationsschreiben"
coding_skills: "Mit welchen Programmiersprachen hast du bereits Erfahrungen gesammelt?"
emergency_number: "Telefonnummer für Notfälle"
organisation: "Schule/Organisation"
vegetarian: "Vegetarisch"
vegan: "Vegan"
allergic: "Allergien vorhanden"
allergies: "Falls Allergien vorhanden, welche?"
annotation: "Hast du weitere Anmerkungen oder Fragen?"
omnivorous: "Omnivor"
Expand All @@ -80,4 +78,4 @@ de:
confirmation_mail:
sender: "workshop@hpi.de"
subject: "Bewerbung erhalten"
content: "Hallo, \n\rDu hast dich erfolgreich für {{semimar_name}} beworben. Deine Bewerbung wird jetzt bearbeitet. Für weitere Information besuche das Workshop Portal. Viele Grüße, das HPI Workshop Team"
content: "Hallo, \n\rDu hast dich erfolgreich für {{semimar_name}} beworben. Deine Bewerbung wird jetzt bearbeitet. Für weitere Information besuche das Workshop Portal. Viele Grüße, das HPI Workshop Team"
2 changes: 1 addition & 1 deletion config/locales/de.events.yml
Expand Up @@ -146,7 +146,7 @@ de:
name: "Name"
description: "Beschreibung"
max_participants: "Maximale Teilnehmerzahl"
participants_are_unlimited: "Unbegrenzte Teilnehmerzahl"
kind: "Art"
active: "Aktiv"
start_date: "Beginn"
end_date: "Ende"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/de.yml
Expand Up @@ -31,7 +31,7 @@ de:
events: "Veranstaltungen"
profiles: "Nutzer"
application_letters: "Bewerbungen"
my_application_letters: "Meine Bewerbungen"
my_events: "Meine Veranstaltungen"
user_management: "Benutzerverwaltung"
requests: "Anfragen"
new_request: "Workshop anfragen"
Expand Down
@@ -0,0 +1,5 @@
class RemoveExperienceFromApplicationLetters < ActiveRecord::Migration
def change
remove_column :application_letters, :experience, :string
end
end
@@ -0,0 +1,5 @@
class RemoveParticipantsAreUnlimitedFromEvents < ActiveRecord::Migration
def change
remove_column :events, :participants_are_unlimited, :boolean
end
end
@@ -0,0 +1,5 @@
class RemoveAllergicFromApplicationLetter < ActiveRecord::Migration
def change
remove_column :application_letters, :allergic
end
end
12 changes: 0 additions & 12 deletions db/sample_data/application_letters.rb
Expand Up @@ -2,13 +2,11 @@ def application_letter_applicant_gongakrobatik(user, event)
ApplicationLetter.new(
motivation: "Ich habe vor kurzem davon erfahren und war direkt hellaufbegeistert. Gerne würde ich mich bei Ihnen näher über das Thema informieren",
grade: 10,
experience: "Über einen Facebookpost ihrer Seite bin ich auf das Angebot aufmerksam geworden",
coding_skills: "HTML",
emergency_number: "01234567891",
organisation: "Schule am Griebnitzsee",
vegetarian: false,
vegan: false,
allergic: false,
allergies: "",
annotation: "Euer Angebot find ich echt super.",
user: user,
Expand All @@ -20,13 +18,11 @@ def application_letter_applicant_gongakrobatik_rejected(user, event)
ApplicationLetter.new(
motivation: "Ich habe vor kurzem davon erfahren und war direkt hellaufbegeistert. Gerne würde ich mich bei Ihnen näher über das Thema informieren",
grade: 10,
experience: "Über einen Facebookpost ihrer Seite bin ich auf das Angebot aufmerksam geworden",
coding_skills: "HTML",
emergency_number: "01234567891",
organisation: "Schule am Griebnitzsee",
vegetarian: false,
vegan: false,
allergic: false,
allergies: "",
annotation: "",
user: user,
Expand All @@ -39,13 +35,11 @@ def application_letter_applicant_gongakrobatik_accepted(user, event)
ApplicationLetter.new(
motivation: "Den normalen Unterricht in der Schule finde ich ziemlich langweilig und würde mich darüber freuen, etwas über den Tellerrand zu schauen und spannende Dinge lernen. Ich arbeite sehr gerne im Team und freue mich darauf, Gleichgesinnte kennen zu lernen.",
grade: 9,
experience: "Über einen Zeitungsartikel",
coding_skills: "For, While und If-Schleifen in Java",
emergency_number: "01234567891",
organisation: "Schule am Griebnitzsee",
vegetarian: false,
vegan: false,
allergic: true,
allergies: "Tomaten",
annotation: "Euer Angebot find ich echt super.",
user: user,
Expand All @@ -58,13 +52,11 @@ def application_letter_applicant_programmierkurs_1(user, event)
ApplicationLetter.new(
motivation: "Den normalen Unterricht in der Schule finde ich ziemlich langweilig und würde mich darüber freuen, etwas über den Tellerrand zu schauen und spannende Dinge lernen. Ich arbeite sehr gerne im Team und freue mich darauf, Gleichgesinnte kennen zu lernen.",
grade: 9,
experience: "Über einen Zeitungsartikel",
coding_skills: "For, While und If-Schleifen in Java",
emergency_number: "01234567891",
organisation: "Schule am Griebnitzsee",
vegetarian: false,
vegan: false,
allergic: true,
allergies: "Tomaten",
annotation: "Euer Angebot find ich echt super.",
user: user,
Expand All @@ -76,13 +68,11 @@ def application_letter_applicant_programmierkurs_2(user, event)
ApplicationLetter.new(
motivation: "Ich habe vor kurzem davon erfahren und war direkt hellaufbegeistert. Gerne würde ich mich bei Ihnen näher über das Thema informieren",
grade: 10,
experience: "Suche im Internet",
coding_skills: "keine",
emergency_number: "01234567891",
organisation: "Schule am Griebnitzsee",
vegetarian: true,
vegan: false,
allergic: false,
allergies: "",
annotation: "Euer Angebot find ich echt super.",
user: user,
Expand All @@ -94,13 +84,11 @@ def application_letter_applicant_programmierkurs_3(user, event)
ApplicationLetter.new(
motivation: "Ich habe vor LANGEM davon erfahren und war direkt hellaufbegeistert. Gerne würde ich mich bei Ihnen näher über das Thema informieren",
grade: 10,
experience: "Suche im Internetz",
coding_skills: "absolut keine",
emergency_number: "01234567819",
organisation: "Schule am Griebnitzsee",
vegetarian: true,
vegan: false,
allergic: false,
allergies: "",
annotation: "Euer Angebot find ich echt super.",
user: user,
Expand Down
12 changes: 4 additions & 8 deletions 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: 20170201141415) do
ActiveRecord::Schema.define(version: 20170201154540) do

create_table "agreement_letters", force: :cascade do |t|
t.integer "user_id", null: false
Expand All @@ -32,12 +32,10 @@
t.datetime "updated_at", null: false
t.integer "status", default: 2, null: false
t.integer "grade"
t.string "experience"
t.string "coding_skills"
t.string "emergency_number"
t.boolean "vegetarian"
t.boolean "vegan"
t.boolean "allergic"
t.string "allergies"
t.text "custom_application_fields"
t.text "annotation"
Expand Down Expand Up @@ -77,15 +75,13 @@
t.string "name"
t.text "description"
t.integer "max_participants"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "published", default: false
t.string "organizer"
t.string "knowledge_level"
t.integer "kind", default: 0
t.boolean "published", default: false
t.date "application_deadline"
t.boolean "application_status_locked"
t.boolean "participants_are_unlimited", default: false
t.text "custom_application_fields"
t.boolean "hidden", default: false
end
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/application_letters_controller_spec.rb
Expand Up @@ -99,7 +99,6 @@
emergency_number: "01234567891",
vegetarian: true,
vegan: true,
allergic: true,
allergys: "Many",
annotation: "This site is so cool."
}
Expand Down

0 comments on commit 3258001

Please sign in to comment.