4b4ecec693
Signed-off-by: Thomas Citharel <tcit@tcit.fr> typo Signed-off-by: Thomas Citharel <tcit@tcit.fr> Rename avatar to avatar_url, same with header. Add a comment to explain why the tweak with HTTPoison and TLS1.2 Signed-off-by: Thomas Citharel <tcit@tcit.fr> Rename avatar to avatar_url Signed-off-by: Thomas Citharel <tcit@tcit.fr> rename old avatar properties in front-end to avatar_url Signed-off-by: Thomas Citharel <tcit@tcit.fr> fix change gravatar from ?d= to ?default= Signed-off-by: Thomas Citharel <tcit@tcit.fr> reorganize aliases and imports Signed-off-by: Thomas Citharel <tcit@tcit.fr> set avatar url only when gravatar exists, add a test for that case Signed-off-by: Thomas Citharel <tcit@tcit.fr>
46 lines
1.5 KiB
Elixir
46 lines
1.5 KiB
Elixir
defmodule Eventos.Accounts.Account do
|
|
@moduledoc """
|
|
Represents an account (local and remote users)
|
|
"""
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
alias Eventos.Accounts.{Account, User}
|
|
alias Eventos.Groups.{Group, Member, Request}
|
|
alias Eventos.Events.Event
|
|
|
|
schema "accounts" do
|
|
field :description, :string
|
|
field :display_name, :string
|
|
field :domain, :string
|
|
field :private_key, :string
|
|
field :public_key, :string
|
|
field :suspended, :boolean, default: false
|
|
field :uri, :string
|
|
field :url, :string
|
|
field :username, :string
|
|
field :avatar_url, :string
|
|
field :banner_url, :string
|
|
has_many :organized_events, Event, [foreign_key: :organizer_account_id]
|
|
many_to_many :groups, Group, join_through: Member
|
|
has_many :group_request, Request
|
|
has_one :user, User
|
|
|
|
timestamps()
|
|
end
|
|
|
|
@doc false
|
|
def changeset(%Account{} = account, attrs) do
|
|
account
|
|
|> cast(attrs, [:username, :domain, :display_name, :description, :private_key, :public_key, :suspended, :uri, :url, :avatar_url, :banner_url])
|
|
|> validate_required([:username, :public_key, :suspended, :uri, :url])
|
|
|> unique_constraint(:username, name: :accounts_username_domain_index)
|
|
end
|
|
|
|
def registration_changeset(%Account{} = account, attrs) do
|
|
account
|
|
|> cast(attrs, [:username, :domain, :display_name, :description, :private_key, :public_key, :suspended, :uri, :url, :avatar_url, :banner_url])
|
|
|> validate_required([:username, :public_key, :suspended, :uri, :url])
|
|
|> unique_constraint(:username)
|
|
end
|
|
end
|