Commit a442ad2b141e078fcc2899ece6068b82b5338bb8
1 parent
7daf3947
Exists in
master
and in
4 other branches
Added Gitlab::Access module
Showing
1 changed file
with
48 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,48 @@ |
1 | +# Gitlab::Access module | |
2 | +# | |
3 | +# Define allowed roles that can be used | |
4 | +# in GitLab code to determine authorization level | |
5 | +# | |
6 | +module Gitlab | |
7 | + module Access | |
8 | + GUEST = 10 | |
9 | + REPORTER = 20 | |
10 | + DEVELOPER = 30 | |
11 | + MASTER = 40 | |
12 | + OWNER = 50 | |
13 | + | |
14 | + class << self | |
15 | + def values | |
16 | + options.values | |
17 | + end | |
18 | + | |
19 | + def options | |
20 | + { | |
21 | + "Guest" => GUEST, | |
22 | + "Reporter" => REPORTER, | |
23 | + "Developer" => DEVELOPER, | |
24 | + "Master" => MASTER, | |
25 | + } | |
26 | + end | |
27 | + | |
28 | + def options_with_owner | |
29 | + options.merge( | |
30 | + "Owner" => OWNER | |
31 | + ) | |
32 | + end | |
33 | + | |
34 | + def sym_options | |
35 | + { | |
36 | + guest: GUEST, | |
37 | + reporter: REPORTER, | |
38 | + developer: DEVELOPER, | |
39 | + master: MASTER, | |
40 | + } | |
41 | + end | |
42 | + end | |
43 | + | |
44 | + def human_access | |
45 | + Gitlab::Access.options_with_owner.key(access_field) | |
46 | + end | |
47 | + end | |
48 | +end | ... | ... |