예제 #1
0
    def register(self, request, **kwargs):
        """
        Register a new user with those params on kwargs

        :param name: the user's name
        :type name: str
        :param realname: the user's realnamee (optional)
        :type realname: str
        :param email: the user's email
        :type email: str
        :param key: the user's key (optional/autogenerated)
        :type key: str
        :param github_profile: the user's github profile (optional)
        :type github_profile: str
        :param bitbucket_profile: the user's bitbucket profile (optional)
        :type bitbucket_profile: str
        :param twitter: the user's twitter account (optional)
        :type twitter: str
        """

        errors = yield self._check_register_errors(**kwargs)
        if len(errors) > 0:
            defer.returnValue({'success': False, 'msg': '\n'.join(errors)})

        user = User()
        for key, value in kwargs.iteritems():
            if key == 'key':
                value = sha512(value).hexdigest()

            if hasattr(user, key):
                setattr(user, key, value)

        user.create()
        defer.returnValue({'success': True})
    def _transfer_user_and_scholar_payment_account(cls, legacy_session,
                                                   session):
        legacy_users = legacy_session.query(model.User).filter(
            model.User.available.is_(True)).all()
        for legacy_user in legacy_users:  # type: model.User
            user = User(
                username=legacy_user.username,
                email=legacy_user.email,
                password=legacy_user.password,
            )
            user.created_at = datetime.fromtimestamp(legacy_user.created_at)
            user.status = User.STATUS.ACTIVATED
            session.add(user)
            session.flush()

            cls._transfer_scholar_payment_account_for_user(
                legacy_session, session, user.uuid, legacy_user.id)
            cls._assign_role_for_user(session, user.uuid,
                                      Role.BuiltInRole.REGISTRATION_USER)
예제 #3
0
def add_user(**kwargs):
    with session_scope() as session:
        user = User(**kwargs)
        session.add(user)
    return user.username
예제 #4
0
파일: quote.py 프로젝트: itsbth/wireqdb
 def __init__(self, quote=None):
     Partial.__init__(self)
     self.tpl["quote"] = quote
     self.tpl["user_obj"] = User.get_current_user()