Skip to content

Commit

Permalink
Use delegate to simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Oct 10, 2023
1 parent d033934 commit fa42957
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Comment < ApplicationRecord
scope(:in_past_week, -> { where("confirmed_at > ?", 7.days.ago) })

delegate :email, to: :user
delegate :comment_authority_with_fallback, to: :application

counter_culture :application,
column_name: proc { |comment| comment.visible? ? "visible_comments_count" : nil },
Expand Down
4 changes: 2 additions & 2 deletions app/views/_tailwind/comments/_delivery_status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<% component.with_summary { "Delivered to the planning authority" } %>
<%# TODO: Use more sensible time zone %>
This comment was successfully delivered to the email server of
<%= comment.application.comment_authority_with_fallback %>
<%= comment.comment_authority_with_fallback %>
on
<%= comment.last_delivered_at.utc.to_fs(:long) %> UTC
<% end %>
<% else %>
<%= render Tailwind::DisclosureComponent.new(size: "xl") do |component| %>
<% component.with_summary { "There was a problem delivering this to the planning authority" } %>
The comment was hard bounced by the email server of
<%= comment.application.comment_authority_with_fallback %>
<%= comment.comment_authority_with_fallback %>
on
<%= comment.last_delivered_at.utc.to_fs(:long) %> UTC
Please follow up by
Expand Down
4 changes: 2 additions & 2 deletions app/views/_tailwind/comments/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<div class="mt-4">
<%= render Tailwind::ButtonComponent.new(tag: :button, size: "2xl", type: :primary) do %>
Publish (and send to <%= @comment.application.comment_authority_with_fallback %>)
Publish (and send to <%= @comment.comment_authority_with_fallback %>)
<% end %>
</div>
</div>
Expand All @@ -37,7 +37,7 @@
<h2 class="text-3xl font-bold text-navy">Email preview</h2>

<p class="mt-8 text-2xl text-navy">
Your comment and details will also automatically be sent to <strong><%= @comment.application.comment_authority_with_fallback %></strong>.
Your comment and details will also automatically be sent to <strong><%= @comment.comment_authority_with_fallback %></strong>.
They may consider your submission when they decide whether to approve this application.
</p>
<p class="mt-4 text-2xl text-navy">
Expand Down
4 changes: 2 additions & 2 deletions app/views/comments/_comment.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
- elsif comment.last_delivered_successfully
This comment was successfully delivered to the
email server of
= comment.application.comment_authority_with_fallback
= comment.comment_authority_with_fallback
at
= comment.last_delivered_at
- else
The comment was hard bounced by the email server of
= comment.application.comment_authority_with_fallback
= comment.comment_authority_with_fallback
at
= comment.last_delivered_at
Please follow up by
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_confirmed.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.notice-comment-confirmed
%h1.page-title Thanks, your comment has been sent!
%p
Your comment has been sent to #{comment.application.comment_authority_with_fallback}
Your comment has been sent to #{comment.comment_authority_with_fallback}
and #{link_to "posted below", comment_path(comment)}.
= link_to "Share your comment on Facebook",
"https://www.facebook.com/sharer/sharer.php?u=#{comment_url(comment)}&t=",
Expand Down

0 comments on commit fa42957

Please sign in to comment.