diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-30 13:13:49 +0300 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-30 13:13:49 +0300 |
commit | 759f102df09a7877ae68ab05b87d3a434f588067 (patch) | |
tree | e5f002acff468f5e84ade40c31e5e4b991899f1e /app/models | |
parent | adff7923ca3088df9e07ccd60d6f9fa24fbdbfc5 (diff) | |
parent | 03f13af588cf2b578a27717db492c216fcafbf9a (diff) |
Merge branch 'master' into balsalmiq-support
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/blob.rb | 2 | ||||
-rw-r--r-- | app/models/blob_viewer/video.rb | 12 | ||||
-rw-r--r-- | app/models/label.rb | 1 | ||||
-rw-r--r-- | app/models/member.rb | 5 | ||||
-rw-r--r-- | app/models/todo.rb | 12 |
5 files changed, 32 insertions, 0 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index 1694f4e6dc9..934dd2b9a4f 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -28,6 +28,8 @@ class Blob < SimpleDelegator BlobViewer::Sketch, BlobViewer::Balsamiq, + BlobViewer::Video, + BlobViewer::PDF, BlobViewer::BinarySTL, diff --git a/app/models/blob_viewer/video.rb b/app/models/blob_viewer/video.rb new file mode 100644 index 00000000000..057f9fe516f --- /dev/null +++ b/app/models/blob_viewer/video.rb @@ -0,0 +1,12 @@ +module BlobViewer + class Video < Base + include Rich + include ClientSide + + self.partial_name = 'video' + self.extensions = UploaderHelper::VIDEO_EXT + self.binary = true + self.switcher_icon = 'film' + self.switcher_title = 'video' + end +end diff --git a/app/models/label.rb b/app/models/label.rb index d8b0e250732..ddddb6bdf8f 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -34,6 +34,7 @@ class Label < ActiveRecord::Base scope :templates, -> { where(template: true) } scope :with_title, ->(title) { where(title: title) } + scope :on_project_boards, ->(project_id) { joins(lists: :board).merge(List.movable).where(boards: { project_id: project_id }) } def self.prioritized(project) joins(:priorities) diff --git a/app/models/member.rb b/app/models/member.rb index 97fba501759..7228e82e978 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -154,6 +154,11 @@ class Member < ActiveRecord::Base def add_users(source, users, access_level, current_user: nil, expires_at: nil) return [] unless users.present? + # Collect all user ids into separate array + # so we can use single sql query to get user objects + user_ids = users.select { |user| user =~ /\A\d+\Z/ } + users = users - user_ids + User.where(id: user_ids) + self.transaction do users.map do |user| add_user( diff --git a/app/models/todo.rb b/app/models/todo.rb index da3fa7277c2..b011001b235 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -84,6 +84,10 @@ class Todo < ActiveRecord::Base action == BUILD_FAILED end + def assigned? + action == ASSIGNED + end + def action_name ACTION_NAMES[action] end @@ -117,6 +121,14 @@ class Todo < ActiveRecord::Base end end + def self_added? + author == user + end + + def self_assigned? + assigned? && self_added? + end + private def keep_around_commit |