Skip to content

Commit

Permalink
Merge branch 'develop' into rl/fix-seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
ruilopesm committed Aug 14, 2023
2 parents 6e1e722 + 24e377f commit 3e8e44d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
9 changes: 4 additions & 5 deletions lib/atomic/accounts/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@ defmodule Atomic.Accounts.User do
alias Atomic.Uploaders.ProfilePicture

@required_fields ~w(email password)a
@optional_fields ~w(name course_id default_organization_id)a
@optional_fields ~w(name role confirmed_at course_id default_organization_id)a

@roles ~w(admin student)a

schema "users" do
field :email, :string
field :name, :string
field :email, :string
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, :naive_datetime
belongs_to :default_organization, Organization

belongs_to :course, Course
field :profile_picture, ProfilePicture.Type
field :role, Ecto.Enum, values: @roles, default: :student
belongs_to :course, Course
belongs_to :default_organization, Organization

has_many :enrollments, Enrollment

many_to_many :organizations, Organization, join_through: Membership

timestamps()
Expand Down
6 changes: 3 additions & 3 deletions lib/atomic_web/live/activity_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
<% end %>
</div>
<div class="flex flex-col-reverse border-b border-zinc-200 xl:flex-row">
<div class="flex w-full items-center justify-between">
<div x-data="{option: 'enrollments'}" class="flex w-full items-center justify-between">
<nav class="-mb-px flex flex-1 space-x-6 overflow-x-auto xl:space-x-8" aria-label="Tabs">
<div x-on:click="open = ! open" x-bind:class="! open ? 'border-transparent' : 'border-zinc-800'" phx-click="open-enrollments" class="text-zinc-500 hover:text-zinc-700 whitespace-nowrap border-b-2 px-1 py-4 text-sm font-medium">
<div x-on:click="option = 'enrollments'" x-bind:class="option == 'enrollments' ? 'border-zinc-800' : 'border-transparent'" phx-click="open-enrollments" class="text-zinc-500 hover:text-zinc-700 whitespace-nowrap border-b-2 px-1 py-4 text-sm font-medium cursor-pointer">
<%= gettext("Open Enrollments") %>
</div>

<div x-on:click="open = ! open" x-bind:class="! open ? 'border-zinc-800' : 'border-transparent'" phx-click="activities-enrolled" class="text-zinc-500 hover:text-zinc-700 whitespace-nowrap border-b-2 px-1 py-4 text-sm font-medium">
<div x-on:click="option = 'activities'" x-bind:class="option == 'activities' ? 'border-zinc-800' : 'border-transparent'" phx-click="activities-enrolled" class="text-zinc-500 hover:text-zinc-700 whitespace-nowrap border-b-2 px-1 py-4 text-sm font-medium cursor-pointer">
<%= gettext("Activities Enrolled") %>
</div>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ defmodule Atomic.Repo.Migrations.CreateUsersAuthTables do

create table(:users, primary_key: false) do
add :id, :binary_id, primary_key: true
add :name, :string
add :email, :citext, null: false
add :hashed_password, :string, null: false
add :confirmed_at, :naive_datetime
add :profile_picture, :string

add :role, :string, null: false, default: "student"

add :default_organization_id,
references(:organizations, type: :binary_id, on_delete: :delete_all)

add :role, :string, null: false, default: "student"
timestamps()
end

Expand All @@ -25,6 +28,7 @@ defmodule Atomic.Repo.Migrations.CreateUsersAuthTables do
add :token, :binary, null: false
add :context, :string, null: false
add :sent_to, :string

timestamps(updated_at: false)
end

Expand Down
2 changes: 0 additions & 2 deletions priv/repo/migrations/20230325151547_add_user_data.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ defmodule Atomic.Repo.Migrations.AddUserData do
end

alter table(:users) do
add :name, :string
add :course_id, references(:courses, on_delete: :nothing, type: :binary_id), null: true
add :profile_picture, :string
end
end
end

0 comments on commit 3e8e44d

Please sign in to comment.