fix staff buttons

This commit is contained in:
byte[] 2019-12-14 15:15:35 -05:00
parent e5266db21e
commit 2eb39b43aa
5 changed files with 57 additions and 25 deletions

View file

@ -113,7 +113,7 @@ defmodule Philomena.DnpEntries do
end end
def count_dnp_entries(user) do def count_dnp_entries(user) do
if Canada.Can.can?(user, :manage, DnpEntry) do if Canada.Can.can?(user, :index, DnpEntry) do
DnpEntry DnpEntry
|> where([dnp], dnp.aasm_state in ["requested", "claimed", "acknowledged"]) |> where([dnp], dnp.aasm_state in ["requested", "claimed", "acknowledged"])
|> Repo.aggregate(:count, :id) |> Repo.aggregate(:count, :id)

View file

@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do
|> order_by(desc: :start_date) |> order_by(desc: :start_date)
|> Repo.paginate(conn.assigns.scrivener) |> Repo.paginate(conn.assigns.scrivener)
render(conn, "index.html", site_notices: site_notices) render(conn, "index.html", admin_site_notices: site_notices)
end end
def new(conn, _params) do def new(conn, _params) do

View file

@ -1,7 +1,7 @@
h1 Site Notices h1 Site Notices
- route = fn p -> Routes.admin_site_notice_path(@conn, :index, p) end - 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
.block__header .block__header
@ -21,7 +21,7 @@ h1 Site Notices
th Live? th Live?
th Options th Options
tbody tbody
= for site_notice <- @site_notices do = for site_notice <- @admin_site_notices do
tr tr
td td
em = site_notice.title em = site_notice.title

View file

@ -1,85 +1,90 @@
/ Dummy view for the admin bar / Dummy view for the admin bar
.flex.flex--centered.header--secondary__admin-links.stretched-mobile-links.js-staff-action .flex.flex--centered.header--secondary__admin-links.stretched-mobile-links.js-staff-action
.dropdown.hide-mobile .dropdown.hide-mobile
/a.header__link title="Admin" a.header__link title="Admin"
' A ' A
i.fa.fa-caret-down i.fa.fa-caret-down
.dropdown__content.js-burger-links .dropdown__content.js-burger-links
/ todo: make some sort of permission for this = if manages_site_notices?(@conn) do
= 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
= link to: "/admin/site_notices", class: "header__link" do = link to: "/admin/site_notices", class: "header__link" do
i.fa.fa-fw.fa-info-circle> i.fa.fa-fw.fa-info-circle>
' Site Notices ' Site Notices
= if can?(@conn, :manage, Tag) do
= if manages_tags?(@conn) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-tags> i.fa.fa-fw.fa-tags>
' Tags ' Tags
= if can?(@conn, :mod_read, User) do
= if manages_users?(@conn) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-users> i.fa.fa-fw.fa-users>
' Users ' Users
= if can?(@conn, :mod_read, Comment) do
= link to: "#", class: "header__link" do = if manages_forums?(@conn) do
i.fa.fa-fw.fa-comments>
' Comments
= if can?(@conn, :mod_read, Forum) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-paragraph> i.fa.fa-fw.fa-paragraph>
' Forums ' Forums
= if can?(@conn, :manage, Advert) do
= if manages_ads?(@conn) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-shopping-bag> i.fa.fa-fw.fa-shopping-bag>
' Advertisements ' Advertisements
= if can?(@conn, :award, Badge) do
= if manages_badges?(@conn) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-trophy> i.fa.fa-fw.fa-trophy>
' Badges ' Badges
= if can?(@conn, :manage, StaticPage) do
= if manages_static_pages?(@conn) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-sticky-note> i.fa.fa-fw.fa-sticky-note>
' Pages ' Pages
= if can?(@conn, :manage, ModNote) do
= if manages_mod_notes?(@conn) do
= link to: "#", class: "header__link" do = link to: "#", class: "header__link" do
i.fa.fa-fw.fa-sticky-note> i.fa.fa-fw.fa-sticky-note>
' Mod Notes ' Mod Notes
= if @duplicate_report_count do = if @duplicate_report_count do
= link to: Routes.duplicate_report_path(@conn, :index), class: "header__link", title: "Duplicates" do = link to: Routes.duplicate_report_path(@conn, :index), class: "header__link", title: "Duplicates" do
' D ' D
span.header__counter__admin span.header__counter__admin
= @duplicate_report_count = @duplicate_report_count
= if @report_count do = if @report_count do
= link to: Routes.admin_report_path(@conn, :index), class: "header__link", title: "Reports" do = link to: Routes.admin_report_path(@conn, :index), class: "header__link", title: "Reports" do
' R ' R
span.header__counter__admin span.header__counter__admin
= @report_count = @report_count
= if @user_link_count do = if @user_link_count do
= link to: Routes.admin_user_link_path(@conn, :index), class: "header__link", title: "User Links" do = link to: Routes.admin_user_link_path(@conn, :index), class: "header__link", title: "User Links" do
' L ' L
span.header__counter__admin span.header__counter__admin
= @user_link_count = @user_link_count
= if @dnp_entry_count do = if @dnp_entry_count do
= link to: Routes.admin_dnp_entry_path(@conn, :index), class: "header__link", title: "DNP Requests" do = link to: Routes.admin_dnp_entry_path(@conn, :index), class: "header__link", title: "DNP Requests" do
' S ' S
span.header__counter__admin span.header__counter__admin
= @dnp_entry_count = @dnp_entry_count
.dropdown.hide-mobile .dropdown.hide-mobile
a.header__link title="Bans" a.header__link title="Bans"
' B ' B
i.fa.fa-caret-down i.fa.fa-caret-down
.dropdown__content.dropdown__content-right.js-burger-links .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 = link to: Routes.admin_user_ban_path(@conn, :index), class: "header__link" do
i.fa.fa-fw.fa-user> i.fa.fa-fw.fa-user>
' User Bans ' User Bans
= if can?(@conn, :index, SubnetBan) do
= link to: Routes.admin_subnet_ban_path(@conn, :index), class: "header__link" do = link to: Routes.admin_subnet_ban_path(@conn, :index), class: "header__link" do
i.fab.fa-fw.fa-internet-explorer> i.fab.fa-fw.fa-internet-explorer>
' IP Bans ' IP Bans
= if can?(@conn, :index, FingerprintBan) do
= link to: Routes.admin_fingerprint_ban_path(@conn, :index), class: "header__link" do = link to: Routes.admin_fingerprint_ban_path(@conn, :index), class: "header__link" do
i.fa.fa-fw.fa-desktop> i.fa.fa-fw.fa-desktop>
' FP Bans ' FP Bans

View file

@ -79,4 +79,31 @@ defmodule PhilomenaWeb.LayoutView do
def opengraph?(conn), def opengraph?(conn),
do: !is_nil(conn.assigns[:image]) and conn.assigns.image.__meta__.state == :loaded and is_list(conn.assigns.image.tags) 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 end