-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from camino-school/school_cycles
School cycles
- Loading branch information
Showing
40 changed files
with
1,560 additions
and
101 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Lanttern.Schools.Cycle do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
schema "school_cycles" do | ||
field :name, :string | ||
field :start_at, :date | ||
field :end_at, :date | ||
belongs_to :school, Lanttern.Schools.School | ||
|
||
timestamps() | ||
end | ||
|
||
@doc false | ||
def changeset(cycle, attrs) do | ||
cycle | ||
|> cast(attrs, [:name, :start_at, :end_at, :school_id]) | ||
|> validate_required([:name, :start_at, :end_at, :school_id]) | ||
|> check_constraint( | ||
:end_at, | ||
name: :cycle_end_date_is_greater_than_start_date, | ||
message: "End date should be greater than start date" | ||
) | ||
end | ||
end |
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
Oops, something went wrong.