From 9d8e9ef8c82cc450f20baa6b6e97d1a1df4a75e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1rio=20Rodrigues?=
<93675410+MarioRodrigues10@users.noreply.github.com>
Date: Wed, 19 Jul 2023 22:31:38 +0100
Subject: [PATCH] Remove unnecessary role (#290)
---
lib/atomic/accounts/user.ex | 2 +-
.../user_registration_controller.ex | 2 +-
.../live/activity_live/show.html.heex | 2 +-
priv/repo/seeds/accounts.exs | 45 -------------------
test/support/factories/accounts_factory.ex | 2 +-
.../factories/organizations_factory.ex | 2 +-
6 files changed, 5 insertions(+), 50 deletions(-)
diff --git a/lib/atomic/accounts/user.ex b/lib/atomic/accounts/user.ex
index c86714ba5..b99913821 100644
--- a/lib/atomic/accounts/user.ex
+++ b/lib/atomic/accounts/user.ex
@@ -12,7 +12,7 @@ defmodule Atomic.Accounts.User do
@required_fields ~w(email password role name)a
@optional_fields ~w(course_id)a
- @roles ~w(admin staff student)a
+ @roles ~w(admin student)a
schema "users" do
field :email, :string
diff --git a/lib/atomic_web/controllers/user_registration_controller.ex b/lib/atomic_web/controllers/user_registration_controller.ex
index 7ccfd9c92..094b4ba24 100644
--- a/lib/atomic_web/controllers/user_registration_controller.ex
+++ b/lib/atomic_web/controllers/user_registration_controller.ex
@@ -10,7 +10,7 @@ defmodule AtomicWeb.UserRegistrationController do
conn =
conn
- |> assign(:roles, ~w(admin staff student)a)
+ |> assign(:roles, ~w(admin student)a)
render(conn, "new.html", changeset: changeset)
end
diff --git a/lib/atomic_web/live/activity_live/show.html.heex b/lib/atomic_web/live/activity_live/show.html.heex
index fa94dcc61..bef7e0824 100644
--- a/lib/atomic_web/live/activity_live/show.html.heex
+++ b/lib/atomic_web/live/activity_live/show.html.heex
@@ -93,7 +93,7 @@
<% end %>
<% end %>
-<%= if @current_user.role in [:admin, :staff] do %>
+<%= if @current_user.role in [:admin] do %>
<%= live_patch("Edit", to: Routes.activity_edit_path(@socket, :edit, @activity), class: "button") %> | <%= link("Delete", to: "#", phx_click: "delete", phx_value_id: @activity.id, data: [confirm: "Are you sure?"]) %> |
<%= live_redirect("Back", to: Routes.activity_index_path(@socket, :index)) %>
<% end %>
diff --git a/priv/repo/seeds/accounts.exs b/priv/repo/seeds/accounts.exs
index a73986b84..58a9c04f1 100644
--- a/priv/repo/seeds/accounts.exs
+++ b/priv/repo/seeds/accounts.exs
@@ -99,51 +99,6 @@ defmodule Atomic.Repo.Seeds.Accounts do
]
|> create_users(:student)
- [
- "Bo Peep",
- "Bugs Bunny",
- "Buzz Lightyear",
- "Captain Hook",
- "Clara Cluck",
- "Clarabelle Cow",
- "Cruella de Vil",
- "Daisy Duck",
- "Dewey Duck",
- "Doc Hudson",
- "Donald Duck",
- "Eddie Valiant",
- "Horace Horsecollar",
- "Huey Duck",
- "Jessica Rabbit",
- "Judge Doom",
- "Lightning McQueen",
- "Little John",
- "Louie Duck",
- "Maid Marian",
- "Max Goof",
- "Mickey Mouse",
- "Minnie Mouse",
- "Mortimer Mouse",
- "Peter Pan",
- "Potato Head",
- "Prince John",
- "Queen of Hearts",
- "Robin Hood",
- "Roger Rabbit",
- "Sally Carrera",
- "Scrooge McDuck",
- "Speedy Gonzalez",
- "Sheriff of Nottingham",
- "Snow White",
- "Tiger Lily",
- "Tinker Bell",
- "Tweedle Dee",
- "Tweedle Dum",
- "Wendy Darling",
- "White Rabbit"
- ]
- |> create_users(:staff)
-
_ ->
Mix.shell().error("Found users, aborting seeding users.")
end
diff --git a/test/support/factories/accounts_factory.ex b/test/support/factories/accounts_factory.ex
index b852fa5ef..edef51bf5 100644
--- a/test/support/factories/accounts_factory.ex
+++ b/test/support/factories/accounts_factory.ex
@@ -7,7 +7,7 @@ defmodule Atomic.Factories.AccountFactory do
defmacro __using__(_opts) do
quote do
- @roles ~w(admin staff student)a
+ @roles ~w(admin student)a
def user_factory do
%User{
diff --git a/test/support/factories/organizations_factory.ex b/test/support/factories/organizations_factory.ex
index b2c93a760..7227e5405 100644
--- a/test/support/factories/organizations_factory.ex
+++ b/test/support/factories/organizations_factory.ex
@@ -19,7 +19,7 @@ defmodule Atomic.Factories.OrganizationFactory do
def membership_factory do
%Membership{
user: build(:user),
- created_by: build(:user, role: "staff"),
+ created_by: build(:user, role: "admin"),
organization: build(:organization),
role: Enum.random(@roles)
}