Skip to content
Snippets Groups Projects
Commit 82ae973a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Describe for Roles

parent 64db5f80
No related branches found
No related tags found
No related merge requests found
# == Account role
#
# Describe behaviour of User in application
#
# Used by User
#
module Account
# Returns a string for use as a Gitolite user identifier
#
Loading
Loading
# == Authority role
#
# Control access to project repository based on users role in team
#
# Used by Project
#
module Authority
# Compatible with all access rights
# Should be rewrited for new access rights
Loading
Loading
# == GitHost role
#
# Provide a shortcut to Gitlab::Gitolite instance
#
# Used by Project, UsersProject
#
module GitHost
def git_host
Gitlab::Gitolite.new
Loading
Loading
# == IssueCommonality role
#
# Contains common functionality shared between Issues and MergeRequests
#
# Used by Issue, MergeRequest
#
module IssueCommonality
extend ActiveSupport::Concern
 
Loading
Loading
# == 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
def transfer(new_namespace)
Project.transaction do
Loading
Loading
# == NoteEvent role
#
# Extends Event model functionality by providing extra methods related to comment events
#
# Used by Event
#
module NoteEvent
def note_commit_id
target.commit_id
Loading
Loading
# == PushEvent role
#
# Extends Event model functionality by providing extra methods related to push events
#
# Used by Event
#
module PushEvent
def valid_push?
data[:ref]
Loading
Loading
@@ -58,7 +64,7 @@ module PushEvent
@commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse
end
 
def commits_count
def commits_count
data[:total_commits_count] || commits.count || 0
end
 
Loading
Loading
@@ -88,7 +94,7 @@ module PushEvent
nil
end
 
def push_with_commits?
def push_with_commits?
md_ref? && commits.any? && parent_commit && last_commit
rescue Grit::NoSuchPathError
false
Loading
Loading
# 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
#
module PushObserver
# This method will be called after each post receive and only if the provided
# user is present in GitLab.
Loading
Loading
# == 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
include GitHost
 
Loading
Loading
# == 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
def team_member_by_name_or_email(name = nil, email = nil)
user = users.where("name like ? or email like ?", name, email).first
Loading
Loading
# == Votes role
#
# Provides functionality to upvote/downvote entity
# based on +1 and -1 notes
#
# Used for Issue and Merge Request
#
module Votes
# Return the number of +1 comments (upvotes)
def upvotes
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment