Skip to content

Commit

Permalink
Changes requested in review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian-Sommer committed Jan 8, 2017
1 parent 90463e7 commit 7cdafb4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def print_badges
def participants
@event = Event.find(params[:id])
@participants = @event.participants_by_agreement_letter
@has_agreement_letters = @event.agreement_letters.any?
end

# GET /events/1/print_applications
Expand Down
16 changes: 9 additions & 7 deletions app/views/events/participants.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%- model_class = Event -%>
<script type="text/javascript">
jQuery(function() {
$('#selectAll').click(function() {
jQuery('#selectAll').click(function() {
if (this.checked) {
$(':checkbox').each(function() {
jQuery(':checkbox').each(function() {
this.checked = true;
});
} else {
$(':checkbox').each(function() {
jQuery(':checkbox').each(function() {
this.checked = false;
});
}
Expand All @@ -27,7 +27,7 @@
<th><%= t 'activerecord.attributes.profile.name' %></th>
<th><%= t 'activerecord.attributes.profile.email' %></th>
<th><%= t 'agreement_letters.agreement_letter' %></th>
<% if can? :print_agreement_letters, Event %><th><input type="checkbox" id="selectAll" value="selectAll" /> <%= t 'events.agreement_letters_download.select_all' %></th><% end %>
<% if can? :print_agreement_letters, Event and @has_agreement_letters %><th><input type="checkbox" id="selectAll" value="selectAll" /> <%= t 'events.agreement_letters_download.select_all' %></th><% end %>
</tr>

<% @participants.each do |participant| %>
Expand All @@ -48,20 +48,22 @@
<span class="text-danger"><%= t '.unavailable' %></span>
<% end %>
</td>
<% if can? :print_agreement_letters, Event %>
<% if can? :print_agreement_letters, Event and @has_agreement_letters %>
<td>
<%= check_box_tag('selected_participants[]', participant.id) %>
</td>
<% end %>
</tr>
<% end %>
</table>
<% if can? :print_agreement_letters, Event %>
<% if can? :print_agreement_letters, Event and @has_agreement_letters %>
<div id="participants_download_submit_button">
<%= submit_tag t('events.agreement_letters_download.download_all_as'), name: "download_all" %>
<%= select_tag :download_type, options_for_select([['pdf'], ['zip']]) %>
</div>
<% end %>
<% end %>

<br>
<%= link_to t('.back', :default => t('helpers.links.back')),
event_path(@event), :class => 'btn btn-default' %>
<% end %>
5 changes: 4 additions & 1 deletion db/sample_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def add_sample_data
application_letters[:applicant_gongakrobatik_past_deadline] = application_letter_applicant_gongakrobatik(users[:applicant], events[:past_deadline_event])
application_letters[:applicant_gongakrobatik_accepcted] = application_letter_applicant_gongakrobatik_accepted(users[:applicant], events[:past_deadline_event])
application_letters[:applicant_gongakrobatik_rejected] = application_letter_applicant_gongakrobatik_rejected(users[:applicant], events[:past_deadline_event])
application_letters[:applicant_gongakrobatik_max] = application_letter_applicant_gongakrobatik_accepted(users[:max], events[:past_deadline_event])
application_letters[:applicant_gongakrobatik_karl] = application_letter_applicant_gongakrobatik_accepted(users[:pupil], events[:past_deadline_event])
application_letters[:applicant_programmierkurs_lisa] = application_letter_applicant_programmierkurs_1(users[:lisa], events[:programmierkurs])
application_letters[:applicant_programmierkurs_max] = application_letter_applicant_programmierkurs_2(users[:max], events[:programmierkurs])
application_letters[:applicant_programmierkurs_tobi] = application_letter_applicant_programmierkurs_3(users[:tobi], events[:programmierkurs])
Expand All @@ -55,7 +57,8 @@ def add_sample_data
requests[:hardware_entwicklung] = request_hardware_entwicklung

agreement_letters = Hash.new
agreement_letters[:applicant_gongakrobatik] = agreement_letter_applicant_gongakrobatik(users[:applicant], events[:gongakrobatik])
agreement_letters[:applicant_gongakrobatik] = agreement_letter_applicant_gongakrobatik(users[:applicant], events[:past_deadline_event])
agreement_letters[:max_gongakrobatik] = agreement_letter_applicant_gongakrobatik(users[:max], events[:past_deadline_event])

[events, users, profiles, application_letters, requests, agreement_letters].each do |models|
save_models(models)
Expand Down
2 changes: 1 addition & 1 deletion db/sample_data/agreement_letters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ def agreement_letter_applicant_gongakrobatik(user, event)
AgreementLetter.new(
user: user,
event: event,
path: "/storage/agreement_letters/foo.pdf"
path: "storage/agreement_letters/real_agreement_letter.pdf"
)
end
6 changes: 3 additions & 3 deletions db/sample_data/profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def profile_pupil(user)
first_name: "Karl",
last_name: "Doe",
gender: "male",
birth_date: Date.parse('2000.11.29'),
birth_date: Date.parse('2005.11.29'),
school: "Schule am Griebnitzsee",
street_name: "Rudolf-Breitscheid-Str. 52",
zip_code: "14482",
Expand All @@ -21,7 +21,7 @@ def profile_pupil_max(user)
first_name: "Max",
last_name: "Mustermann",
gender: "male",
birth_date: Date.parse('2000.12.09'),
birth_date: Date.parse('2005.12.09'),
school: "Musterschule",
street_name: "Musterstraße 42",
zip_code: "14482",
Expand Down Expand Up @@ -55,7 +55,7 @@ def profile_applicant(user)
first_name: "Erika",
last_name: "Mustermann",
gender: "female",
birth_date: Date.parse('1999.08.14'),
birth_date: Date.parse('2006.08.14'),
school: "Schule am Griebnitzsee",
street_name: "Rudolf-Breitscheid-Str. 52",
zip_code: "14482",
Expand Down
Binary file removed storage/agreement_letters/foo.pdf
Binary file not shown.
Binary file not shown.

0 comments on commit 7cdafb4

Please sign in to comment.