summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-21 19:28:48 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-21 19:28:48 +0000
commit4a1680261513926f0fa4634bae02e8d599d47050 (patch)
tree8b48f8e7c8fbb570aa563c4a0f3444e8991a0f1a /app/models
parent642f56c6465b5f2e0f4e44e59e018391f43d1acf (diff)
parent6e5461c6ee8b408e35324b32c0b5ba99328ec763 (diff)
downloadgitlab-ce-4a1680261513926f0fa4634bae02e8d599d47050.tar.gz
Merge branch '2489-soft-delete-issues' into 'master'
Soft delete issuables Fixes #2489 What still needs to happen: research on the indexes, the gem suggests a [lot of changes](https://github.com/rubysherpas/paranoia#about-indexes) though this is probably a good idea to discuss and I'm unsure on the impact of an omnibus upgrade as I suspect creating about 10 new indexes has a large impact on the downtime. TODO: - [x] Also group owners can ***soft*** delete - [x] Button should be hidden See merge request !2982
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ability.rb4
-rw-r--r--app/models/concerns/internal_id.rb5
-rw-r--r--app/models/concerns/issuable.rb2
3 files changed, 9 insertions, 2 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index e22da4806e6..40c529e8117 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -235,7 +235,9 @@ class Ability
:rename_project,
:remove_project,
:archive_project,
- :remove_fork_project
+ :remove_fork_project,
+ :destroy_merge_request,
+ :destroy_issue
]
end
diff --git a/app/models/concerns/internal_id.rb b/app/models/concerns/internal_id.rb
index 821ed54fb98..51288094ef1 100644
--- a/app/models/concerns/internal_id.rb
+++ b/app/models/concerns/internal_id.rb
@@ -7,7 +7,10 @@ module InternalId
end
def set_iid
- max_iid = project.send(self.class.name.tableize).maximum(:iid)
+ records = project.send(self.class.name.tableize)
+ records = records.with_deleted if self.paranoid?
+ max_iid = records.maximum(:iid)
+
self.iid = max_iid.to_i + 1
end
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 9ab72652190..476e1ce7af0 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -58,6 +58,8 @@ module Issuable
attr_mentionable :description, cache: true
participant :author, :assignee, :notes_with_associations
strip_attributes :title
+
+ acts_as_paranoid
end
module ClassMethods