Skip to content

Commit

Permalink
Merge branch 'dev' into 238_Event_Description_Textfield
Browse files Browse the repository at this point in the history
  • Loading branch information
GoesOnTangents committed Feb 3, 2017
2 parents 7d70970 + d7e3194 commit c8992d2
Show file tree
Hide file tree
Showing 103 changed files with 828 additions and 449 deletions.
1 change: 1 addition & 0 deletions .rbenv_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.2-x64
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ gem 'will_paginate-bootstrap'
# Markdown renderer
gem 'redcarpet'

# Ical generator
gem 'icalendar'

# Pattern generator
gem 'geo_pattern'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
9 changes: 6 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ GEM
codeclimate-test-reporter (1.0.3)
simplecov
coderay (1.1.1)
color (1.8)
combine_pdf (0.2.32)
ruby-rc4 (>= 0.1.5)
commonjs (0.2.7)
Expand Down Expand Up @@ -112,13 +113,16 @@ GEM
railties (>= 3.0.0)
figaro (1.1.1)
thor (~> 0.14)
geo_pattern (1.4.0)
color (~> 1.5)
globalid (0.3.7)
activesupport (>= 4.1.0)
has_scope (0.7.0)
actionpack (>= 4.1, < 5.1)
activesupport (>= 4.1, < 5.1)
hashery (2.1.2)
i18n (0.7.0)
icalendar (2.4.1)
jquery-rails (4.2.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand Down Expand Up @@ -324,7 +328,9 @@ DEPENDENCIES
devise_openid_authenticatable
factory_girl_rails
figaro
geo_pattern
has_scope
icalendar
jquery-rails
jquery-turbolinks
jquery-ui-rails
Expand Down Expand Up @@ -355,8 +361,5 @@ DEPENDENCIES
web-console (~> 2.0)
will_paginate-bootstrap

RUBY VERSION
ruby 2.2.2p95

BUNDLED WITH
1.13.7
Binary file added app/assets/images/about_hpi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ body, footer, main, .front-section {
width: 100%;
}

footer.front-section {
border: none;
}
footer {
margin-top: 120px;
}
.m-l-1 { margin-left: 15px; }
.m-r-1 { margin-right: 15px; }
.m-t-1 { margin-top: 15px; }
Expand Down
3 changes: 0 additions & 3 deletions app/assets/stylesheets/custom_bootstrap/variables.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/*! Generated by Live LESS Theme Customizer */

@import url('//fonts.googleapis.com/css?family=Open+Sans|Roboto+Slab');


@gray-base: rgb(0, 0, 0);
@gray-darker: lighten(@gray-base, 13.5%);
@gray-dark: lighten(@gray-base, 20%);
Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/events.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,9 @@
font-size: 1.5em;
}
}

#wsp-event-show-banner {
width: 100%;
height: 150px;
margin-bottom: 15px;
}
18 changes: 18 additions & 0 deletions app/assets/stylesheets/footer.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

@footer-bg: lighten(#F7B21C, 30%);

footer {
margin-top: 36px;
padding-top: 36px;
padding-bottom: 20px;
text-align: center;
color: rgba(0, 0, 0, 0.3);
background-color: @footer-bg;
}
footer .container {
max-width: 600px;
}
footer .ignore {
color: @footer-bg;
}

4 changes: 4 additions & 0 deletions app/assets/stylesheets/users.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#wsp-login-remember-me {
margin-bottom: 25px;
margin-top: 53px;
}
5 changes: 4 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def index
render 'index', locals: { full_width: true }
end

def imprint
end

def add_missing_permission_flashes

if current_user
Expand All @@ -33,7 +36,7 @@ def add_missing_permission_flashes
current_user.events_with_missing_agreement_letters.each do |event|
application_letter = ApplicationLetter.where(user: current_user, event: event).first
path = check_application_letter_path(application_letter)
flash.now[:warning] << "#{t('agreement_letters.please_upload', event: event.name)} <a class='btn btn-default' href='#{path}'>
flash.now[:warning] << "#{t('agreement_letters.please_upload', event: event.name)} <a class='btn btn-default btn-xs' href='#{path}'>
#{t('agreement_letters.upload')}
</a>".html_safe if current_user.older_than_required_age_at_start_date_of_event?(event, current_user.profile.age)
end
Expand Down
21 changes: 18 additions & 3 deletions app/controllers/application_letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def show
def new
if not current_user
message = I18n.t('application_letters.login_before_creation')
flash[:event_id] = params[:event_id]
flash.keep(:event_id)
return redirect_to user_session_path, :alert => message
elsif not current_user.profile.present?
message = I18n.t('application_letters.fill_in_profile_before_creation')
Expand All @@ -30,7 +32,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 All @@ -55,11 +57,24 @@ def edit
def create
@application_letter = ApplicationLetter.new(application_params)
#event must be param to new_application_letter_path
seminar_name = ''
if params[:event_id]
@application_letter.event_id = params[:event_id]
seminar_name = Event.find(params[:event_id]).name
end
@application_letter.user_id = current_user.id

# Send Confirmation E-Mail
email_params = {
:hide_recipients => true,
:recipients => current_user.email,
:reply_to => Rails.configuration.reply_to_address,
:subject => I18n.t('controllers.application_letters.confirmation_mail.subject'),
:content => I18n.t('controllers.application_letters.confirmation_mail.content', :seminar_name => seminar_name)
}
@email = Email.new(email_params)
Mailer.send_generic_email(@email.hide_recipients, @email.recipients, @email.reply_to, @email.subject, @email.content)

if @application_letter.save
redirect_to check_application_letter_path(@application_letter), notice: I18n.t('application_letters.successful_creation')
else
Expand Down Expand Up @@ -110,8 +125,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,
: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
12 changes: 9 additions & 3 deletions app/controllers/emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ def show
@event = Event.find(params[:event_id])

@templates = EmailTemplate.with_status(get_email_template_status)
@addresses = @event.email_addresses_of_type(get_corresponding_application_letter_status)
application_letter_status = get_corresponding_application_letter_status
@addresses = @event.email_addresses_of_type(application_letter_status)

@email = Email.new(hide_recipients: true, reply_to: 'workshop.portal@hpi.de', recipients: @addresses.join(','),
@email = Email.new(hide_recipients: true, reply_to: Rails.configuration.reply_to_address, recipients: @addresses.join(','),
subject: '', content: '')

render :email
end

Expand All @@ -29,7 +31,11 @@ def send_email
@event = Event.find(params[:event_id])

if @email.valid?
@email.send_email
if get_corresponding_application_letter_status == :accepted
@email.send_email_with_ical @event
else
@email.send_email
end

@event.lock_application_status

Expand Down
20 changes: 14 additions & 6 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class EventsController < ApplicationController

# GET /events
def index
@events = Event.sorted_by_start_date(false)
@events = @events.select{|event| event.hidden == false} unless can? :view_hidden, Event
@events = @events.select{|event| event.published == true} unless can? :view_unpublished, Event
@events = add_event_query_conditions(Event.future)
end

def archive
@events = add_event_query_conditions(Event.past)
end

# GET /events/1
Expand Down Expand Up @@ -75,7 +77,7 @@ def print_badges
@participants = @event.participants
name_format = params[:name_format]
show_color = params[:show_color]
show_school = params[:show_school]
show_organisation = params[:show_organisation]
logo = params[:logo_upload]

selected_ids = params[:selected_ids]
Expand All @@ -88,7 +90,7 @@ def print_badges
end

begin
pdf = BadgesPDF.generate(@event, selected_participants, name_format, show_color, show_school, logo)
pdf = BadgesPDF.generate(@event, selected_participants, name_format, show_color, show_organisation, logo)
send_data pdf, filename: "badges.pdf", type: "application/pdf", disposition: "inline"
rescue Prawn::Errors::UnsupportedImageType
flash.now[:error] = I18n.t('events.badges.wrong_file_format')
Expand Down Expand Up @@ -250,8 +252,14 @@ def set_event
end

def event_params
params.require(:event).permit(:name, :description, :max_participants, :participants_are_unlimited, :kind, :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)
conditions = {}
conditions[:hidden] = false unless can? :view_hidden, Event
conditions[:published] = true unless can? :view_unpublished, Event
query.where(conditions)
end

def filter_application_letters(application_letters)
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ def set_contact_person
end
end

def set_notes
@request = Request.find(params[:request_id])
update_params = notes_params
if !update_params[:notes].nil? and @request.update(update_params)
redirect_to @request, notice: I18n.t('requests.notice.was_updated')
else
render :show
end
end

# DELETE /requests/1
def destroy
@request.destroy
Expand Down Expand Up @@ -79,4 +89,8 @@ def request_params
def contact_person_params
params.require(:request).permit(:contact_person)
end

def notes_params
params.require(:request).permit(:notes)
end
end
9 changes: 9 additions & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ def after_update_path_for(resource)

# The path used after sign up.
def after_sign_up_path_for(resource)
stored_location = stored_location_for(resource)
if stored_location
referrer = Rails.application.routes.recognize_path(stored_location)
if referrer[:controller] == "application_letters" and referrer[:action] == "new"
# This comes from a application letter creation page -> redirect user there.
return stored_location
end
end

new_profile_path
end

Expand Down
9 changes: 8 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
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 All @@ -87,4 +87,11 @@ def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end

# Generates a nice looking pattern in one of the HPI colors
# for the given string.
def geopattern(string)
colors = ['#B1073A', '#DE6207', '#F7A900']
color = colors[Digest::SHA1.hexdigest(string).to_i(16) % colors.size]
GeoPattern.generate(string, color: color)
end
end
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "workshop.portal@gmail.com"
default from: Rails.configuration.from_address
layout 'mailer'
end
6 changes: 5 additions & 1 deletion app/mailers/portal_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ class PortalMailer < ApplicationMailer
# @param reply_to [Array<String>] - email addresses of recipient of the answer - can be a string of comma separated email adresses too
# @param subject [String] - subject of the mail
# @param content [String] - content of the mail
# @param some_attachments - array of hashes with name and content
# @return [ActionMailer::MessageDelivery] a mail object with the given parameters.
def generic_email(recipients, reply_to, subject, content)
def generic_email(recipients, reply_to, subject, content, some_attachments = [])
some_attachments.each do |attachment|
attachments[attachment[:name]] = attachment[:content]
end
mail(to: recipients, reply_to: reply_to, subject: subject, body: content)
end
end
13 changes: 8 additions & 5 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def initialize(user)

user ||= User.new # guest user (not logged in)

# Even guests can see the apply button
# This is revoked for coaches and organizers below.
can :view_apply_button, Event

if user.role? :pupil
# Pupils can only edit their own profiles
can [:new, :create], Profile
Expand All @@ -43,16 +47,15 @@ def initialize(user)
# Pupils can upload their letters of agreement
can [:create], AgreementLetter
can [:new, :create], Request
can :apply, Event
cannot :view_personal_details, ApplicationLetter, user: { id: !user.id }
end
if user.role? :coach
# Coaches can view Applications and participants for and view, upload and download materials for Event
can [:view_applicants, :view_participants, :view_material, :upload_material, :print_applications, :download_material], Event
can [:view_and_add_notes, :show], ApplicationLetter
can [:print_applications], Event
can :manage, Request
cannot :apply, Event
can [:show, :index], Request
cannot :view_apply_button, Event
cannot :check, ApplicationLetter
end
if user.role? :organizer
Expand All @@ -63,8 +66,8 @@ def initialize(user)
:manage, :view_material, :upload_material, :print_agreement_letters, :download_material,
:view_unpublished, :show_eating_habits, :print_applications_eating_habits, :view_hidden], Event
can :send_email, Email
can :manage, Request
cannot :apply, Event
can [:manage, :set_contact_person, :set_notes], Request
cannot :view_apply_button, Event
can [:update], ParticipantGroup

# Organizers can update user roles of pupil, coach and organizer, but cannot manage admins and cannot update a role to admin
Expand Down
Loading

0 comments on commit c8992d2

Please sign in to comment.