Skip to content

Commit

Permalink
Merge branch 'dev' into 571_annotations_icon
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterCarl committed Feb 9, 2017
2 parents 25aa4ae + dd4296a commit b3f3734
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ DEPENDENCIES
jquery-turbolinks
jquery-ui-rails
less-rails
owlcarousel-rails!
mini_magick
owlcarousel-rails!
parser (~> 2.2.2.5)
pdf-inspector
pg
Expand Down
12 changes: 12 additions & 0 deletions app/assets/stylesheets/events.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
margin: 15px 0;
padding-bottom: 15px;
}

.event-preview a{
color: #000;
transition: all 0.5s;
}

.event-preview a:hover {
text-decoration: none;
color: #DE6207;
transition: all 0.5s;
}

.front-section:nth-child(even) .event-preview {
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def send_application_result_email
if @email.valid?
application_letter_status = get_corresponding_application_letter_status
if application_letter_status == :accepted
@email.send_email_with_ical @event
@email.send_email_with_ical_and_agreement_letter @event
else
@email.send_email
end
Expand Down
11 changes: 9 additions & 2 deletions app/models/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def initialize(attributes = {})
end
end

def send_email_with_ical(event)
send_email([get_ical_attachment(event)])
def send_email_with_ical_and_agreement_letter(event)
send_email([get_ical_attachment(event), get_agreement_letter_attachment])
end

def send_email(attachments = [])
Expand All @@ -41,6 +41,13 @@ def persisted?

private

def get_agreement_letter_attachment
{
name: (I18n.t 'emails.agreement_letter_attachment'),
content: File.read(Rails.configuration.empty_agreement_letter_path)
}
end

def get_ical_attachment(event)
cal = Icalendar::Calendar.new
for date_range in event.date_ranges do
Expand Down
6 changes: 3 additions & 3 deletions app/views/events/_event.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
</div>

<div class="media-body">
<a href="<%= event_path(event) %>">
<h3>
<a href="<%= event_path(event) %>">
<%= event.name %>
</a>
<small>
<%= tag_label t('activerecord.attributes.event.draft'), :default if not event.published and can? :view_unpublished, Event %>
<%= tag_label t('activerecord.attributes.event.hidden'), :default if event.hidden and can? :view_hidden, Event %>
<%= tag_label t('events.notices.past_event'), :default if event.is_past %>
</small>
</h3>
</a>

<p>
<%= truncate(markdown(event.description, true), length: Event::TRUNCATE_DESCRIPTION_TEXT_LENGTH) %>
<%= link_to " " + I18n.t('events.list.read_on'), event_path(event) %>
<%= link_to " " + t('events.list.read_on'), event_path(event) %>

<div class="pull-left">
<div class="m-b-1">
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
end_picker = text_field_tag "event[date_ranges_attributes][][end_date]", (I18n.l end_date),
class: 'form-control', :"data-enable-datepicker" => 'true'

"<div>#{start_picker} #{t 'date_range.to'} #{end_picker} "+
"<div>#{start_picker} #{t 'date_range.pronouns.to'} #{end_picker} "+
"<a class=\"close\" onclick=\"javascript:removeEventDatePicker(event.target)\">&times;</a></div>"
end %>
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ class ApplicationLetter < Rails::Application

config.from_address = ENV['SMTP_ADDRESS'] ? ENV['SMTP_ADDRESS'] : 'noreply@localhost'
config.reply_to_address = config.from_address

config.empty_agreement_letter_path = Rails.root.join('storage', 'agreement_letters', 'real_agreement_letter.pdf')
end
end
3 changes: 2 additions & 1 deletion config/locales/de.emails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ de:
sending_failed: 'Email konnte nicht versenden werden'
saving_successful: 'Vorlage erfolgreich gespeichert'
saving_failed: 'Vorlage konnte nicht gespeichert werden'
ical_attachment: "Termin.ics"
ical_attachment: "Termin.ics"
agreement_letter_attachment: "Einverstaendniserklaerung.pdf"
8 changes: 4 additions & 4 deletions spec/controllers/email_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
}.to change{ActionMailer::Base.deliveries.count}.by(1)
end

it "sends an Email with ical attachement for accepted applications" do
it "sends an Email with ical and pdf attachement for accepted applications" do
post :submit_application_result, send: I18n.t('.emails.email_form.send'), event_id: @event.id, email: @email, status: 'acceptance'

mail = ActionMailer::Base.deliveries.last
expect(mail.attachments.size).to eq(1)
attachment = mail.attachments[0]
expect(attachment.filename).to eq(I18n.t 'emails.ical_attachment')
expect(mail.attachments.size).to eq(2)
expect(mail.attachments[0].filename).to eq(I18n.t 'emails.ical_attachment')
expect(mail.attachments[1].filename).to eq(I18n.t 'emails.agreement_letter_attachment')
end

it "does not send an Email with ical attachement for rejected applications" do
Expand Down

0 comments on commit b3f3734

Please sign in to comment.