diff --git a/lib/philomena_web/templates/admin/fingerprint_ban/_form.html.slime b/lib/philomena_web/templates/admin/fingerprint_ban/_form.html.slime index 30b4b38c..e81456ee 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/_form.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/_form.html.slime @@ -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" diff --git a/lib/philomena_web/templates/admin/subnet_ban/_form.html.slime b/lib/philomena_web/templates/admin/subnet_ban/_form.html.slime index 3ad336d4..bf87b2ce 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/_form.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/_form.html.slime @@ -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" diff --git a/lib/philomena_web/templates/admin/user_ban/_form.html.slime b/lib/philomena_web/templates/admin/user_ban/_form.html.slime index 164991ee..292f07eb 100644 --- a/lib/philomena_web/templates/admin/user_ban/_form.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/_form.html.slime @@ -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" diff --git a/lib/philomena_web/templates/admin/user_ban/index.html.slime b/lib/philomena_web/templates/admin/user_ban/index.html.slime index 94b25f6d..0684aa82 100644 --- a/lib/philomena_web/templates/admin/user_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/index.html.slime @@ -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) ' • diff --git a/lib/philomena_web/views/ban_view.ex b/lib/philomena_web/views/ban_view.ex index d858a954..3e821604 100644 --- a/lib/philomena_web/views/ban_view.ex +++ b/lib/philomena_web/views/ban_view.ex @@ -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 diff --git a/lib/relative_date/parser.ex b/lib/relative_date/parser.ex index e6da0495..a801b74c 100644 --- a/lib/relative_date/parser.ex +++ b/lib/relative_date/parser.ex @@ -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)