Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update API - notifications.json #5288

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/helpers/notifications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
{ controller: 'evaluations', action: 'overview', id: notification.notifiable_id } if notification.notifiable_type == 'Evaluation'
end

def notifiable_url(notification)
def notifiable_path(notification)
return exports_path(highlighted: notification.notifiable_id) if notification.notifiable_type == 'Export'
return submission_path(notification.notifiable_id, anchor: 'code') if notification.notifiable_type == 'Submission'

overview_evaluation_path(notification.notifiable_id) if notification.notifiable_type == 'Evaluation'
end

def notifiable_url(notification)
return exports_url(highlighted: notification.notifiable_id, format: :json) if notification.notifiable_type == 'Export'
return submission_url(notification.notifiable_id, anchor: 'code', format: :json) if notification.notifiable_type == 'Submission'

Check warning on line 18 in app/helpers/notifications_helper.rb

View check run for this annotation

Codecov / codecov/patch

app/helpers/notifications_helper.rb#L18

Added line #L18 was not covered by tests

overview_evaluation_url(notification.notifiable_id, format: :json) if notification.notifiable_type == 'Evaluation'

Check warning on line 20 in app/helpers/notifications_helper.rb

View check run for this annotation

Codecov / codecov/patch

app/helpers/notifications_helper.rb#L20

Added line #L20 was not covered by tests
end

def notifiable_icon(notification)
return 'mdi-file-download-outline' if notification.notifiable_type == 'Export'
return 'mdi-comment-account-outline' if notification.notifiable_type == 'Submission'
Expand Down
1 change: 1 addition & 0 deletions app/views/notifications/_notification.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
json.extract! notification, :id, :message, :read, :created_at, :updated_at
json.url notification_url(notification, format: :json)
json.notifiable_path notifiable_path(notification)
json.notifiable_url notifiable_url(notification)
4 changes: 2 additions & 2 deletions app/views/notifications/_notifications_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<i class="mdi <%= notifiable_icon(n) %>"></i>
</td>
<td>
<a class="notification-link" href="<%= notifiable_url n %>"><%= t n.message %></a>
<a class="notification-link" href="<%= notifiable_path n %>"><%= t n.message %></a>
</td>
<td>
<span><%= t 'notifications.index.created', when: time_ago_in_words(n.created_at) %></span>
Expand All @@ -32,7 +32,7 @@
<script>
dodona.ready.then(() => {
<% notifications.each do |n| %>
new dodona.Notification(<%= n.id %>, "<%= notification_path(n, format: :json) %>", <%= n.read %>, "<%= notifiable_url(n) %>", false, dodona.dotManager);
new dodona.Notification(<%= n.id %>, "<%= notification_path(n, format: :json) %>", <%= n.read %>, "<%= notifiable_path(n) %>", false, dodona.dotManager);
<% end %>
})
</script>
Expand Down
4 changes: 2 additions & 2 deletions app/views/notifications/_small_notifications_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<i class="mdi mdi-48 <%= notifiable_icon(n) %>" ></i>
</td>
<td>
<a class="notification-link" href="<%= notifiable_url n %>"><%= t n.message %></a>
<a class="notification-link" href="<%= notifiable_path n %>"><%= t n.message %></a>
<div class="text-muted">
<small>
<span><%= t 'notifications.index.created', when: time_ago_in_words(n.created_at) %></span>
Expand All @@ -30,7 +30,7 @@
<script>
dodona.ready.then(() => {
<% notifications.each do |n| %>
new dodona.Notification(<%= n.id %>, "<%= notification_path(n, format: :json) %>", <%= n.read %>, "<%= notifiable_url(n) %>", true, dodona.dotManager);
new dodona.Notification(<%= n.id %>, "<%= notification_path(n, format: :json) %>", <%= n.read %>, "<%= notifiable_path(n) %>", true, dodona.dotManager);
<% end %>
})
</script>
Expand Down