diff --git a/lib/philomena/users/user.ex b/lib/philomena/users/user.ex index 8739fdb3..b25ac992 100644 --- a/lib/philomena/users/user.ex +++ b/lib/philomena/users/user.ex @@ -117,6 +117,7 @@ defmodule Philomena.Users.User do field :scratchpad, :string field :secondary_role, :string field :hide_default_role, :boolean, default: false + field :senior_staff, :boolean, default: false # For avatar validation/persistence field :avatar_width, :integer, virtual: true @@ -268,7 +269,7 @@ defmodule Philomena.Users.User do def update_changeset(user, attrs, roles) do user - |> cast(attrs, [:name, :email, :role, :secondary_role, :hide_default_role]) + |> cast(attrs, [:name, :email, :role, :secondary_role, :hide_default_role, :senior_staff]) |> validate_required([:name, :email, :role]) |> validate_inclusion(:role, ["user", "assistant", "moderator", "admin"]) |> put_assoc(:roles, roles) diff --git a/lib/philomena_web/templates/admin/user/_form.html.slime b/lib/philomena_web/templates/admin/user/_form.html.slime index 64a4fc34..2eebaaff 100644 --- a/lib/philomena_web/templates/admin/user/_form.html.slime +++ b/lib/philomena_web/templates/admin/user/_form.html.slime @@ -21,6 +21,9 @@ label.table-list__label .table-list__label__text Hide staff banner: .table-list__label__input = checkbox f, :hide_default_role, class: "checkbox" + label.table-list__label + .table-list__label__text Senior staff: + .table-list__label__input = checkbox f, :senior_staff, class: "checkbox" .table-list__label .table-list__label__text Avatar .table-list__label__input @@ -29,6 +32,10 @@ .block .block__header span.block__header__title General user flags + ul + p + strong> Be careful when issuing these permissions to staff members! + | Staff members with relevant roles may have these permissions anyway. Issuing them may break things, such as tag aliasing. ul = collection_checkboxes f, :roles, filtered_roles(general_permissions(), @roles), mapper: &checkbox_mapper/6 .block diff --git a/lib/philomena_web/templates/user_attribution/_user_title.html.slime b/lib/philomena_web/templates/user_attribution/_user_title.html.slime index 8695b48c..1dba6410 100644 --- a/lib/philomena_web/templates/user_attribution/_user_title.html.slime +++ b/lib/philomena_web/templates/user_attribution/_user_title.html.slime @@ -2,4 +2,4 @@ = if assigns[:large] do .label.label--block class=class = label - else - .label.label--block.label--small class=class = label \ No newline at end of file + .label.label--block.label--small class=class = label diff --git a/lib/philomena_web/views/user_attribution_view.ex b/lib/philomena_web/views/user_attribution_view.ex index c2c47a38..fc8613f0 100644 --- a/lib/philomena_web/views/user_attribution_view.ex +++ b/lib/philomena_web/views/user_attribution_view.ex @@ -107,12 +107,21 @@ defmodule PhilomenaWeb.UserAttributionView do defp secondary_role(labels, _user), do: labels + defp staff_role(labels, %{hide_default_role: false, role: "admin", senior_staff: true}), + do: [{"label--danger", "Head Administrator"} | labels] + defp staff_role(labels, %{hide_default_role: false, role: "admin"}), do: [{"label--danger", "Site Administrator"} | labels] + defp staff_role(labels, %{hide_default_role: false, role: "moderator", senior_staff: true}), + do: [{"label--success", "Senior Moderator"} | labels] + defp staff_role(labels, %{hide_default_role: false, role: "moderator"}), do: [{"label--success", "Site Moderator"} | labels] + defp staff_role(labels, %{hide_default_role: false, role: "assistant", senior_staff: true}), + do: [{"label--purple", "Senior Assistant"} | labels] + defp staff_role(labels, %{hide_default_role: false, role: "assistant"}), do: [{"label--purple", "Site Assistant"} | labels] diff --git a/priv/repo/migrations/20200817213256_add_senior_staff.exs b/priv/repo/migrations/20200817213256_add_senior_staff.exs new file mode 100644 index 00000000..555416a4 --- /dev/null +++ b/priv/repo/migrations/20200817213256_add_senior_staff.exs @@ -0,0 +1,9 @@ +defmodule Philomena.Repo.Migrations.AddSeniorStaff do + use Ecto.Migration + + def change do + alter table(:users) do + add :senior_staff, :boolean, default: false + end + end +end diff --git a/priv/repo/structure.sql b/priv/repo/structure.sql index b90b65dc..c18baf56 100644 --- a/priv/repo/structure.sql +++ b/priv/repo/structure.sql @@ -1974,7 +1974,8 @@ CREATE TABLE public.users ( otp_backup_codes character varying[], last_renamed_at timestamp without time zone DEFAULT '1970-01-01 00:00:00'::timestamp without time zone NOT NULL, forced_filter_id bigint, - confirmed_at timestamp(0) without time zone + confirmed_at timestamp(0) without time zone, + senior_staff boolean DEFAULT false ); @@ -4794,3 +4795,4 @@ INSERT INTO public."schema_migrations" (version) VALUES (20200617111116); INSERT INTO public."schema_migrations" (version) VALUES (20200617113333); INSERT INTO public."schema_migrations" (version) VALUES (20200706171350); INSERT INTO public."schema_migrations" (version) VALUES (20200725234412); +INSERT INTO public."schema_migrations" (version) VALUES (20200817213256);