summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb26
1 files changed, 18 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 0ede6c6b139..9dca63f124b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -5,7 +5,6 @@ class Project < ActiveRecord::Base
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
include Gitlab::CurrentSettings
- include AccessRequestable
include Referable
include Sortable
include AfterCommitQueue
@@ -81,7 +80,7 @@ class Project < ActiveRecord::Base
has_one :jira_service, dependent: :destroy
has_one :redmine_service, dependent: :destroy
has_one :custom_issue_tracker_service, dependent: :destroy
- has_one :gitlab_issue_tracker_service, dependent: :destroy, inverse_of: :project
+ has_one :gitlab_issue_tracker_service, dependent: :destroy
has_one :external_wiki_service, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
@@ -103,9 +102,8 @@ class Project < ActiveRecord::Base
has_many :snippets, dependent: :destroy, class_name: 'ProjectSnippet'
has_many :hooks, dependent: :destroy, class_name: 'ProjectHook'
has_many :protected_branches, dependent: :destroy
- has_many :project_members, dependent: :destroy, as: :source, class_name: 'ProjectMember'
- alias_method :members, :project_members
- has_many :users, -> { where(members: { requested_at: nil }) }, through: :project_members
+ has_many :project_members, dependent: :destroy, as: :source, class_name: 'ProjectMember'
+ has_many :users, through: :project_members
has_many :deploy_keys_projects, dependent: :destroy
has_many :deploy_keys, through: :deploy_keys_projects
has_many :users_star_projects, dependent: :destroy
@@ -127,8 +125,6 @@ class Project < ActiveRecord::Base
has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
has_many :variables, dependent: :destroy, class_name: 'Ci::Variable', foreign_key: :gl_project_id
has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger', foreign_key: :gl_project_id
- has_many :environments, dependent: :destroy
- has_many :deployments, dependent: :destroy
accepts_nested_attributes_for :variables, allow_destroy: true
@@ -150,6 +146,7 @@ class Project < ActiveRecord::Base
message: Gitlab::Regex.project_path_regex_message }
validates :issues_enabled, :merge_requests_enabled,
:wiki_enabled, inclusion: { in: [true, false] }
+ validates :issues_tracker_id, length: { maximum: 255 }, allow_blank: true
validates :namespace, presence: true
validates_uniqueness_of :name, scope: :namespace_id
validates_uniqueness_of :path, scope: :namespace_id
@@ -592,6 +589,10 @@ class Project < ActiveRecord::Base
update_column(:has_external_issue_tracker, services.external_issue_trackers.any?)
end
+ def can_have_issues_tracker_id?
+ self.issues_enabled && !self.default_issues_tracker?
+ end
+
def build_missing_services
services_templates = Service.where(template: true)
@@ -684,6 +685,16 @@ class Project < ActiveRecord::Base
end
end
+ def project_member_by_name_or_email(name = nil, email = nil)
+ user = users.find_by('name like ? or email like ?', name, email)
+ project_members.where(user: user) if user
+ end
+
+ # Get Team Member record by user id
+ def project_member_by_id(user_id)
+ project_members.find_by(user_id: user_id)
+ end
+
def name_with_namespace
@name_with_namespace ||= begin
if namespace
@@ -693,7 +704,6 @@ class Project < ActiveRecord::Base
end
end
end
- alias_method :human_name, :name_with_namespace
def path_with_namespace
if namespace