Last active
November 21, 2020 17:29
-
-
Save mazz/735ee71c78f0ddfbf9397b9c2bd6b7bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user_status: <%= @user.status %> | |
<div class="mb-6"> | |
<%= select(f, @user.status, @statuses) %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UserStatusEnum.__enum_map__(): [inactive: 0, active: 1] | |
statuses: [inactive: 0, active: 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IO.inspect(UserStatusEnum.__enum_map__(), label: "UserStatusEnum.__enum_map__()") | |
statuses = | |
Enum.map(UserStatusEnum.__enum_map__(), fn status -> | |
status | |
end) | |
IO.inspect(statuses, label: "statuses") | |
assigns = [ | |
conn: socket, | |
action: action, | |
csrf_token: csrf_token, | |
form_action: form_action, | |
changeset: changeset, | |
user: user, | |
statuses: statuses, | |
administrating_user: administrating_user, | |
orgs_admin: orgs_admin, | |
orgs_user: orgs_user, | |
orgs_invite: orgs_invite, | |
org_add_id: nil | |
] | |
{:ok, assign(socket, assigns)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defenum UserStatusEnum, inactive: 0, active: 1 | |
@derive {Inspect, except: [:password]} | |
@valid_locales ~w(en) | |
@email_regex ~r/\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i | |
@required_fields ~w(email username uuid)a | |
@optional_fields ~w(name phone_number locale)a | |
def email_regex(), do: @email_regex | |
schema "users" do | |
field :email, :string | |
field :username, :string | |
field :name, :string | |
field :phone_number, :string | |
field :confirmed_at, :naive_datetime | |
field :orgs_registered, {:array, :integer}, default: [] | |
field :orgs_confirmed, {:array, :integer}, default: [] | |
field :orgs_authorized, {:array, :integer}, default: [] | |
field :uuid, Ecto.UUID | |
field :avatar, Markably.AvatarUploader.Type | |
many_to_many :orgs, Markably.Schema.Org, join_through: "orgs_users", on_replace: :delete | |
field :locale, :string | |
field :role, RolesEnum, default: :user | |
field :status, UserStatusEnum |
Author
mazz
commented
Nov 21, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment