Add emails for booth's acceptance and rejection

This commit is contained in:
nasia 2017-08-02 20:10:47 +03:00 committed by Stella Rouzi
parent 5f9c0065c6
commit 7107f9a35f
11 changed files with 114 additions and 10 deletions

View file

@ -303,6 +303,7 @@ linters:
SpaceInsideHashAttributes: SpaceInsideHashAttributes:
exclude: exclude:
- "app/views/admin/conferences/_todo_list.html.haml" - "app/views/admin/conferences/_todo_list.html.haml"
- "app/views/admin/emails/index.html.haml"
- "app/views/admin/questions/_form.html.haml" - "app/views/admin/questions/_form.html.haml"
- "app/views/admin/questions/index.html.haml" - "app/views/admin/questions/index.html.haml"
- "app/views/admin/registrations/index.html.haml" - "app/views/admin/registrations/index.html.haml"
@ -403,6 +404,7 @@ linters:
# Offense count: 14 # Offense count: 14
ConsecutiveSilentScripts: ConsecutiveSilentScripts:
exclude: exclude:
- "app/views/admin/booths/_change_state_dropdown.html.haml"
- "app/views/admin/events/index.html.haml" - "app/views/admin/events/index.html.haml"
- "app/views/admin/schedules/_day_tab.html.haml" - "app/views/admin/schedules/_day_tab.html.haml"
- "app/views/admin/schedules/_event.html.haml" - "app/views/admin/schedules/_event.html.haml"

View file

@ -450,6 +450,7 @@ Style/IfUnlessModifier:
- 'app/helpers/application_helper.rb' - 'app/helpers/application_helper.rb'
- 'app/models/commercial.rb' - 'app/models/commercial.rb'
- 'app/models/conference.rb' - 'app/models/conference.rb'
- 'app/models/email_settings.rb'
- 'app/models/ticket_purchase.rb' - 'app/models/ticket_purchase.rb'
- 'app/models/user.rb' - 'app/models/user.rb'
- 'db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb' - 'db/migrate/20151031092713_change_conference_id_to_venue_id_in_rooms.rb'

View file

@ -47,7 +47,18 @@ module Admin
end end
def accept def accept
update_state(:accept, 'Booth accepted!') @booth.accept!
if @booth.save
if @conference.email_settings.send_on_booths_acceptance
Mailbot.conference_booths_acceptance_mail(@booth).deliver
end
redirect_to admin_conference_booths_path(conference_id: @conference.short_title),
notice: 'Booth successfully accepted!'
else
redirect_to admin_conference_booths_path(conference_id: @conference.short_title)
flash[:error] = "Booth could not be accepted. #{@booth.errors.full_messages.to_sentence}."
end
end end
def to_accept def to_accept
@ -59,7 +70,16 @@ module Admin
end end
def reject def reject
update_state(:reject, 'Booth rejected') @booth.reject!
if @booth.save
Mailbot.conference_booths_rejection_mail(@booth).deliver
redirect_to admin_conference_booths_path(conference_id: @conference.short_title),
notice: 'Booth successfully rejected.'
else
redirect_to admin_conference_booths_path(conference_id: @conference.short_title)
flash[:error] = "Booth could not be rejected. #{@booth.errors.full_messages.to_sentence}."
end
end end
def restart def restart

View file

@ -30,7 +30,9 @@ module Admin
:send_on_conference_registration_dates_updated, :conference_registration_dates_updated_subject, :conference_registration_dates_updated_body, :send_on_conference_registration_dates_updated, :conference_registration_dates_updated_subject, :conference_registration_dates_updated_body,
:send_on_venue_updated, :venue_updated_subject, :venue_updated_body, :send_on_venue_updated, :venue_updated_subject, :venue_updated_body,
:send_on_cfp_dates_updated, :cfp_dates_updated_subject, :cfp_dates_updated_body, :send_on_cfp_dates_updated, :cfp_dates_updated_subject, :cfp_dates_updated_body,
:send_on_program_schedule_public, :program_schedule_public_subject, :program_schedule_public_body) :send_on_program_schedule_public, :program_schedule_public_subject, :program_schedule_public_body,
:send_on_booths_acceptance, :booths_acceptance_subject, :booths_acceptance_body,
:send_on_booths_rejection, :booths_rejection_subject, :booths_rejection_body)
end end
end end
end end

View file

@ -97,6 +97,24 @@ class Mailbot < ActionMailer::Base
conference.email_settings.cfp_dates_updated_body)) conference.email_settings.cfp_dates_updated_body))
end end
def conference_booths_acceptance_mail(booth)
conference = booth.conference
mail(to: booth.submitter.email,
from: conference.contact.email,
subject: conference.email_settings.booths_acceptance_subject,
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body))
end
def conference_booths_rejection_mail(booth)
conference = booth.conference
mail(to: booth.submitter.email,
from: conference.contact.email,
subject: conference.email_settings.booths_rejection_subject,
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body))
end
def event_comment_mail(comment, user) def event_comment_mail(comment, user)
@comment = comment @comment = comment
@event = @comment.commentable @event = @comment.commentable

View file

@ -3,7 +3,7 @@ class EmailSettings < ActiveRecord::Base
has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id } has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id }
def get_values(conference, user, event = nil) def get_values(conference, user, event = nil, booth = nil)
h = { h = {
'email' => user.email, 'email' => user.email,
'name' => user.name, 'name' => user.name,
@ -45,6 +45,10 @@ class EmailSettings < ActiveRecord::Base
h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposals_url( h['proposalslink'] = Rails.application.routes.url_helpers.conference_program_proposals_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')) conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
end end
if booth
h['booth_title'] = booth.title
end
h h
end end
@ -58,6 +62,11 @@ class EmailSettings < ActiveRecord::Base
parse_template(conf_update_template, values) parse_template(conf_update_template, values)
end end
def generate_booth_mail(booth, booth_template)
values = get_values(booth.conference, booth.submitter, nil, booth)
parse_template(booth_template, values)
end
private private
def parse_template(text, values) def parse_template(text, values)

View file

@ -1,17 +1,25 @@
- if booth.transition_possible? :accept - if booth.transition_possible? :accept
%li= link_to 'Accept booth', - if @conference.email_settings.send_on_booths_acceptance
- link = 'Accept with email'
- else
- link = 'Accept booth'
%li= link_to link,
accept_admin_conference_booth_path(@conference.short_title, booth), accept_admin_conference_booth_path(@conference.short_title, booth),
method: :patch, id: "accept_booth_#{booth.id}" method: :patch ,id: "accept_booth_#{booth.id}"
- if booth.transition_possible? :reject - if booth.transition_possible? :reject
%li= link_to 'Reject booth', - if @conference.email_settings.send_on_booths_rejection
- link = 'Reject with email'
- else
- link = 'Reject'
%li= link_to link,
reject_admin_conference_booth_path(@conference.short_title, booth), reject_admin_conference_booth_path(@conference.short_title, booth),
method: :patch, confirm: 'Are you sure?', id: "reject_booth_#{booth.id}" method: :patch, id: "reject_booth_#{booth.id}"
- if booth.transition_possible? :to_reject - if booth.transition_possible? :to_reject
%li= link_to 'To reject booth', %li= link_to 'To reject booth',
to_reject_admin_conference_booth_path(@conference.short_title, booth), to_reject_admin_conference_booth_path(@conference.short_title, booth),
method: :patch, confirm: 'Are you sure?', id: "to_reject_booth_#{booth.id}" method: :patch, id: "to_reject_booth_#{booth.id}"
- if booth.transition_possible? :restart - if booth.transition_possible? :restart
%li= link_to 'Start review', %li= link_to 'Start review',

View file

@ -55,4 +55,10 @@
%tr %tr
%td {conference_splash_link} %td {conference_splash_link}
%td The link to conference splash page %td The link to conference splash page
- if @conference.booths
%tr
%td {submitter_name}
%td Submitter's name
%tr
%td {booth_title}
%td Booth's title

View file

@ -14,6 +14,8 @@
%a{ 'aria-controls' => 'notifications', 'data-toggle' => 'tab', href: '#notifications', role: 'tab' } Update Notifications %a{ 'aria-controls' => 'notifications', 'data-toggle' => 'tab', href: '#notifications', role: 'tab' } Update Notifications
%li{ role: 'presentation' } %li{ role: 'presentation' }
%a{ 'aria-controls' => 'cfp', 'data-toggle' => 'tab', href: '#cfp', role: 'tab' } Call for Papers %a{ 'aria-controls' => 'cfp', 'data-toggle' => 'tab', href: '#cfp', role: 'tab' } Call for Papers
%li{ role: 'presentation' }
%a{ 'aria-controls' => 'booths', 'data-toggle' => 'tab', href: '#booth', role: 'tab' } Booth
/ Tab panes / Tab panes
.tab-content .tab-content
#onboarding.tab-pane.active{ role: 'tabpanel' } #onboarding.tab-pane.active{ role: 'tabpanel' }
@ -100,6 +102,26 @@
'data-body-text' => "Dear {name},\n\nThe Conference Call for Papers Details of {conference} has changed.\nNew Dates : {cfp_start_date} - {cfp_end_date}.\n Link to Schedule {schedule_link} \n\nBest wishes\n\n{conference} Team" } Load Template 'data-body-text' => "Dear {name},\n\nThe Conference Call for Papers Details of {conference} has changed.\nNew Dates : {cfp_start_date} - {cfp_end_date}.\n Link to Schedule {schedule_link} \n\nBest wishes\n\n{conference} Team" } Load Template
%a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'updated_cfp_help' } Show Help %a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'updated_cfp_help' } Show Help
= render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false} = render partial: 'help', locals: {id: 'updated_cfp_help', show_event_variables: false}
#booth.tab-pane{ role: 'tabpanel' }
= f.input :send_on_booths_acceptance
= f.input :booths_acceptance_subject
= f.input :booths_acceptance_body, input_html: { rows:10, cols: 20 }
%a.btn.btn-link.control_label.load_template{ 'data-subject-input-id' => 'email_settings_booths_acceptance_subject',
'data-subject-text' => 'Your booth has been accepted!',
'data-body-input-id' => 'email_settings_booths_acceptance_body',
'data-body-text' => "Dear {name},\n\nWe are really pleased to inform you that your booth request {booth_title} has been accepted for the conference {conference}.\nPlease click the confirm button to let us know you can make it as soon as possible!\n\nFeel free to contact us with any questions or concerns.\n\nWe look forward to seeing you there.\n\nBest wishes\n\n{conference} Team"} Load Template
%a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'booth_acceptance_help' } Show help
= render partial: 'help', locals: {id: 'booth_acceptance_help', show_event_variables: false}
= f.input :send_on_booths_rejection
= f.input :booths_rejection_subject
= f.input :booths_rejection_body, input_html: { rows:10, cols:20 }
%a.btn.btn-link.control_label.load_template{ 'data-subject-input-id' => 'email_settings_booths_rejection_subject',
'data-subject-text' => 'Your booth request has been rejected',
'data-body-input-id' => 'email_settings_booths_rejection_body',
'data-body-text' => "Dear {name},\n\nThank you for your booth request {booth_title} for the conference {conference}.\n\nUnfortunately, we are sorry to inform you that your request has been rejected.\n\n\nBest wishes\n\n{conference} Team" } Load Template
%a.btn.btn-link.control_label.template_help_link{ 'data-name' => 'booth_rejection_help' } Show help
= render partial: 'help', locals: {id: 'booth_rejection_help', show_event_variables: false}
.row .row
.col-md-12 .col-md-12
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,10 @@
class AddBoothsToEmailSettings < ActiveRecord::Migration
def change
add_column :email_settings, :send_on_booths_acceptance, :boolean, default: false
add_column :email_settings, :booths_acceptance_subject, :string
add_column :email_settings, :booths_acceptance_body, :text
add_column :email_settings, :send_on_booths_rejection, :boolean, default: false
add_column :email_settings, :booths_rejection_subject, :string
add_column :email_settings, :booths_rejection_body, :text
end
end

View file

@ -205,6 +205,12 @@ ActiveRecord::Schema.define(version: 20170807092805) do
t.string "cfp_dates_updated_subject" t.string "cfp_dates_updated_subject"
t.text "program_schedule_public_body" t.text "program_schedule_public_body"
t.text "cfp_dates_updated_body" t.text "cfp_dates_updated_body"
t.boolean "send_on_booths_acceptance", default: false
t.string "booths_acceptance_subject"
t.text "booths_acceptance_body"
t.boolean "send_on_booths_rejection", default: false
t.string "booths_rejection_subject"
t.text "booths_rejection_body"
end end
create_table "event_schedules", force: :cascade do |t| create_table "event_schedules", force: :cascade do |t|