Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <ruben@gitlab.com>2018-02-07 16:00:53 +0300
committerRubén Dávila <ruben@gitlab.com>2018-02-07 17:04:00 +0300
commitbed948321173b49564f39837e97212ee4dd96e03 (patch)
tree72e6faa9f68378f997f876cf9550561bad546028 /app/models/lfs_file_lock.rb
parentead97c55eac773444dee547a934112aa282c2e2e (diff)
Backport of LFS File Locking API
Diffstat (limited to 'app/models/lfs_file_lock.rb')
-rw-r--r--app/models/lfs_file_lock.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/lfs_file_lock.rb b/app/models/lfs_file_lock.rb
new file mode 100644
index 00000000000..50bb6ca382d
--- /dev/null
+++ b/app/models/lfs_file_lock.rb
@@ -0,0 +1,12 @@
+class LfsFileLock < ActiveRecord::Base
+ belongs_to :project
+ belongs_to :user
+
+ validates :project_id, :user_id, :path, presence: true
+
+ def can_be_unlocked_by?(current_user, forced = false)
+ return true if current_user.id == user_id
+
+ forced && current_user.can?(:admin_project, project)
+ end
+end