Skip to content

Commit

Permalink
fix(fworks): fix internal server error for activity log page
Browse files Browse the repository at this point in the history
  • Loading branch information
serenaabbott11 committed Jul 9, 2024
1 parent 9f0aa41 commit 2cbeadd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/frameworks/activity_log_item.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Frameworks::ActivityLogItem < ApplicationRecord
include Presentable

belongs_to :actor, polymorphic: true, optional: true
belongs_to :subject, polymorphic: true, optional: true
delegated_type :activity, types: %w[Frameworks::ActivityLoggableVersion Frameworks::ActivityEvent]
Expand Down
15 changes: 15 additions & 0 deletions app/models/frameworks/activity_log_item/presentable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Frameworks::ActivityLogItem::Presentable
extend ActiveSupport::Concern

def display_subject
"#{subject.try(:activity_log_display_type)} #{subject.try(:reference)}"
end

def display_created_at
created_at.strftime("%d %B %Y at %H:%M:%S")
end

def display_actor
actor.try(:full_name)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ def activity_log_display_name
def activity_log_display_short_name
try(:short_name) || try(:reference)
end

def activity_log_display_type
self.class.to_s.demodulize.underscore.humanize
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<td class="govuk-table__cell"><code><%= activity_log_item.guid %></code></td>
<td class="govuk-table__cell"><%= activity_log_item.display_created_at %></td>
<td class="govuk-table__cell"><%= activity_log_item.display_actor %></td>
<td class="govuk-table__cell"><%= link_to activity_log_item.display_subject, activity_log_item.subject, class: "govuk-link" %> - <%= render activity_log_item %></td>
<td class="govuk-table__cell"><%= link_to activity_log_item.display_subject, activity_log_item.subject, class: "govuk-link" %> - <%= activity_log_item.event_description %></td>
</tr>
<% end %>
</tbody>
Expand Down

0 comments on commit 2cbeadd

Please sign in to comment.