diff options
author | Jarka Kadlecová <jarka@gitlab.com> | 2018-06-13 18:11:10 +0200 |
---|---|---|
committer | Jarka Kadlecová <jarka@gitlab.com> | 2018-07-03 09:34:44 +0200 |
commit | 57a44f2da3d2a0b59209b6c2d653d04efd0d3d41 (patch) | |
tree | 37a3035e1f1411a16a989e8b22f20bb80c79cf6d /app/models | |
parent | 275fbf24b1810e2fbef92b6599d5372855b97b46 (diff) | |
download | gitlab-ce-57a44f2da3d2a0b59209b6c2d653d04efd0d3d41.tar.gz |
Support todos for epics backport
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/group.rb | 9 | ||||
-rw-r--r-- | app/models/todo.rb | 11 |
2 files changed, 18 insertions, 2 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 9c171de7fc3..9baf2cfd810 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -39,6 +39,8 @@ class Group < Namespace has_many :boards has_many :badges, class_name: 'GroupBadge' + has_many :todos + accepts_nested_attributes_for :variables, allow_destroy: true validate :visibility_level_allowed_by_projects @@ -82,6 +84,13 @@ class Group < Namespace where(id: user.authorized_groups.select(:id).reorder(nil)) end + def public_or_visible_to_user(user) + where('id IN (?) OR namespaces.visibility_level IN (?)', + user.authorized_groups.select(:id), + Gitlab::VisibilityLevel.levels_for_user(user) + ) + end + def select_for_project_authorization if current_scope.joins_values.include?(:shared_projects) joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id') diff --git a/app/models/todo.rb b/app/models/todo.rb index a2ab405fdbe..5ce77d5ddc2 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -22,15 +22,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 + validates :group, presence: true, unless: :project scope :pending, -> { with_state(:pending) } scope :done, -> { with_state(:done) } @@ -44,7 +47,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 @@ -79,6 +82,10 @@ class Todo < ActiveRecord::Base end end + def parent + project || group + end + def unmergeable? action == UNMERGEABLE end |