Skip to content

Commit

Permalink
Merge pull request #29 from cs169/187044290-reason-to-denial-reason
Browse files Browse the repository at this point in the history
reason to denial reason
  • Loading branch information
ArushC authored Feb 20, 2024
2 parents 0f79f52 + 092cce2 commit 2ee19ed
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def page_params
# teacher_snap: @teacher.snap,
# teacher_school_website: @teacher.school.website,
# piazza_password: Rails.application.secrets[:piazza_password],
# reason: @reason
# denial_reason: @denial_reason
# }.with_indifferent_access
# end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/teachers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def update
def request_info
@teacher.info_needed!
if !params[:skip_email].present?
TeacherMailer.request_info_email(@teacher, params[:reason]).deliver_now
TeacherMailer.request_info_email(@teacher, params[:denial_reason]).deliver_now
end
redirect_to root_path
end
Expand All @@ -146,7 +146,7 @@ def deny
@teacher.denied!
if !params[:skip_email].present?
# TODO: Update dropdown to select the email template.
TeacherMailer.deny_email(@teacher, params[:reason]).deliver_now
TeacherMailer.deny_email(@teacher, params[:denial_reason]).deliver_now
end
redirect_to root_path
end
Expand Down
10 changes: 5 additions & 5 deletions app/mailers/teacher_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ def welcome_email(teacher)
subject: email_template.subject
end

def deny_email(teacher, reason)
def deny_email(teacher, denial_reason)
@teacher = teacher
@reason = reason
@denial_reason = denial_reason
set_body
mail to: @teacher.email_name,
cc: CONTACT_EMAIL,
subject: email_template.subject
end

def request_info_email(teacher, reason)
def request_info_email(teacher, request_reason)
@teacher = teacher
@reason = reason
@request_reason = request_reason
set_body
mail to: @teacher.email_name,
cc: CONTACT_EMAIL,
Expand All @@ -48,7 +48,7 @@ def liquid_assigns
base_rules = {
bjc_password: Rails.application.secrets[:bjc_password],
piazza_password: Rails.application.secrets[:piazza_password],
reason: @reason
denial_reason: @denial_reason
}
base_rules.merge!(@teacher.email_attributes)
base_rules.with_indifferent_access
Expand Down
2 changes: 1 addition & 1 deletion app/views/email_templates/_liquid_fields.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<td>(The current piazza sign up password)</td>
</tr>
<tr>
<td><code>{{reason}}</code></td>
<td><code>{{denial_reason}}</code></td>
<td>(Only on denial emails.)</td>
</tr>
</tbody>
Expand Down
6 changes: 3 additions & 3 deletions app/views/main/_deny_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</div>
<%= form_tag deny_teacher_path(0), method: :post, class: "form-horizontal" do %>
<div class="modal-body">
<%= label_tag 'reason', 'Reason', class: 'control-label' %>
<%= text_field_tag :reason, params[:reason], class: "form-control" %>
<%= label_tag 'denial_reason', 'Reason', class: 'control-label' %>
<%= text_field_tag :denial_reason, params[:denial_reason], class: "form-control" %>
<!-- <div class="form-group">
<label for="reason-select">Reason for Denial (Select)</label>
<select id="reason-select" name="reason-select" class="form-control">
Expand Down Expand Up @@ -57,7 +57,7 @@
modal.find('.modal-title').text(newTitle);
});
modal.on('hidden.bs.modal', function () {
$('input[name="reason"]').val('');
$('input[name="denial_reason"]').val('');
modal.find('.modal-title').text('');
});
</script>
4 changes: 2 additions & 2 deletions db/seed_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module SeedData

@basic_email_with_reason = <<-DENY_EMAIL
<p>
{{ reason | strip_tags }}
{{ denial_reason | strip_tags }}
</p>
DENY_EMAIL

Expand All @@ -38,7 +38,7 @@ module SeedData
<p>[Your Name]</p>
<p>Below, you can find the reason as to why it was rejected </p>
<p>
{{ reason | strip_tags}}
{{ denial_reason | strip_tags}}
</p>
DENY_EMAIL1

Expand Down
6 changes: 3 additions & 3 deletions features/admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ Scenario: Deny teacher as an admin
And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)"
Then I should see "Reason"
And I should see "Deny Joseph Mamoa"
And I fill in "reason" with "Test"
And I fill in "denial_reason" with "Test"
And I press "Cancel"
And I press "❌" within "#DataTables_Table_0 > tbody > tr:nth-child(1)"
Then the "reason" field should not contain "Test"
And I fill in "reason" with "Denial Reason"
Then the "denial_reason" field should not contain "Test"
And I fill in "denial_reason" with "Denial Reason"
And I press "Submit"
Then I can send a deny email

Expand Down

0 comments on commit 2ee19ed

Please sign in to comment.