mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
additional pagination fixes (fixes philomena-dev/philomena#117)
This commit is contained in:
parent
80d3cb5cd1
commit
952d7bca4f
7 changed files with 29 additions and 42 deletions
|
@ -1,7 +1,7 @@
|
|||
h1 Fingerprint Bans
|
||||
|
||||
- route = fn p -> Routes.admin_fingerprint_ban_path(@conn, :index, p) end
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @fingerprint_bans, route: route, params: [q: @conn.params["q"]]
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @fingerprint_bans, route: route, params: page_params(@conn.params)
|
||||
|
||||
= form_for :fingerprint_ban, Routes.admin_fingerprint_ban_path(@conn, :index), [method: "get", class: "hform"], fn f ->
|
||||
.field
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
h1 Subnet Bans
|
||||
|
||||
- route = fn p -> Routes.admin_subnet_ban_path(@conn, :index, p) end
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @subnet_bans, route: route, params: [q: @conn.params["q"]]
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @subnet_bans, route: route, params: page_params(@conn.params)
|
||||
|
||||
= form_for :subnet_ban, Routes.admin_subnet_ban_path(@conn, :index), [method: "get", class: "hform"], fn f ->
|
||||
.field
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
h1 User Bans
|
||||
|
||||
- route = fn p -> Routes.admin_user_ban_path(@conn, :index, p) end
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @user_bans, route: route, params: [q: @conn.params["q"]]
|
||||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @user_bans, route: route, params: page_params(@conn.params)
|
||||
|
||||
= form_for :user_ban, Routes.admin_user_ban_path(@conn, :index), [method: "get", class: "hform"], fn f ->
|
||||
.field
|
||||
|
|
23
lib/philomena_web/views/admin/ban_view.ex
Normal file
23
lib/philomena_web/views/admin/ban_view.ex
Normal file
|
@ -0,0 +1,23 @@
|
|||
defmodule PhilomenaWeb.Admin.BanView do
|
||||
alias PhilomenaWeb.ProfileView
|
||||
|
||||
def user_abbrv(conn, user),
|
||||
do: ProfileView.user_abbrv(conn, user)
|
||||
|
||||
def ban_row_class(%{valid_until: until, enabled: enabled}) do
|
||||
now = DateTime.utc_now()
|
||||
|
||||
case enabled and DateTime.diff(until, now) > 0 do
|
||||
true -> "success"
|
||||
_false -> "danger"
|
||||
end
|
||||
end
|
||||
|
||||
def page_params(params) do
|
||||
case params["q"] do
|
||||
nil -> []
|
||||
"" -> []
|
||||
q -> [q: q]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +1,5 @@
|
|||
defmodule PhilomenaWeb.Admin.FingerprintBanView do
|
||||
use PhilomenaWeb, :view
|
||||
|
||||
alias PhilomenaWeb.ProfileView
|
||||
|
||||
defp user_abbrv(conn, user),
|
||||
do: ProfileView.user_abbrv(conn, user)
|
||||
|
||||
defp ban_row_class(%{valid_until: until, enabled: enabled}) do
|
||||
now = DateTime.utc_now()
|
||||
|
||||
case enabled and DateTime.diff(until, now) > 0 do
|
||||
true -> "success"
|
||||
_false -> "danger"
|
||||
end
|
||||
end
|
||||
import PhilomenaWeb.Admin.BanView
|
||||
end
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
defmodule PhilomenaWeb.Admin.SubnetBanView do
|
||||
use PhilomenaWeb, :view
|
||||
|
||||
alias PhilomenaWeb.ProfileView
|
||||
|
||||
defp user_abbrv(conn, user),
|
||||
do: ProfileView.user_abbrv(conn, user)
|
||||
|
||||
defp ban_row_class(%{valid_until: until, enabled: enabled}) do
|
||||
now = DateTime.utc_now()
|
||||
|
||||
case enabled and DateTime.diff(until, now) > 0 do
|
||||
true -> "success"
|
||||
_false -> "danger"
|
||||
end
|
||||
end
|
||||
import PhilomenaWeb.Admin.BanView
|
||||
end
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
defmodule PhilomenaWeb.Admin.UserBanView do
|
||||
use PhilomenaWeb, :view
|
||||
|
||||
alias PhilomenaWeb.ProfileView
|
||||
|
||||
defp user_abbrv(conn, user),
|
||||
do: ProfileView.user_abbrv(conn, user)
|
||||
|
||||
defp ban_row_class(%{valid_until: until, enabled: enabled}) do
|
||||
now = DateTime.utc_now()
|
||||
|
||||
case enabled and DateTime.diff(until, now) > 0 do
|
||||
true -> "success"
|
||||
_false -> "danger"
|
||||
end
|
||||
end
|
||||
import PhilomenaWeb.Admin.BanView
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue