From 37836b2c30d4dde624173954a4414bc04cfa83a2 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Wed, 25 Dec 2019 16:10:56 -0500 Subject: [PATCH] more admin permissions --- lib/philomena/users/ability.ex | 5 ++--- lib/philomena_web/controllers/profile_controller.ex | 2 +- lib/philomena_web/templates/admin/badge/index.html.slime | 2 ++ lib/philomena_web/templates/profile/show.html.slime | 6 ++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/philomena/users/ability.ex b/lib/philomena/users/ability.ex index 7d0b218b..5fd843c7 100644 --- a/lib/philomena/users/ability.ex +++ b/lib/philomena/users/ability.ex @@ -102,7 +102,8 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do def can?(%User{role: "moderator"}, :edit, %Tag{}), do: true # Award badges - def can?(%User{role: "moderator"}, :create, %Award{}), do: true + def can?(%User{role: "moderator"}, _action, %Award{}), do: true + def can?(%User{role: "moderator"}, _action, Award), do: true # Create mod notes def can?(%User{role: "moderator"}, :index, ModNote), do: true @@ -117,8 +118,6 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do def can?(%User{role: "moderator", role_map: %{"SiteNotice" => "admin"}}, _action, %SiteNotice{}), do: true # Manage badges - def can?(%User{role: "moderator", role_map: %{"Badge" => "admin"}}, _action, Award), do: true - def can?(%User{role: "moderator", role_map: %{"Badge" => "admin"}}, _action, %Award{}), do: true def can?(%User{role: "moderator", role_map: %{"Badge" => "admin"}}, _action, Badge), do: true def can?(%User{role: "moderator", role_map: %{"Badge" => "admin"}}, _action, %Badge{}), do: true diff --git a/lib/philomena_web/controllers/profile_controller.ex b/lib/philomena_web/controllers/profile_controller.ex index 60c5b2af..266eee04 100644 --- a/lib/philomena_web/controllers/profile_controller.ex +++ b/lib/philomena_web/controllers/profile_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.ProfileController do import Ecto.Query plug :load_and_authorize_resource, model: User, only: :show, id_field: "slug", preload: [ - awards: :badge, public_links: :tag, verified_links: :tag, commission: [sheet_image: :tags, items: [example_image: :tags]] + awards: [:badge, :awarded_by], public_links: :tag, verified_links: :tag, commission: [sheet_image: :tags, items: [example_image: :tags]] ] plug :set_admin_metadata plug :set_mod_notes diff --git a/lib/philomena_web/templates/admin/badge/index.html.slime b/lib/philomena_web/templates/admin/badge/index.html.slime index d7bce004..b46f6b71 100644 --- a/lib/philomena_web/templates/admin/badge/index.html.slime +++ b/lib/philomena_web/templates/admin/badge/index.html.slime @@ -28,6 +28,8 @@ h2 Badges = badge_image(badge, width: 32, height: 32) td + => link "Users", to: Routes.admin_badge_user_path(@conn, :index, badge) + ' • = link "Edit", to: Routes.admin_badge_path(@conn, :edit, badge) .block__header.block__header--light diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index dab90530..b843b097 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -54,7 +54,7 @@ = render PhilomenaWeb.ProfileView, "_commission.html", user: @user, commission_information: @commission_information, conn: @conn .block - = if current?(@user, @conn.assigns.current_user) do + = if current?(@user, @conn.assigns.current_user) or manages_links?(@conn, @user) do a.block__header--single-item href=Routes.profile_user_link_path(@conn, :new, @user) User Links - else .block__header @@ -92,7 +92,9 @@ br = award_title(award) .flex__grow.center - = pretty_time(award.awarded_on) + => pretty_time(award.awarded_on) + = if manages_awards?(@conn) do + = user_abbrv(@conn, award.awarded_by) = if manages_awards?(@conn) do .flex__grow.center