Show More
@@ -32,6 +32,7 b' def trigger_user_permission_flush(event)' | |||
|
32 | 32 | automatic flush of permission caches, so the users affected receive new permissions |
|
33 | 33 | Right Away |
|
34 | 34 | """ |
|
35 | ||
|
35 | 36 | affected_user_ids = set(event.user_ids) |
|
36 | 37 | for user_id in affected_user_ids: |
|
37 | 38 | cache_namespace_uid = 'cache_user_auth.{}'.format(user_id) |
@@ -34,7 +34,7 b' def trigger(event, registry=None):' | |||
|
34 | 34 | # passing the registry as an argument to get rid of it. |
|
35 | 35 | registry = registry or get_current_registry() |
|
36 | 36 | registry.notify(event) |
|
37 | log.debug('event %s triggered using registry %s', event, registry) | |
|
37 | log.debug('event %s triggered using registry %s', event.__class__, registry) | |
|
38 | 38 | |
|
39 | 39 | # Until we can work around the problem that VCS operations do not have a |
|
40 | 40 | # pyramid context to work with, we send the events to integrations directly |
@@ -33,7 +33,7 b' from rhodecode import events' | |||
|
33 | 33 | from rhodecode.integrations.types.base import EEIntegration |
|
34 | 34 | from rhodecode.lib.caching_query import FromCache |
|
35 | 35 | from rhodecode.model import BaseModel |
|
36 | from rhodecode.model.db import Integration, Repository, RepoGroup | |
|
36 | from rhodecode.model.db import Integration, Repository, RepoGroup, true, false | |
|
37 | 37 | from rhodecode.integrations import integration_type_registry |
|
38 | 38 | |
|
39 | 39 | log = logging.getLogger(__name__) |
@@ -119,20 +119,20 b' class IntegrationModel(BaseModel):' | |||
|
119 | 119 | |
|
120 | 120 | if isinstance(scope, Repository): |
|
121 | 121 | query = self.sa.query(Integration).filter( |
|
122 | Integration.repo==scope) | |
|
122 | Integration.repo == scope) | |
|
123 | 123 | elif isinstance(scope, RepoGroup): |
|
124 | 124 | query = self.sa.query(Integration).filter( |
|
125 | Integration.repo_group==scope) | |
|
125 | Integration.repo_group == scope) | |
|
126 | 126 | elif scope == 'global': |
|
127 | 127 | # global integrations |
|
128 | 128 | query = self.sa.query(Integration).filter( |
|
129 | and_(Integration.repo_id==None, Integration.repo_group_id==None) | |
|
129 | and_(Integration.repo_id == None, Integration.repo_group_id == None) | |
|
130 | 130 | ) |
|
131 | 131 | elif scope == 'root-repos': |
|
132 | 132 | query = self.sa.query(Integration).filter( |
|
133 | and_(Integration.repo_id==None, | |
|
134 | Integration.repo_group_id==None, | |
|
135 |
Integration.child_repos_only== |
|
|
133 | and_(Integration.repo_id == None, | |
|
134 | Integration.repo_group_id == None, | |
|
135 | Integration.child_repos_only == true()) | |
|
136 | 136 | ) |
|
137 | 137 | elif scope == 'all': |
|
138 | 138 | query = self.sa.query(Integration) |
@@ -158,20 +158,20 b' class IntegrationModel(BaseModel):' | |||
|
158 | 158 | query = self.sa.query( |
|
159 | 159 | Integration |
|
160 | 160 | ).filter( |
|
161 |
Integration.enabled== |
|
|
161 | Integration.enabled == true() | |
|
162 | 162 | ) |
|
163 | 163 | |
|
164 | 164 | global_integrations_filter = and_( |
|
165 | Integration.repo_id==None, | |
|
166 | Integration.repo_group_id==None, | |
|
167 | Integration.child_repos_only==False, | |
|
165 | Integration.repo_id == None, | |
|
166 | Integration.repo_group_id == None, | |
|
167 | Integration.child_repos_only == False, | |
|
168 | 168 | ) |
|
169 | 169 | |
|
170 | 170 | if isinstance(event, events.RepoEvent): |
|
171 | 171 | root_repos_integrations_filter = and_( |
|
172 | Integration.repo_id==None, | |
|
173 | Integration.repo_group_id==None, | |
|
174 |
Integration.child_repos_only== |
|
|
172 | Integration.repo_id == None, | |
|
173 | Integration.repo_group_id == None, | |
|
174 | Integration.child_repos_only == true(), | |
|
175 | 175 | ) |
|
176 | 176 | |
|
177 | 177 | clauses = [ |
@@ -179,16 +179,16 b' class IntegrationModel(BaseModel):' | |||
|
179 | 179 | ] |
|
180 | 180 | |
|
181 | 181 | # repo integrations |
|
182 | if event.repo.repo_id: # pre create events dont have a repo_id yet | |
|
182 | if event.repo.repo_id: # pre create events dont have a repo_id yet | |
|
183 | 183 | clauses.append( |
|
184 | Integration.repo_id==event.repo.repo_id | |
|
184 | Integration.repo_id == event.repo.repo_id | |
|
185 | 185 | ) |
|
186 | 186 | |
|
187 | 187 | if event.repo.group: |
|
188 | 188 | clauses.append( |
|
189 | 189 | and_( |
|
190 | Integration.repo_group_id==event.repo.group.group_id, | |
|
191 |
Integration.child_repos_only== |
|
|
190 | Integration.repo_group_id == event.repo.group.group_id, | |
|
191 | Integration.child_repos_only == true() | |
|
192 | 192 | ) |
|
193 | 193 | ) |
|
194 | 194 | # repo group cascade to kids |
@@ -196,14 +196,13 b' class IntegrationModel(BaseModel):' | |||
|
196 | 196 | and_( |
|
197 | 197 | Integration.repo_group_id.in_( |
|
198 | 198 | [group.group_id for group in |
|
199 | event.repo.groups_with_parents] | |
|
199 | event.repo.groups_with_parents] | |
|
200 | 200 | ), |
|
201 |
Integration.child_repos_only== |
|
|
201 | Integration.child_repos_only == false() | |
|
202 | 202 | ) |
|
203 | 203 | ) |
|
204 | 204 | |
|
205 | ||
|
206 | if not event.repo.group: # root repo | |
|
205 | if not event.repo.group: # root repo | |
|
207 | 206 | clauses.append(root_repos_integrations_filter) |
|
208 | 207 | |
|
209 | 208 | query = query.filter(or_(*clauses)) |
@@ -212,11 +211,11 b' class IntegrationModel(BaseModel):' | |||
|
212 | 211 | cache_key = "get_enabled_repo_integrations_%i" % event.repo.repo_id |
|
213 | 212 | query = query.options( |
|
214 | 213 | FromCache("sql_cache_short", cache_key)) |
|
215 | else: # only global integrations | |
|
214 | else: # only global integrations | |
|
216 | 215 | query = query.filter(global_integrations_filter) |
|
217 | 216 | if cache: |
|
218 | 217 | query = query.options( |
|
219 | 218 | FromCache("sql_cache_short", "get_enabled_global_integrations")) |
|
220 | 219 | |
|
221 | 220 | result = query.all() |
|
222 | return result No newline at end of file | |
|
221 | return result |
General Comments 0
You need to be logged in to leave comments.
Login now