diff options
author | James Lopez <james@jameslopez.es> | 2016-07-21 11:40:49 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-01-11 15:07:09 +0100 |
commit | d3cfa39e3cb7a4a04f3f42d00c4740d317690bbc (patch) | |
tree | b7553bcc4875f95d1dddaf3a7d41e932a0afeb53 /app/models/project.rb | |
parent | 4404ea8662508c60f96e6730d9a45feb68498c28 (diff) | |
download | gitlab-ce-fix/project-delete-tooltip.tar.gz |
New error message recreating projects on pending deletefix/project-delete-tooltip
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 94a6f3ba799..c22386c84e9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -12,6 +12,7 @@ class Project < ActiveRecord::Base include AfterCommitQueue include CaseSensitivity include TokenAuthenticatable + include ValidAttribute include ProjectFeaturesCompatibility include SelectForProjectAuthorization include Routable @@ -65,6 +66,8 @@ class Project < ActiveRecord::Base end end + after_validation :check_pending_delete + ActsAsTaggableOn.strict_case_match = true acts_as_taggable_on :tags @@ -1320,4 +1323,21 @@ class Project < ActiveRecord::Base stats = statistics || build_statistics stats.update(namespace_id: namespace_id) end + + def check_pending_delete + return if valid_attribute?(:name) && valid_attribute?(:path) + return unless pending_delete_twin + + %i[route route.path name path].each do |error| + errors.delete(error) + end + + errors.add(:base, "The project is still being deleted. Please try again later.") + end + + def pending_delete_twin + return false unless path + + Project.unscoped.where(pending_delete: true).find_with_namespace(path_with_namespace) + end end |