bans view changes

This commit is contained in:
byte[] 2019-12-30 07:30:39 -05:00
parent 9ed5652aad
commit 38c4e35bb7
6 changed files with 43 additions and 12 deletions

View file

@ -10,6 +10,7 @@
.field
=> label f, :reason, "Reason (shown to the banned user, and to staff on the user's profile page):"
= text_input f, :reason, class: "input input--wide", placeholder: "Reason", required: true
= error_tag f, :reason
.field
=> label f, :note, "Admin-only note:"
@ -18,5 +19,12 @@
.field
=> label f, :until, "End time relative to now, in simple English (e.g. \"1 week from now\"):"
= text_input f, :until, class: "input input--wide", placeholder: "Until", required: true
= error_tag f, :until
br
.field
=> checkbox f, :enabled
= label f, :enabled
br
= submit "Save Ban", class: "button"

View file

@ -10,6 +10,7 @@
.field
=> label f, :reason, "Reason (shown to the banned user, and to staff on the user's profile page):"
= text_input f, :reason, class: "input input--wide", placeholder: "Reason", required: true
= error_tag f, :reason
.field
=> label f, :note, "Admin-only note:"
@ -18,5 +19,12 @@
.field
=> label f, :until, "End time relative to now, in simple English (e.g. \"1 week from now\"):"
= text_input f, :until, class: "input input--wide", placeholder: "Until", required: true
= error_tag f, :until
br
.field
=> checkbox f, :enabled
= label f, :enabled
br
= submit "Save Ban", class: "button"

View file

@ -7,13 +7,10 @@
=> label f, :username, "Username:"
= text_input f, :username, class: "input", placeholder: "Username", required: true
.field
=> checkbox f, :override_ip_ban, class: "checkbox"
= label f, :override_ip_ban, "Override IP ban?"
.field
=> label f, :reason, "Reason (shown to the banned user, and to staff on the user's profile page):"
= text_input f, :reason, class: "input input--wide", placeholder: "Reason", required: true
= error_tag f, :reason
.field
=> label f, :note, "Admin-only note:"
@ -22,5 +19,12 @@
.field
=> label f, :until, "End time relative to now, in simple English (e.g. \"1 week from now\"):"
= text_input f, :until, class: "input input--wide", placeholder: "Until", required: true
= error_tag f, :until
br
.field
=> checkbox f, :enabled
= label f, :enabled
br
= submit "Save Ban", class: "button"

View file

@ -25,7 +25,6 @@ h1 User Bans
th Expires
th Reason/Note
th Ban ID
th Auto IP Ban
th Options
tbody
@ -53,11 +52,6 @@ h1 User Bans
td
= ban.generated_ban_id
= if ban.override_ip_ban do
td.danger Disabled
- else
td.success Enabled
td
=> link "Edit", to: Routes.admin_user_ban_path(@conn, :edit, ban)
' •

View file

@ -2,6 +2,6 @@ defmodule PhilomenaWeb.BanView do
use PhilomenaWeb, :view
def active?(ban) do
NaiveDateTime.diff(ban.valid_until, NaiveDateTime.utc_now()) > 0
ban.enabled and NaiveDateTime.diff(ban.valid_until, NaiveDateTime.utc_now()) > 0
end
end

View file

@ -1,6 +1,23 @@
defmodule RelativeDate.Parser do
import NimbleParsec
number_words =
choice([
string("a") |> replace(1),
string("an") |> replace(1),
string("one") |> replace(1),
string("two") |> replace(2),
string("three") |> replace(3),
string("four") |> replace(4),
string("five") |> replace(5),
string("six") |> replace(6),
string("seven") |> replace(7),
string("eight") |> replace(8),
string("nine") |> replace(9),
string("ten") |> replace(10),
integer(min: 1)
])
time_specifier =
choice([
string("second") |> replace(1),
@ -37,7 +54,7 @@ defmodule RelativeDate.Parser do
date =
space
|> integer(min: 1)
|> concat(number_words)
|> concat(space)
|> concat(time_specifier)
|> concat(space)