Introduce group basic federation, event new page and notifications
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
38
lib/mobilizon/users/setting.ex
Normal file
38
lib/mobilizon/users/setting.ex
Normal file
@@ -0,0 +1,38 @@
|
||||
defmodule Mobilizon.Users.Setting do
|
||||
@moduledoc """
|
||||
Module to manage users settings
|
||||
"""
|
||||
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
alias Mobilizon.Users.User
|
||||
|
||||
@required_attrs [:user_id]
|
||||
|
||||
@optional_attrs [
|
||||
:timezone,
|
||||
:notification_on_day,
|
||||
:notification_each_week,
|
||||
:notification_before_event
|
||||
]
|
||||
|
||||
@attrs @required_attrs ++ @optional_attrs
|
||||
|
||||
@primary_key {:user_id, :id, autogenerate: false}
|
||||
schema "user_settings" do
|
||||
field(:timezone, :string)
|
||||
field(:notification_on_day, :boolean)
|
||||
field(:notification_each_week, :boolean)
|
||||
field(:notification_before_event, :boolean)
|
||||
belongs_to(:user, User, primary_key: true, type: :id, foreign_key: :id, define_field: false)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(setting, attrs) do
|
||||
setting
|
||||
|> cast(attrs, @attrs)
|
||||
|> validate_required(@required_attrs)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user