Skip to content

Commit

Permalink
Cleanup and mail
Browse files Browse the repository at this point in the history
  • Loading branch information
feliciaan committed Jan 11, 2017
1 parent 2639828 commit 241fa89
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/controllers/registrations_controller.rb
Expand Up @@ -47,13 +47,15 @@ def resend
end
end

def showUnsubscribe
def show_unsubscribe
@registration = Registration.find_by! id: params[:id], barcode: params[:barcode]
end

def destroyUnsubscribe
def destroy_unsubscribe
registration = Registration.find_by! id: params[:id], barcode: params[:barcode]
registration.destroy
event = registration.event
registration.destroy!
RegistrationMailer.confirm_unsubscribing(registration, event).deliver_now
end

def basic
Expand Down
6 changes: 6 additions & 0 deletions app/mailers/registration_mailer.rb
Expand Up @@ -28,4 +28,10 @@ def notify_overpayment(registration)
mail to: "#{registration.name} <#{registration.email}>", subject: "Overpayment for #{registration.event.name}"
end

def confirm_unsubscribing(registration, event)
@registration = registration
@event = event

mail to: "#{registration.name} <#{registration.email}>", subject: "Unsubscription for #{event.name}"
end
end
49 changes: 49 additions & 0 deletions app/views/registration_mailer/confirm_unsubscribing.html.erb
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<p>Dear <%= @registration.name %>,</p>

<p>This email is confirms you have unsubscribed for the following event:</p>

This comment has been minimized.

Copy link
@TomNaessens

TomNaessens Jan 11, 2017

Member

is to confirm?

This comment has been minimized.

Copy link
@TomNaessens

TomNaessens Jan 11, 2017

Member

Of: Your registration for the following event has been cancelled


<table>
<tbody>
<tr>
<td><strong>Event</strong></td>
<td><%= @event.name %></td>
</tr>
<tr>
<td><strong>Organisation</strong></td>
<td><%= @event.club.name %></td>
</tr>
<tr>
<td><strong>Location</strong></td>
<td><%= @event.location %></td>
</tr>
<tr>
<td><strong>Start date</strong></td>
<td><%= nice_time @event.start_date %></td>
</tr>
<tr>
<td><strong>End date</strong></td>
<td><%= nice_time @event.end_date %></td>
</tr>
<tr>
<td><strong>Website</strong></td>
<td><a href="<%= @event.website %>"><%= @event.website %></a></td>
</tr>
</tbody>
</table>

<p>If you have any problems, you can contact us via mail: <%= mail_to @event.contact_email, @event.contact_email %></p>

<p>Kind regards,<br /><%= @event.club.name %></p>

<% unless @event.signature.blank? %>
<%= simple_format @event.signature %>
<% end %>

</body>
</html>
4 changes: 2 additions & 2 deletions config/routes.rb
Expand Up @@ -38,8 +38,8 @@
get 'resend'
get 'info'

get 'unsubscribe/:barcode', to: 'registrations#showUnsubscribe', as: 'unsubscribe'
delete 'unsubscribe/:barcode', to: 'registrations#destroyUnsubscribe', as: 'unsubscribe_destroy'
get 'unsubscribe/:barcode', to: 'registrations#show_unsubscribe', as: 'unsubscribe'
delete 'unsubscribe/:barcode', to: 'registrations#destroy_unsubscribe', as: 'unsubscribe_destroy'
end

collection do
Expand Down

0 comments on commit 241fa89

Please sign in to comment.