more admin permissions

This commit is contained in:
byte[] 2019-12-25 16:10:56 -05:00
parent 481e29fd50
commit 37836b2c30
4 changed files with 9 additions and 6 deletions

View file

@ -102,7 +102,8 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
def can?(%User{role: "moderator"}, :edit, %Tag{}), do: true def can?(%User{role: "moderator"}, :edit, %Tag{}), do: true
# Award badges # 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 # Create mod notes
def can?(%User{role: "moderator"}, :index, ModNote), do: true 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 def can?(%User{role: "moderator", role_map: %{"SiteNotice" => "admin"}}, _action, %SiteNotice{}), do: true
# Manage badges # 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
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

View file

@ -20,7 +20,7 @@ defmodule PhilomenaWeb.ProfileController do
import Ecto.Query import Ecto.Query
plug :load_and_authorize_resource, model: User, only: :show, id_field: "slug", preload: [ 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_admin_metadata
plug :set_mod_notes plug :set_mod_notes

View file

@ -28,6 +28,8 @@ h2 Badges
= badge_image(badge, width: 32, height: 32) = badge_image(badge, width: 32, height: 32)
td td
=> link "Users", to: Routes.admin_badge_user_path(@conn, :index, badge)
' •
= link "Edit", to: Routes.admin_badge_path(@conn, :edit, badge) = link "Edit", to: Routes.admin_badge_path(@conn, :edit, badge)
.block__header.block__header--light .block__header.block__header--light

View file

@ -54,7 +54,7 @@
= render PhilomenaWeb.ProfileView, "_commission.html", user: @user, commission_information: @commission_information, conn: @conn = render PhilomenaWeb.ProfileView, "_commission.html", user: @user, commission_information: @commission_information, conn: @conn
.block .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 a.block__header--single-item href=Routes.profile_user_link_path(@conn, :new, @user) User Links
- else - else
.block__header .block__header
@ -92,7 +92,9 @@
br br
= award_title(award) = award_title(award)
.flex__grow.center .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 = if manages_awards?(@conn) do
.flex__grow.center .flex__grow.center