mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
fix staff buttons
This commit is contained in:
parent
e5266db21e
commit
2eb39b43aa
5 changed files with 57 additions and 25 deletions
|
@ -113,7 +113,7 @@ defmodule Philomena.DnpEntries do
|
|||
end
|
||||
|
||||
def count_dnp_entries(user) do
|
||||
if Canada.Can.can?(user, :manage, DnpEntry) do
|
||||
if Canada.Can.can?(user, :index, DnpEntry) do
|
||||
DnpEntry
|
||||
|> where([dnp], dnp.aasm_state in ["requested", "claimed", "acknowledged"])
|
||||
|> Repo.aggregate(:count, :id)
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do
|
|||
|> order_by(desc: :start_date)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
render(conn, "index.html", site_notices: site_notices)
|
||||
render(conn, "index.html", admin_site_notices: site_notices)
|
||||
end
|
||||
|
||||
def new(conn, _params) do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
h1 Site Notices
|
||||
|
||||
- route = fn p -> Routes.admin_site_notice_path(@conn, :index, p) end
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @site_notices, route: route, conn: @conn
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @admin_site_notices, route: route, conn: @conn
|
||||
|
||||
.block
|
||||
.block__header
|
||||
|
@ -21,7 +21,7 @@ h1 Site Notices
|
|||
th Live?
|
||||
th Options
|
||||
tbody
|
||||
= for site_notice <- @site_notices do
|
||||
= for site_notice <- @admin_site_notices do
|
||||
tr
|
||||
td
|
||||
em = site_notice.title
|
||||
|
|
|
@ -1,85 +1,90 @@
|
|||
/ Dummy view for the admin bar
|
||||
.flex.flex--centered.header--secondary__admin-links.stretched-mobile-links.js-staff-action
|
||||
.dropdown.hide-mobile
|
||||
/a.header__link title="Admin"
|
||||
a.header__link title="Admin"
|
||||
' A
|
||||
i.fa.fa-caret-down
|
||||
|
||||
.dropdown__content.js-burger-links
|
||||
/ todo: make some sort of permission for this
|
||||
= if @current_user.role == "admin" do
|
||||
= link to: "/admin/flipper", class: "header__link" do
|
||||
i.fa.fa-fw.fa-toggle-on>
|
||||
' Site Settings
|
||||
= if can?(@conn, :manage, SiteNotice) do
|
||||
= if manages_site_notices?(@conn) do
|
||||
= link to: "/admin/site_notices", class: "header__link" do
|
||||
i.fa.fa-fw.fa-info-circle>
|
||||
' Site Notices
|
||||
= if can?(@conn, :manage, Tag) do
|
||||
|
||||
= if manages_tags?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-tags>
|
||||
' Tags
|
||||
= if can?(@conn, :mod_read, User) do
|
||||
|
||||
= if manages_users?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-users>
|
||||
' Users
|
||||
= if can?(@conn, :mod_read, Comment) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-comments>
|
||||
' Comments
|
||||
= if can?(@conn, :mod_read, Forum) do
|
||||
|
||||
= if manages_forums?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-paragraph>
|
||||
' Forums
|
||||
= if can?(@conn, :manage, Advert) do
|
||||
|
||||
= if manages_ads?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-shopping-bag>
|
||||
' Advertisements
|
||||
= if can?(@conn, :award, Badge) do
|
||||
|
||||
= if manages_badges?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-trophy>
|
||||
' Badges
|
||||
= if can?(@conn, :manage, StaticPage) do
|
||||
|
||||
= if manages_static_pages?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-sticky-note>
|
||||
' Pages
|
||||
= if can?(@conn, :manage, ModNote) do
|
||||
|
||||
= if manages_mod_notes?(@conn) do
|
||||
= link to: "#", class: "header__link" do
|
||||
i.fa.fa-fw.fa-sticky-note>
|
||||
' Mod Notes
|
||||
|
||||
= if @duplicate_report_count do
|
||||
= link to: Routes.duplicate_report_path(@conn, :index), class: "header__link", title: "Duplicates" do
|
||||
' D
|
||||
span.header__counter__admin
|
||||
= @duplicate_report_count
|
||||
|
||||
= if @report_count do
|
||||
= link to: Routes.admin_report_path(@conn, :index), class: "header__link", title: "Reports" do
|
||||
' R
|
||||
span.header__counter__admin
|
||||
= @report_count
|
||||
|
||||
= if @user_link_count do
|
||||
= link to: Routes.admin_user_link_path(@conn, :index), class: "header__link", title: "User Links" do
|
||||
' L
|
||||
span.header__counter__admin
|
||||
= @user_link_count
|
||||
|
||||
= if @dnp_entry_count do
|
||||
= link to: Routes.admin_dnp_entry_path(@conn, :index), class: "header__link", title: "DNP Requests" do
|
||||
' S
|
||||
span.header__counter__admin
|
||||
= @dnp_entry_count
|
||||
|
||||
.dropdown.hide-mobile
|
||||
a.header__link title="Bans"
|
||||
' B
|
||||
i.fa.fa-caret-down
|
||||
|
||||
.dropdown__content.dropdown__content-right.js-burger-links
|
||||
= if can?(@conn, :index, UserBan) do
|
||||
= if manages_bans?(@conn) do
|
||||
= link to: Routes.admin_user_ban_path(@conn, :index), class: "header__link" do
|
||||
i.fa.fa-fw.fa-user>
|
||||
' User Bans
|
||||
= if can?(@conn, :index, SubnetBan) do
|
||||
|
||||
= link to: Routes.admin_subnet_ban_path(@conn, :index), class: "header__link" do
|
||||
i.fab.fa-fw.fa-internet-explorer>
|
||||
' IP Bans
|
||||
= if can?(@conn, :index, FingerprintBan) do
|
||||
|
||||
= link to: Routes.admin_fingerprint_ban_path(@conn, :index), class: "header__link" do
|
||||
i.fa.fa-fw.fa-desktop>
|
||||
' FP Bans
|
||||
|
|
|
@ -79,4 +79,31 @@ defmodule PhilomenaWeb.LayoutView do
|
|||
|
||||
def opengraph?(conn),
|
||||
do: !is_nil(conn.assigns[:image]) and conn.assigns.image.__meta__.state == :loaded and is_list(conn.assigns.image.tags)
|
||||
|
||||
def manages_site_notices?(conn),
|
||||
do: can?(conn, :index, Philomena.SiteNotices.SiteNotice)
|
||||
|
||||
def manages_tags?(conn),
|
||||
do: can?(conn, :index, Philomena.Tags.Tag)
|
||||
|
||||
def manages_users?(conn),
|
||||
do: can?(conn, :index, Philomena.Users.User)
|
||||
|
||||
def manages_forums?(conn),
|
||||
do: conn.assigns.current_user.role == "admin"
|
||||
|
||||
def manages_ads?(conn),
|
||||
do: conn.assigns.current_user.role == "admin"
|
||||
|
||||
def manages_badges?(conn),
|
||||
do: can?(conn, :index, Philomena.Badges.Badge)
|
||||
|
||||
def manages_static_pages?(conn),
|
||||
do: conn.assigns.current_user.role == "admin"
|
||||
|
||||
def manages_mod_notes?(conn),
|
||||
do: conn.assigns.current_user.role in ["admin", "moderator"]
|
||||
|
||||
def manages_bans?(conn),
|
||||
do: conn.assigns.current_user.role in ["admin", "moderator"]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue