summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-03 09:07:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-03 09:07:54 +0000
commit87ef501eacd66d7166183d20d84e33de022f7002 (patch)
treefa4e0f41e00a4b6aeb035530be4b5473f51b7a3d /app/models
parentf321e51f46bcb628c3e96a44b5ebf3bb1c4033ab (diff)
downloadgitlab-ce-87ef501eacd66d7166183d20d84e33de022f7002.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/appearance.rb2
-rw-r--r--app/models/application_setting_implementation.rb2
-rw-r--r--app/models/ci/job_artifact.rb2
-rw-r--r--app/models/clusters/applications/ingress.rb2
-rw-r--r--app/models/clusters/cluster.rb4
-rw-r--r--app/models/concerns/has_repository.rb2
-rw-r--r--app/models/concerns/milestoneable.rb2
-rw-r--r--app/models/concerns/time_trackable.rb2
-rw-r--r--app/models/deploy_token.rb2
-rw-r--r--app/models/description_version.rb8
-rw-r--r--app/models/external_pull_request.rb2
-rw-r--r--app/models/milestone_release.rb2
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/project_ci_cd_setting.rb2
-rw-r--r--app/models/project_services/issue_tracker_service.rb2
-rw-r--r--app/models/prometheus_alert.rb4
-rw-r--r--app/models/resource_event.rb5
-rw-r--r--app/models/sent_notification.rb5
-rw-r--r--app/models/timelog.rb4
-rw-r--r--app/models/user.rb7
-rw-r--r--app/models/user_detail.rb7
21 files changed, 48 insertions, 22 deletions
diff --git a/app/models/appearance.rb b/app/models/appearance.rb
index 1104b676bc4..9da4dfd43b5 100644
--- a/app/models/appearance.rb
+++ b/app/models/appearance.rb
@@ -38,7 +38,7 @@ class Appearance < ApplicationRecord
def single_appearance_row
if self.class.any?
- errors.add(:single_appearance_row, 'Only 1 appearances row can exist')
+ errors.add(:base, _('Only 1 appearances row can exist'))
end
end
diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb
index a9856203cc0..98b8981754f 100644
--- a/app/models/application_setting_implementation.rb
+++ b/app/models/application_setting_implementation.rb
@@ -389,7 +389,7 @@ module ApplicationSettingImplementation
def terms_exist
return unless enforce_terms?
- errors.add(:terms, "You need to set terms to be enforced") unless terms.present?
+ errors.add(:base, _('You need to set terms to be enforced')) unless terms.present?
end
def expire_performance_bar_allowed_user_ids_cache
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index 8defe742ec4..f9a5f713814 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -148,7 +148,7 @@ module Ci
def valid_file_format?
unless TYPE_AND_FORMAT_PAIRS[self.file_type&.to_sym] == self.file_format&.to_sym
- errors.add(:file_format, 'Invalid file format with specified file type')
+ errors.add(:base, _('Invalid file format with specified file type'))
end
end
diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb
index bdd7ad90fba..233920f4fe2 100644
--- a/app/models/clusters/applications/ingress.rb
+++ b/app/models/clusters/applications/ingress.rb
@@ -3,7 +3,7 @@
module Clusters
module Applications
class Ingress < ApplicationRecord
- VERSION = '1.29.3'
+ VERSION = '1.29.7'
MODSECURITY_LOG_CONTAINER_NAME = 'modsecurity-log'
self.table_name = 'clusters_applications_ingress'
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 6e890de924e..7f155a8d435 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -306,7 +306,7 @@ module Clusters
.where.not(id: id)
if duplicate_management_clusters.any?
- errors.add(:environment_scope, "cannot add duplicated environment scope")
+ errors.add(:environment_scope, 'cannot add duplicated environment scope')
end
end
@@ -380,7 +380,7 @@ module Clusters
def restrict_modification
if provider&.on_creation?
- errors.add(:base, "cannot modify during creation")
+ errors.add(:base, _('Cannot modify provider during creation'))
return false
end
diff --git a/app/models/concerns/has_repository.rb b/app/models/concerns/has_repository.rb
index d04a6408a21..0887236e65e 100644
--- a/app/models/concerns/has_repository.rb
+++ b/app/models/concerns/has_repository.rb
@@ -19,7 +19,7 @@ module HasRepository
def valid_repo?
repository.exists?
rescue
- errors.add(:path, _('Invalid repository path'))
+ errors.add(:base, _('Invalid repository path'))
false
end
diff --git a/app/models/concerns/milestoneable.rb b/app/models/concerns/milestoneable.rb
index 7df6981a129..3ffb32f94fc 100644
--- a/app/models/concerns/milestoneable.rb
+++ b/app/models/concerns/milestoneable.rb
@@ -37,7 +37,7 @@ module Milestoneable
private
def milestone_is_valid
- errors.add(:milestone_id, message: "is invalid") if respond_to?(:milestone_id) && milestone_id.present? && !milestone_available?
+ errors.add(:milestone_id, 'is invalid') if respond_to?(:milestone_id) && milestone_id.present? && !milestone_available?
end
end
diff --git a/app/models/concerns/time_trackable.rb b/app/models/concerns/time_trackable.rb
index f61a0bbc65b..dddf96837b7 100644
--- a/app/models/concerns/time_trackable.rb
+++ b/app/models/concerns/time_trackable.rb
@@ -77,7 +77,7 @@ module TimeTrackable
return if time_spent.nil? || time_spent == :reset
if time_spent < 0 && (time_spent.abs > original_total_time_spent)
- errors.add(:time_spent, 'Time to subtract exceeds the total time spent')
+ errors.add(:base, _('Time to subtract exceeds the total time spent'))
end
end
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index 31c813edb67..a9844f627b7 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -105,7 +105,7 @@ class DeployToken < ApplicationRecord
end
def ensure_at_least_one_scope
- errors.add(:base, "Scopes can't be blank") unless read_repository || read_registry
+ errors.add(:base, _("Scopes can't be blank")) unless read_repository || read_registry
end
def default_username
diff --git a/app/models/description_version.rb b/app/models/description_version.rb
index 05362a2f90b..f69564f4893 100644
--- a/app/models/description_version.rb
+++ b/app/models/description_version.rb
@@ -19,7 +19,13 @@ class DescriptionVersion < ApplicationRecord
def exactly_one_issuable
issuable_count = self.class.issuable_attrs.count { |attr| self["#{attr}_id"] }
- errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(', ')} is required") if issuable_count != 1
+ if issuable_count != 1
+ errors.add(
+ :base,
+ _("Exactly one of %{attributes} is required") %
+ { attributes: self.class.issuable_attrs.join(', ') }
+ )
+ end
end
end
diff --git a/app/models/external_pull_request.rb b/app/models/external_pull_request.rb
index 65ae8d95500..9c6d05f773a 100644
--- a/app/models/external_pull_request.rb
+++ b/app/models/external_pull_request.rb
@@ -78,7 +78,7 @@ class ExternalPullRequest < ApplicationRecord
def not_from_fork
if from_fork?
- errors.add(:base, 'Pull requests from fork are not supported')
+ errors.add(:base, _('Pull requests from fork are not supported'))
end
end
diff --git a/app/models/milestone_release.rb b/app/models/milestone_release.rb
index 713c8ef7b94..0a6165c8254 100644
--- a/app/models/milestone_release.rb
+++ b/app/models/milestone_release.rb
@@ -11,6 +11,6 @@ class MilestoneRelease < ApplicationRecord
def same_project_between_milestone_and_release
return if milestone&.project_id == release&.project_id
- errors.add(:base, 'does not have the same project as the milestone')
+ errors.add(:base, _('Release does not have the same project as the milestone'))
end
end
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index fbc010c6b7c..631bd930e2f 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -376,7 +376,7 @@ class Namespace < ApplicationRecord
def nesting_level_allowed
if ancestors.count > Group::NUMBER_OF_ANCESTORS_ALLOWED
- errors.add(:parent_id, "has too deep level of nesting")
+ errors.add(:parent_id, 'has too deep level of nesting')
end
end
diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb
index b26a3025b61..39e177e8bd8 100644
--- a/app/models/project_ci_cd_setting.rb
+++ b/app/models/project_ci_cd_setting.rb
@@ -31,7 +31,7 @@ class ProjectCiCdSetting < ApplicationRecord
end
def forward_deployment_enabled?
- super && ::Feature.enabled?(:forward_deployment_enabled, project)
+ super && ::Feature.enabled?(:forward_deployment_enabled, project, default_enabled: true)
end
private
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb
index 7cdbb124dee..2bf14a6ed25 100644
--- a/app/models/project_services/issue_tracker_service.rb
+++ b/app/models/project_services/issue_tracker_service.rb
@@ -168,7 +168,7 @@ class IssueTrackerService < Service
return if project.blank?
if project.services.external_issue_trackers.where.not(id: id).any?
- errors.add(:base, 'Another issue tracker is already in use. Only one issue tracker service can be active at a time')
+ errors.add(:base, _('Another issue tracker is already in use. Only one issue tracker service can be active at a time'))
end
end
end
diff --git a/app/models/prometheus_alert.rb b/app/models/prometheus_alert.rb
index 1014231102f..1dc7dc73e31 100644
--- a/app/models/prometheus_alert.rb
+++ b/app/models/prometheus_alert.rb
@@ -69,13 +69,13 @@ class PrometheusAlert < ApplicationRecord
def require_valid_environment_project!
return if project == environment&.project
- errors.add(:environment, "invalid project")
+ errors.add(:environment, 'invalid project')
end
def require_valid_metric_project!
return if prometheus_metric&.common?
return if project == prometheus_metric&.project
- errors.add(:prometheus_metric, "invalid project")
+ errors.add(:prometheus_metric, 'invalid project')
end
end
diff --git a/app/models/resource_event.rb b/app/models/resource_event.rb
index 9b3a211ad43..2c0052b0be3 100644
--- a/app/models/resource_event.rb
+++ b/app/models/resource_event.rb
@@ -37,6 +37,9 @@ class ResourceEvent < ApplicationRecord
return true if issuable_count == 1
end
- errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(', ')} is required")
+ errors.add(
+ :base, _("Exactly one of %{attributes} is required") %
+ { attributes: self.class.issuable_attrs.join(', ') }
+ )
end
end
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 0427d5b9ca7..f3a9293376f 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -111,7 +111,10 @@ class SentNotification < ApplicationRecord
note = create_reply('Test', dryrun: true)
unless note.valid?
- self.errors.add(:base, "Note parameters are invalid: #{note.errors.full_messages.to_sentence}")
+ self.errors.add(
+ :base, _("Note parameters are invalid: %{errors}") %
+ { errors: note.errors.full_messages.to_sentence }
+ )
end
end
diff --git a/app/models/timelog.rb b/app/models/timelog.rb
index 4ddaf6bcb86..f52dd74d4c9 100644
--- a/app/models/timelog.rb
+++ b/app/models/timelog.rb
@@ -28,9 +28,9 @@ class Timelog < ApplicationRecord
def issuable_id_is_present
if issue_id && merge_request_id
- errors.add(:base, 'Only Issue ID or Merge Request ID is required')
+ errors.add(:base, _('Only Issue ID or Merge Request ID is required'))
elsif issuable.nil?
- errors.add(:base, 'Issue or Merge Request ID is required')
+ errors.add(:base, _('Issue or Merge Request ID is required'))
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index f3db0522edc..81cabc67c3b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -162,6 +162,7 @@ class User < ApplicationRecord
has_one :status, class_name: 'UserStatus'
has_one :user_preference
+ has_one :user_detail
#
# Validations
@@ -259,8 +260,10 @@ class User < ApplicationRecord
delegate :sourcegraph_enabled, :sourcegraph_enabled=, to: :user_preference
delegate :setup_for_company, :setup_for_company=, to: :user_preference
delegate :render_whitespace_in_code, :render_whitespace_in_code=, to: :user_preference
+ delegate :job_title, :job_title=, to: :user_detail, allow_nil: true
accepts_nested_attributes_for :user_preference, update_only: true
+ accepts_nested_attributes_for :user_detail, update_only: true
state_machine :state, initial: :active do
event :block do
@@ -1619,6 +1622,10 @@ class User < ApplicationRecord
super.presence || build_user_preference
end
+ def user_detail
+ super.presence || build_user_detail
+ end
+
def todos_limited_to(ids)
todos.where(id: ids)
end
diff --git a/app/models/user_detail.rb b/app/models/user_detail.rb
new file mode 100644
index 00000000000..1621f336111
--- /dev/null
+++ b/app/models/user_detail.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class UserDetail < ApplicationRecord
+ belongs_to :user
+
+ validates :job_title, presence: true, length: { maximum: 200 }
+end