Skip to content

Commit

Permalink
Simplify code in managers/moderators/admins tables
Browse files Browse the repository at this point in the history
Originally, the code was shared between the index action and the search
action, but since commit fb6dbdf that's no longer the case. So in the
index action we don't need to check whether a user is a
moderator/manager/admin or not; they all are.
  • Loading branch information
javierm committed Jun 15, 2020
1 parent b67602d commit 5c17591
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 42 deletions.
22 changes: 7 additions & 15 deletions app/views/admin/administrators/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,13 @@
<%= administrator.description %>
</td>
<td>
<% if administrator.persisted? %>
<%= link_to t("admin.actions.edit"),
edit_admin_administrator_path(administrator),
class: "button hollow" %>
<%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t("admin.administrators.administrator.add"),
{ controller: "admin/administrators", action: :create,
user_id: administrator.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
<%= link_to t("admin.actions.edit"),
edit_admin_administrator_path(administrator),
class: "button hollow" %>
<%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
Expand Down
18 changes: 4 additions & 14 deletions app/views/admin/managers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,10 @@
<%= manager.email %>
</td>
<td>
<% if manager.persisted? %>
<%= link_to t("admin.managers.manager.delete"),
admin_manager_path(manager),
method: :delete,
class: "button hollow alert expanded"
%>
<% else %>
<%= link_to t("admin.managers.manager.add"),
{ controller: "admin/managers",
action: :create,
user_id: manager.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
<%= link_to t("admin.managers.manager.delete"),
admin_manager_path(manager),
method: :delete,
class: "button hollow alert expanded" %>
</td>
</tr>
<% end %>
Expand Down
17 changes: 4 additions & 13 deletions app/views/admin/moderators/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,10 @@
<%= moderator.email %>
</td>
<td>
<% if moderator.persisted? %>
<%= link_to t("admin.moderators.moderator.delete"),
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded"
%>
<% else %>
<%= link_to t("admin.moderators.moderator.add"),
{ controller: "admin/moderators", action: :create,
user_id: moderator.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
<%= link_to t("admin.moderators.moderator.delete"),
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded" %>
</td>
</tr>
<% end %>
Expand Down

0 comments on commit 5c17591

Please sign in to comment.