# HG changeset patch # User Johannes Bornhold # Date 2016-05-31 10:36:58 # Node ID 636c8b2a35e8136153a1422fa9ee032f1a004861 # Parent a33067ed2f1ed4ded8b4d00d05f27b5f4937820e events: Send events when user is created or updated. Send the UserPreCreate event before a new user is created. Send the UserPreUpdate event before a user is updated. diff --git a/rhodecode/model/user.py b/rhodecode/model/user.py --- a/rhodecode/model/user.py +++ b/rhodecode/model/user.py @@ -26,13 +26,13 @@ import logging import traceback import datetime -from pylons import url from pylons.i18n.translation import _ import ipaddress from sqlalchemy.exc import DatabaseError from sqlalchemy.sql.expression import true, false +from rhodecode.events import UserPreCreate, UserPreUpdate from rhodecode.lib.utils2 import ( safe_unicode, get_current_rhodecode_user, action_logger_generic, AttributeDict) @@ -270,10 +270,12 @@ class UserModel(BaseModel): # raises UserCreationError if it's not allowed for any reason to # create new active user, this also executes pre-create hooks check_allowed_create_user(user_data, cur_user, strict_check=True) + self.send_event(UserPreCreate(user_data)) new_user = User() edit = False else: log.debug('updating user %s', username) + self.send_event(UserPreUpdate(user, user_data)) new_user = user edit = True