diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-08 13:56:37 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-08 13:56:37 +0300 |
commit | 1f98beba79b16fc0167f8b3396b58d047edade37 (patch) | |
tree | 12eff99624dbeb61135919b1261f574681792087 /app/models | |
parent | 8ce11fc388bc168368b1e0a65659bb45c76a4a08 (diff) | |
parent | 13bd4b028a5d83e63026dc0023c090c677fceb3b (diff) |
Merge branch 'clean-up-project-for-merge-conflicts' into 'master'
Clean up the Project model to reduce conflicts
See merge request !11967
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 0caf7387450..4c394646787 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -63,16 +63,6 @@ class Project < ActiveRecord::Base # update visibility_level of forks after_update :update_forks_visibility_level - def update_forks_visibility_level - return unless visibility_level < visibility_level_was - - forks.each do |forked_project| - if forked_project.visibility_level > visibility_level - forked_project.visibility_level = visibility_level - forked_project.save! - end - end - end after_validation :check_pending_delete @@ -165,7 +155,7 @@ class Project < ActiveRecord::Base has_many :todos, dependent: :destroy has_many :notification_settings, dependent: :destroy, as: :source - has_one :import_data, dependent: :delete, class_name: "ProjectImportData" + has_one :import_data, dependent: :delete, class_name: 'ProjectImportData' has_one :project_feature, dependent: :destroy has_one :statistics, class_name: 'ProjectStatistics', dependent: :delete has_many :container_repositories, dependent: :destroy @@ -488,7 +478,11 @@ class Project < ActiveRecord::Base ProjectCacheWorker.perform_async(self.id) end - self.import_data&.destroy + remove_import_data + end + + def remove_import_data + import_data&.destroy end def import_url=(value) @@ -1060,6 +1054,17 @@ class Project < ActiveRecord::Base !!repository.exists? end + def update_forks_visibility_level + return unless visibility_level < visibility_level_was + + forks.each do |forked_project| + if forked_project.visibility_level > visibility_level + forked_project.visibility_level = visibility_level + forked_project.save! + end + end + end + def create_wiki ProjectWiki.new(self, self.owner).wiki true @@ -1068,6 +1073,10 @@ class Project < ActiveRecord::Base false end + def wiki + @wiki ||= ProjectWiki.new(self, self.owner) + end + def jira_tracker_active? jira_tracker? && jira_service.active end @@ -1190,10 +1199,6 @@ class Project < ActiveRecord::Base end end - def wiki - @wiki ||= ProjectWiki.new(self, self.owner) - end - def running_or_pending_build_count(force: false) Rails.cache.fetch(['projects', id, 'running_or_pending_build_count'], force: force) do builds.running_or_pending.count(:all) |