Show More
@@ -30,7 +30,7 b' EXTRA_INDEX_EXTENSIONS = []' | |||
|
30 | 30 | # POST CREATE REPOSITORY HOOK |
|
31 | 31 | #============================================================================== |
|
32 | 32 | # this function will be executed after each repository is created |
|
33 | def _crhook(*args, **kwargs): | |
|
33 | def _crrepohook(*args, **kwargs): | |
|
34 | 34 | """ |
|
35 | 35 | Post create repository HOOK |
|
36 | 36 | kwargs available: |
@@ -49,16 +49,48 b' def _crhook(*args, **kwargs):' | |||
|
49 | 49 | :param created_by: |
|
50 | 50 | """ |
|
51 | 51 | return 0 |
|
52 | CREATE_REPO_HOOK = _crhook | |
|
52 | CREATE_REPO_HOOK = _crrepohook | |
|
53 | ||
|
54 | ||
|
55 | #============================================================================== | |
|
56 | # POST CREATE USER HOOK | |
|
57 | #============================================================================== | |
|
58 | # this function will be executed after each user is created | |
|
59 | def _cruserhook(*args, **kwargs): | |
|
60 | """ | |
|
61 | Post create user HOOK | |
|
62 | kwargs available: | |
|
63 | :param username: | |
|
64 | :param full_name_or_username: | |
|
65 | :param full_contact: | |
|
66 | :param user_id: | |
|
67 | :param name: | |
|
68 | :param firstname: | |
|
69 | :param short_contact: | |
|
70 | :param admin: | |
|
71 | :param lastname: | |
|
72 | :param ip_addresses: | |
|
73 | :param ldap_dn: | |
|
74 | :param email: | |
|
75 | :param api_key: | |
|
76 | :param last_login: | |
|
77 | :param full_name: | |
|
78 | :param active: | |
|
79 | :param password: | |
|
80 | :param emails: | |
|
81 | :param inherit_default_permissions: | |
|
82 | """ | |
|
83 | return 0 | |
|
84 | CREATE_USER_HOOK = _cruserhook | |
|
53 | 85 | |
|
54 | 86 | |
|
55 | 87 | #============================================================================== |
|
56 | 88 | # POST DELETE REPOSITORY HOOK |
|
57 | 89 | #============================================================================== |
|
58 | 90 | # this function will be executed after each repository deletion |
|
59 | def _dlhook(*args, **kwargs): | |
|
91 | def _dlrepohook(*args, **kwargs): | |
|
60 | 92 | """ |
|
61 |
Post |
|
|
93 | Post delete repository HOOK | |
|
62 | 94 | kwargs available: |
|
63 | 95 | :param repo_name: |
|
64 | 96 | :param repo_type: |
@@ -76,7 +108,39 b' def _dlhook(*args, **kwargs):' | |||
|
76 | 108 | :param deleted_on: |
|
77 | 109 | """ |
|
78 | 110 | return 0 |
|
79 | DELETE_REPO_HOOK = _dlhook | |
|
111 | DELETE_REPO_HOOK = _dlrepohook | |
|
112 | ||
|
113 | ||
|
114 | #============================================================================== | |
|
115 | # POST DELETE USER HOOK | |
|
116 | #============================================================================== | |
|
117 | # this function will be executed after each user is deleted | |
|
118 | def _dluserhook(*args, **kwargs): | |
|
119 | """ | |
|
120 | Post delete user HOOK | |
|
121 | kwargs available: | |
|
122 | :param username: | |
|
123 | :param full_name_or_username: | |
|
124 | :param full_contact: | |
|
125 | :param user_id: | |
|
126 | :param name: | |
|
127 | :param firstname: | |
|
128 | :param short_contact: | |
|
129 | :param admin: | |
|
130 | :param lastname: | |
|
131 | :param ip_addresses: | |
|
132 | :param ldap_dn: | |
|
133 | :param email: | |
|
134 | :param api_key: | |
|
135 | :param last_login: | |
|
136 | :param full_name: | |
|
137 | :param active: | |
|
138 | :param password: | |
|
139 | :param emails: | |
|
140 | :param inherit_default_permissions: | |
|
141 | """ | |
|
142 | return 0 | |
|
143 | DELETE_USER_HOOK = _dluserhook | |
|
80 | 144 | |
|
81 | 145 | |
|
82 | 146 | #============================================================================== |
@@ -252,6 +252,45 b' def log_create_repository(repository_dic' | |||
|
252 | 252 | return 0 |
|
253 | 253 | |
|
254 | 254 | |
|
255 | def log_create_user(user_dict, **kwargs): | |
|
256 | """ | |
|
257 | Post create user Hook. This is a dummy function for admins to re-use | |
|
258 | if needed. It's taken from rhodecode-extensions module and executed | |
|
259 | if present | |
|
260 | ||
|
261 | :param user_dict: dict dump of user object | |
|
262 | ||
|
263 | available keys for user_dict: | |
|
264 | ||
|
265 | 'username', | |
|
266 | 'full_name_or_username', | |
|
267 | 'full_contact', | |
|
268 | 'user_id', | |
|
269 | 'name', | |
|
270 | 'firstname', | |
|
271 | 'short_contact', | |
|
272 | 'admin', | |
|
273 | 'lastname', | |
|
274 | 'ip_addresses', | |
|
275 | 'ldap_dn', | |
|
276 | 'email', | |
|
277 | 'api_key', | |
|
278 | 'last_login', | |
|
279 | 'full_name', | |
|
280 | 'active', | |
|
281 | 'password', | |
|
282 | 'emails', | |
|
283 | 'inherit_default_permissions' | |
|
284 | ||
|
285 | """ | |
|
286 | from rhodecode import EXTENSIONS | |
|
287 | callback = getattr(EXTENSIONS, 'CREATE_USER_HOOK', None) | |
|
288 | if isfunction(callback): | |
|
289 | return callback(**user_dict) | |
|
290 | ||
|
291 | return 0 | |
|
292 | ||
|
293 | ||
|
255 | 294 | def log_delete_repository(repository_dict, deleted_by, **kwargs): |
|
256 | 295 | """ |
|
257 | 296 | Post delete repository Hook. This is a dummy function for admins to re-use |
@@ -290,6 +329,45 b' def log_delete_repository(repository_dic' | |||
|
290 | 329 | return 0 |
|
291 | 330 | |
|
292 | 331 | |
|
332 | def log_delete_user(user_dict, **kwargs): | |
|
333 | """ | |
|
334 | Post delete user Hook. This is a dummy function for admins to re-use | |
|
335 | if needed. It's taken from rhodecode-extensions module and executed | |
|
336 | if present | |
|
337 | ||
|
338 | :param user_dict: dict dump of user object | |
|
339 | ||
|
340 | available keys for user_dict: | |
|
341 | ||
|
342 | 'username', | |
|
343 | 'full_name_or_username', | |
|
344 | 'full_contact', | |
|
345 | 'user_id', | |
|
346 | 'name', | |
|
347 | 'firstname', | |
|
348 | 'short_contact', | |
|
349 | 'admin', | |
|
350 | 'lastname', | |
|
351 | 'ip_addresses', | |
|
352 | 'ldap_dn', | |
|
353 | 'email', | |
|
354 | 'api_key', | |
|
355 | 'last_login', | |
|
356 | 'full_name', | |
|
357 | 'active', | |
|
358 | 'password', | |
|
359 | 'emails', | |
|
360 | 'inherit_default_permissions' | |
|
361 | ||
|
362 | """ | |
|
363 | from rhodecode import EXTENSIONS | |
|
364 | callback = getattr(EXTENSIONS, 'DELETE_USER_HOOK', None) | |
|
365 | if isfunction(callback): | |
|
366 | return callback(**user_dict) | |
|
367 | ||
|
368 | return 0 | |
|
369 | ||
|
370 | ||
|
293 | 371 | handle_git_pre_receive = (lambda repo_path, revs, env: |
|
294 | 372 | handle_git_receive(repo_path, revs, env, hook_type='pre')) |
|
295 | 373 | handle_git_post_receive = (lambda repo_path, revs, env: |
@@ -94,6 +94,9 b' class UserModel(BaseModel):' | |||
|
94 | 94 | |
|
95 | 95 | new_user.api_key = generate_api_key(form_data['username']) |
|
96 | 96 | self.sa.add(new_user) |
|
97 | ||
|
98 | from rhodecode.lib.hooks import log_create_user | |
|
99 | log_create_user(new_user.get_dict()) | |
|
97 | 100 | return new_user |
|
98 | 101 | except Exception: |
|
99 | 102 | log.error(traceback.format_exc()) |
@@ -141,6 +144,10 b' class UserModel(BaseModel):' | |||
|
141 | 144 | new_user.name = firstname |
|
142 | 145 | new_user.lastname = lastname |
|
143 | 146 | self.sa.add(new_user) |
|
147 | ||
|
148 | if not edit: | |
|
149 | from rhodecode.lib.hooks import log_create_user | |
|
150 | log_create_user(new_user.get_dict()) | |
|
144 | 151 | return new_user |
|
145 | 152 | except (DatabaseError,): |
|
146 | 153 | log.error(traceback.format_exc()) |
@@ -169,6 +176,9 b' class UserModel(BaseModel):' | |||
|
169 | 176 | new_user.lastname = attrs['lastname'] |
|
170 | 177 | |
|
171 | 178 | self.sa.add(new_user) |
|
179 | ||
|
180 | from rhodecode.lib.hooks import log_create_user | |
|
181 | log_create_user(new_user.get_dict()) | |
|
172 | 182 | return new_user |
|
173 | 183 | except (DatabaseError,): |
|
174 | 184 | log.error(traceback.format_exc()) |
@@ -209,6 +219,9 b' class UserModel(BaseModel):' | |||
|
209 | 219 | new_user.lastname = attrs['lastname'] |
|
210 | 220 | |
|
211 | 221 | self.sa.add(new_user) |
|
222 | ||
|
223 | from rhodecode.lib.hooks import log_create_user | |
|
224 | log_create_user(new_user.get_dict()) | |
|
212 | 225 | return new_user |
|
213 | 226 | except (DatabaseError,): |
|
214 | 227 | log.error(traceback.format_exc()) |
@@ -311,6 +324,9 b' class UserModel(BaseModel):' | |||
|
311 | 324 | % (user.username, len(repos), ', '.join(repos)) |
|
312 | 325 | ) |
|
313 | 326 | self.sa.delete(user) |
|
327 | ||
|
328 | from rhodecode.lib.hooks import log_delete_user | |
|
329 | log_delete_user(user.get_dict()) | |
|
314 | 330 | except Exception: |
|
315 | 331 | log.error(traceback.format_exc()) |
|
316 | 332 | raise |
General Comments 0
You need to be logged in to leave comments.
Login now