diff options
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 5347d4fa1be..35e08fa915b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -16,6 +16,7 @@ # state :string(255) # iid :integer # updated_by_id :integer +# moved_to_id :integer # require 'carrierwave/orm/activerecord' @@ -31,6 +32,8 @@ class Issue < ActiveRecord::Base ActsAsTaggableOn.strict_case_match = true belongs_to :project + belongs_to :moved_to, class_name: 'Issue' + validates :project, presence: true scope :of_group, @@ -137,6 +140,18 @@ class Issue < ActiveRecord::Base end.uniq.select { |mr| mr.open? && mr.closes_issue?(self) } end + def moved? + !moved_to.nil? + end + + def can_move?(user, to_project = nil) + if to_project + return false unless user.can?(:admin_issue, to_project) + end + + !moved? && user.can?(:admin_issue, self.project) + end + def to_branch_name "#{title.parameterize}-#{iid}" end |