Skip to content

Commit

Permalink
apply :assigned status if assignee is defined #1
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Jun 5, 2019
1 parent 97648c0 commit bf4934e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/app/ctx/todo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ defmodule App.Ctx.Todo do
@doc false
def changeset(todo, attrs) do
todo
|> cast(attrs, [:title, :status, :priority, :time_estimate, :deadline, :schedule, :assignee, :owner])
|> cast(attrs, [:title, :status, :priority, :time_estimate, :deadline,
:schedule, :assignee, :owner])
|> validate_required([])
|> status_assigned(todo)
end

def status_assigned(changeset, todo) do
if(todo.assignee && todo.status == :unassigned) do
put_change(changeset, :status, :assigned)
else
changeset
end
end
end

0 comments on commit bf4934e

Please sign in to comment.