Packages

Profile-related models for commonspub

Current section

Files

Jump to
cpub_profiles lib profile.ex
Raw

lib/profile.ex

defmodule CommonsPub.Profiles.Profile do
use Pointers.Mixin,
otp_app: :cpub_profiles,
source: "cpub_profiles_profile"
alias Pointers.Changesets
alias CommonsPub.Profiles.Profile
mixin_schema do
field :name, :string
field :summary, :string
# belongs_to :icon, Content
# belongs_to :image, Content
end
@defaults [
cast: [:name, :summary],
required: [:name, :summary],
name: [length: [min: 3, max: 50]],
summary: [length: [min: 20, max: 500]],
]
def changeset(prof \\ %Profile{}, attrs, opts \\ []),
do: Changesets.auto(prof, attrs, opts, @defaults)
end
defmodule CommonsPub.Profiles.Profile.Migration do
import Ecto.Migration
import Pointers.Migration
alias CommonsPub.Profiles.Profile
# @profile_table Profile.__schema__(:source)
def migrate_profile(dir \\ direction())
def migrate_profile(:up) do
create_mixin_table(Profile) do
add :name, :text
add :summary, :text
# add :icon, strong_pointer(Content)
# add :image, strong_pointer(Content)
end
end
def migrate_profile(:down) do
drop_mixin_table(Profile)
end
end