added weekdays enum and week_start_at for user records
This commit is contained in:
parent
4fb0e2df7b
commit
4031640e1d
4 changed files with 11 additions and 0 deletions
lib/shift73k
|
@ -3,6 +3,7 @@ defmodule Shift73k.Accounts.User do
|
|||
import Ecto.Changeset
|
||||
import EctoEnum
|
||||
|
||||
alias Shift73k.EctoEnums.WeekdayEnum
|
||||
alias Shift73k.Shifts.Templates.ShiftTemplate
|
||||
alias Shift73k.Shifts.Shift
|
||||
|
||||
|
@ -28,6 +29,7 @@ defmodule Shift73k.Accounts.User do
|
|||
field(:confirmed_at, :naive_datetime)
|
||||
|
||||
field(:role, RolesEnum, default: :user)
|
||||
field(:week_start_at, WeekdayEnum, default: 1)
|
||||
|
||||
has_many(:shift_templates, ShiftTemplate)
|
||||
belongs_to(:fave_shift_template, ShiftTemplate)
|
||||
|
|
7
lib/shift73k/ecto_enums.ex
Normal file
7
lib/shift73k/ecto_enums.ex
Normal file
|
@ -0,0 +1,7 @@
|
|||
defmodule Shift73k.EctoEnums do
|
||||
import EctoEnum
|
||||
|
||||
@weekdays [:mon, :tue, :wed, :thu, :fri, :sat, :sun] |> Enum.with_index(1)
|
||||
|
||||
defenum(WeekdayEnum, @weekdays)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue