diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 12:35:32 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 12:35:32 +0000 |
commit | b3deca7a2606a6b2cef464ed08417be4ffb0cb6b (patch) | |
tree | 58cb99a58196581520303a57e9f2024553649eae /app/models/todo.rb | |
parent | 411070c3afa621a0bdc741617c1d17f54205b81a (diff) | |
parent | 6dc7490789237a84b66baaaf4c6deea5ec3bf2de (diff) | |
download | gitlab-ce-b3deca7a2606a6b2cef464ed08417be4ffb0cb6b.tar.gz |
Merge branch 'group-todos' into 'master'
Group todos
See merge request gitlab-org/gitlab-ce!20675
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r-- | app/models/todo.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb index 5f5c2f9073d..48d92ad04b3 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -24,15 +24,18 @@ class Todo < ActiveRecord::Base belongs_to :author, class_name: "User" belongs_to :note belongs_to :project + belongs_to :group belongs_to :target, polymorphic: true, touch: true # rubocop:disable Cop/PolymorphicAssociations belongs_to :user delegate :name, :email, to: :author, prefix: true, allow_nil: true - validates :action, :project, :target_type, :user, presence: true + validates :action, :target_type, :user, presence: true validates :author, presence: true validates :target_id, presence: true, unless: :for_commit? validates :commit_id, presence: true, if: :for_commit? + validates :project, presence: true, unless: :group_id + validates :group, presence: true, unless: :project_id scope :pending, -> { with_state(:pending) } scope :done, -> { with_state(:done) } @@ -46,7 +49,7 @@ class Todo < ActiveRecord::Base state :done end - after_save :keep_around_commit + after_save :keep_around_commit, if: :commit_id class << self # Priority sorting isn't displayed in the dropdown, because we don't show @@ -81,6 +84,10 @@ class Todo < ActiveRecord::Base end end + def parent + project + end + def unmergeable? action == UNMERGEABLE end |