Describe for Roles
This commit is contained in:
parent
64db5f808b
commit
82ae973a99
11 changed files with 75 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
# == Account role
|
||||||
|
#
|
||||||
|
# Describe behaviour of User in application
|
||||||
|
#
|
||||||
|
# Used by User
|
||||||
|
#
|
||||||
module Account
|
module Account
|
||||||
# Returns a string for use as a Gitolite user identifier
|
# Returns a string for use as a Gitolite user identifier
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
# == Authority role
|
||||||
|
#
|
||||||
|
# Control access to project repository based on users role in team
|
||||||
|
#
|
||||||
|
# Used by Project
|
||||||
|
#
|
||||||
module Authority
|
module Authority
|
||||||
# Compatible with all access rights
|
# Compatible with all access rights
|
||||||
# Should be rewrited for new access rights
|
# Should be rewrited for new access rights
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
# == GitHost role
|
||||||
|
#
|
||||||
|
# Provide a shortcut to Gitlab::Gitolite instance
|
||||||
|
#
|
||||||
|
# Used by Project, UsersProject
|
||||||
|
#
|
||||||
module GitHost
|
module GitHost
|
||||||
def git_host
|
def git_host
|
||||||
Gitlab::Gitolite.new
|
Gitlab::Gitolite.new
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
# == IssueCommonality role
|
||||||
|
#
|
||||||
# Contains common functionality shared between Issues and MergeRequests
|
# Contains common functionality shared between Issues and MergeRequests
|
||||||
|
#
|
||||||
|
# Used by Issue, MergeRequest
|
||||||
|
#
|
||||||
module IssueCommonality
|
module IssueCommonality
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
# == NamespacedProject role
|
||||||
|
#
|
||||||
|
# Provides extra functionality for Project related to namespaces like:
|
||||||
|
# - transfer project between namespaces
|
||||||
|
# - name, path including namespece
|
||||||
|
# - project owner based on namespace
|
||||||
|
#
|
||||||
|
# Used by Project
|
||||||
|
#
|
||||||
module NamespacedProject
|
module NamespacedProject
|
||||||
def transfer(new_namespace)
|
def transfer(new_namespace)
|
||||||
Project.transaction do
|
Project.transaction do
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
# == NoteEvent role
|
||||||
|
#
|
||||||
|
# Extends Event model functionality by providing extra methods related to comment events
|
||||||
|
#
|
||||||
|
# Used by Event
|
||||||
|
#
|
||||||
module NoteEvent
|
module NoteEvent
|
||||||
def note_commit_id
|
def note_commit_id
|
||||||
target.commit_id
|
target.commit_id
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
# == PushEvent role
|
||||||
|
#
|
||||||
|
# Extends Event model functionality by providing extra methods related to push events
|
||||||
|
#
|
||||||
|
# Used by Event
|
||||||
|
#
|
||||||
module PushEvent
|
module PushEvent
|
||||||
def valid_push?
|
def valid_push?
|
||||||
data[:ref]
|
data[:ref]
|
||||||
|
@ -58,7 +64,7 @@ module PushEvent
|
||||||
@commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse
|
@commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
def commits_count
|
def commits_count
|
||||||
data[:total_commits_count] || commits.count || 0
|
data[:total_commits_count] || commits.count || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,7 +94,7 @@ module PushEvent
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_with_commits?
|
def push_with_commits?
|
||||||
md_ref? && commits.any? && parent_commit && last_commit
|
md_ref? && commits.any? && parent_commit && last_commit
|
||||||
rescue Grit::NoSuchPathError
|
rescue Grit::NoSuchPathError
|
||||||
false
|
false
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
# Includes methods for handling Git Push events
|
# == PushObserver role
|
||||||
#
|
#
|
||||||
|
# Includes methods to be triggered on push to project repository.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Used by Project
|
||||||
# Triggered by PostReceive job
|
# Triggered by PostReceive job
|
||||||
|
#
|
||||||
module PushObserver
|
module PushObserver
|
||||||
# This method will be called after each post receive and only if the provided
|
# This method will be called after each post receive and only if the provided
|
||||||
# user is present in GitLab.
|
# user is present in GitLab.
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
# == Repository role
|
||||||
|
#
|
||||||
|
# Provides access to git repository resources like commits, branches etc..
|
||||||
|
# Allows you to manage repository via gitolite interface(git_host)
|
||||||
|
#
|
||||||
|
# Used by Project
|
||||||
|
#
|
||||||
module Repository
|
module Repository
|
||||||
include GitHost
|
include GitHost
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
# == Team role
|
||||||
|
#
|
||||||
|
# Provides functionality to manage project team
|
||||||
|
# - add user/users to project
|
||||||
|
# - update existing membership
|
||||||
|
# - remove users from project team
|
||||||
|
#
|
||||||
|
# Used by Project
|
||||||
|
#
|
||||||
module Team
|
module Team
|
||||||
def team_member_by_name_or_email(name = nil, email = nil)
|
def team_member_by_name_or_email(name = nil, email = nil)
|
||||||
user = users.where("name like ? or email like ?", name, email).first
|
user = users.where("name like ? or email like ?", name, email).first
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
# == Votes role
|
||||||
|
#
|
||||||
|
# Provides functionality to upvote/downvote entity
|
||||||
|
# based on +1 and -1 notes
|
||||||
|
#
|
||||||
|
# Used for Issue and Merge Request
|
||||||
|
#
|
||||||
module Votes
|
module Votes
|
||||||
# Return the number of +1 comments (upvotes)
|
# Return the number of +1 comments (upvotes)
|
||||||
def upvotes
|
def upvotes
|
||||||
|
|
Loading…
Add table
Reference in a new issue