1 import json
2 from datetime import date
3 from coprs import exceptions
4 from flask import url_for
5
6 from coprs import app, db
7 from coprs.models import User, Group
8 from coprs.helpers import copr_url
9 from sqlalchemy import update
13
14 @classmethod
15 - def get(cls, username):
17
18 @classmethod
21
22 @classmethod
24 """
25 Raise InsufficientRightsException if given user cant update
26 given copr. Return None otherwise.
27 """
28
29
30
31 if not user.can_edit(copr):
32 raise exceptions.InsufficientRightsException(message)
33
34 @classmethod
36 """
37 Raises InsufficientRightsException if given user cant build in
38 given copr. Return None otherwise.
39 """
40
41 if not user.can_build_in(copr):
42 raise exceptions.InsufficientRightsException(message)
43
44 @classmethod
50
51 @classmethod
54
55 @classmethod
59
60 @classmethod
63
64 @classmethod
67
68 @classmethod
71
72 @classmethod
83
84 @classmethod
93
94 @classmethod
96 """ removes blacklisted groups from teams list
97 :type teams: list of str
98 :return: filtered teams
99 :rtype: list of str
100 """
101 blacklist = set(app.config.get("BLACKLISTED_GROUPS", []))
102 return filter(lambda t: t not in blacklist, teams)
103
104 @classmethod
106 if "BLACKLISTED_GROUPS" in app.config:
107 return fas_group in app.config["BLACKLISTED_GROUPS"]
108 else:
109 return False
110
111 @classmethod
113 null = {"timezone": None,
114 "proven": False,
115 "admin": False,
116 "proxy": False,
117 "api_login": "",
118 "api_token": "",
119 "api_token_expiration": date(1970, 1, 1),
120 "openid_groups": None}
121 for k, v in null.items():
122 setattr(user, k, v)
123
128
129 - def dumps(self, pretty=False):
130 if pretty:
131 return json.dumps(self.data, indent=2)
132 return json.dumps(self.data)
133
134 @property
141
142 @property
153
154 @property
159
160 @property
167
168 @property
174