Skip to content

Commit

Permalink
return capture with task, #14
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed Apr 17, 2020
1 parent e893ee1 commit 43ad4da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/app_api/captures/capture.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule AppApi.Captures.Capture do
field :completed, :boolean, default: false
field :id_person, :integer
field :text, :string
field :task, :boolean, default: true
has_many :timers, Timer

timestamps()
Expand All @@ -15,7 +16,7 @@ defmodule AppApi.Captures.Capture do
@doc false
def changeset(capture, attrs) do
capture
|> cast(attrs, [:id_person, :text, :completed])
|> validate_required([:id_person, :text, :completed])
|> cast(attrs, [:id_person, :text, :completed, :task])
|> validate_required([:id_person, :text, :completed, :task])
end
end
3 changes: 2 additions & 1 deletion lib/app_api_web/controllers/capture_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ defmodule AppApiWeb.CaptureController do

updates = %{
completed: params["completed"],
text: params["text"]
text: params["text"],
task: params["task"]
}

udpatedCatpure = Captures.update_capture(capture, updates)
Expand Down
1 change: 1 addition & 0 deletions lib/app_api_web/views/capture_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule AppApiWeb.CaptureView do
id_person: capture.id_person,
text: capture.text,
completed: capture.completed,
task: capture.task,
timers: Enum.map(capture.timers, &TimerView.timer_to_json/1)
}
end
Expand Down

0 comments on commit 43ad4da

Please sign in to comment.