-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
213 changed files
with
23 additions
and
37,615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,2 @@ | ||
class Form::SupportLettersController < Form::BaseController | ||
before_action :load_letter, only: :destroy | ||
|
||
def create | ||
@support_letter = @form_answer.support_letters.new( | ||
support_letter_params.merge( | ||
user_id: current_user.id, | ||
manual: true, | ||
), | ||
) | ||
|
||
attachment = SupportLetterAttachment.new(attachment_params) | ||
attachment.user = current_user | ||
attachment.form_answer = @form_answer | ||
attachment.original_filename = attachment_params[:attachment].try(:original_filename) | ||
@support_letter.support_letter_attachment = attachment | ||
|
||
if @support_letter.save | ||
add_support_letter_to_document! | ||
@form_answer.save | ||
|
||
redirect_to form_form_answer_supporters_path(@form_answer) | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def new | ||
@support_letter = @form_answer.support_letters.new | ||
end | ||
|
||
def destroy | ||
if @support_letter.destroy | ||
remove_support_letter_from_document! | ||
@form_answer.save | ||
end | ||
|
||
redirect_to form_form_answer_supporters_path(@form_answer) | ||
end | ||
|
||
private | ||
|
||
def support_letter_params | ||
params[:support_letter].permit( | ||
:first_name, | ||
:last_name, | ||
:relationship_to_nominee, | ||
) | ||
end | ||
|
||
def attachment_params | ||
if params[:support_letter] && params[:support_letter][:support_letter_attachment] | ||
params[:support_letter][:support_letter_attachment].permit(:attachment) | ||
else | ||
{} | ||
end | ||
end | ||
|
||
def load_letter | ||
@support_letter = @form_answer.support_letters.find(params[:id]) | ||
end | ||
|
||
def add_support_letter_to_document! | ||
letters = support_letters_doc | ||
|
||
new_letter = { | ||
support_letter_id: @support_letter.id, | ||
first_name: @support_letter.first_name, | ||
last_name: @support_letter.last_name, | ||
relationship_to_nominee: @support_letter.relationship_to_nominee, | ||
letter_of_support: @support_letter.support_letter_attachment.id, | ||
} | ||
|
||
letters << new_letter | ||
|
||
@form_answer.document = @form_answer.document.merge(supporter_letters_list: letters, | ||
manually_upload: "yes",) | ||
end | ||
|
||
def remove_support_letter_from_document! | ||
letters = support_letters_doc | ||
|
||
letters.delete_if do |sup| | ||
sup["support_letter_id"] == @support_letter.id | ||
end | ||
|
||
@form_answer.document = @form_answer.document.merge(supporter_letters_list: letters) | ||
end | ||
|
||
def support_letters_doc | ||
@form_answer.document["supporter_letters_list"].presence || [] | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
app/mailers/account_mailers/promotion_letters_of_support_reminder_mailer.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
app/views/account_mailers/notify_non_shortlisted_mailer/ep_notify.text.erb
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
app/views/account_mailers/promotion_letters_of_support_reminder_mailer/notify.text.erb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.