diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-03-16 01:29:07 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-03-31 21:37:01 +0300 |
commit | 91ed8ed687ee9edbda0098475e66ad41f886d7a5 (patch) | |
tree | 7a446fa1048484d2ccb25a37e7ce650884b7d76f /app/models/concerns/protected_tag_access.rb | |
parent | 1a416a42f1c1b876ecd96687e41696bc915cc2c2 (diff) |
Protected tags copy/paste from protected branches
Should provide basic CRUD backend for frontend to work from. Doesn’t include frontend, API, or the internal API used from gitlab-shell
Diffstat (limited to 'app/models/concerns/protected_tag_access.rb')
-rw-r--r-- | app/models/concerns/protected_tag_access.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/concerns/protected_tag_access.rb b/app/models/concerns/protected_tag_access.rb new file mode 100644 index 00000000000..cf66a6434b5 --- /dev/null +++ b/app/models/concerns/protected_tag_access.rb @@ -0,0 +1,21 @@ +module ProtectedTagAccess + extend ActiveSupport::Concern + + included do + belongs_to :protected_tag + delegate :project, to: :protected_tag + + scope :master, -> { where(access_level: Gitlab::Access::MASTER) } + scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) } + end + + def humanize + self.class.human_access_levels[self.access_level] + end + + def check_access(user) + return true if user.is_admin? + + project.team.max_member_access(user.id) >= access_level + end +end |