@@ -7,16 +7,18 @@ defmodule CodeCorps.Task do
77 field :body , :string
88 field :markdown , :string
99 field :number , :integer , read_after_writes: true
10- field :task_type , :string
10+ field :order , :integer
1111 field :state , :string
1212 field :status , :string , default: "open"
13+ field :task_type , :string
1314 field :title , :string
15+
1416 field :position , :integer , virtual: true
15- field :order , :integer
1617
1718 belongs_to :project , CodeCorps.Project
18- belongs_to :user , CodeCorps.User
1919 belongs_to :task_list , CodeCorps.TaskList
20+ belongs_to :user , CodeCorps.User
21+
2022 has_many :comments , CodeCorps.Comment
2123
2224 timestamps ( )
@@ -25,7 +27,7 @@ defmodule CodeCorps.Task do
2527 def changeset ( struct , params \\ % { } ) do
2628 struct
2729 |> cast ( params , [ :title , :markdown , :task_type , :task_list_id , :position ] )
28- |> validate_required ( [ :title , :markdown , :task_type ] )
30+ |> validate_required ( [ :title , :markdown , :task_list_id , : task_type] )
2931 |> validate_inclusion ( :task_type , task_types )
3032 |> assoc_constraint ( :task_list )
3133 |> apply_position ( )
@@ -37,7 +39,7 @@ defmodule CodeCorps.Task do
3739 struct
3840 |> changeset ( params )
3941 |> cast ( params , [ :project_id , :user_id ] )
40- |> validate_required ( [ :project_id , :user_id , :task_list_id ] )
42+ |> validate_required ( [ :project_id , :user_id ] )
4143 |> assoc_constraint ( :project )
4244 |> assoc_constraint ( :user )
4345 |> put_change ( :state , "published" )
0 commit comments