Пример #1
0
def _register_user(form):
    user = User.create_with_channel(
        username=form.username.data,
        first_name=form.first_name.data,
        last_name=form.last_name.data,
        date_of_birth=form.date_of_birth.data,
        email=form.email.data.lower(),
        password=form.password.data,
        gender=form.gender.data or None,
        locale=form.locale.data)
    record_user_event(user.username, 'registration succeeded', user=user)

    # Check if anyone has emailed this person before
    senders = models.ExternalFriend.query.filter(
        models.ExternalFriend.external_system == 'email',
        models.ExternalFriend.email == user.email
    ).join(
        User,
        User.id == models.ExternalFriend.user
    ).with_entities(User)

    if senders.count():
        db.session.flush()  # Get the user id before the commit
        from rockpack.mainsite.services.share import api
        for sender in senders:
            api.create_reverse_email_friend_association(sender, user)

    return user
Пример #2
0
 def create_test_user(self, **kwargs):
     postfix = uuid.uuid4().hex
     userdata = dict(
         username='******' + postfix,
         password='******',
         first_name='Alexia',
         last_name='Barrichello',
         date_of_birth=date(2000, 1, 1),
         email='noreply+test_' + postfix + '@rockpack.com',
         avatar='',
         refresh_token='',
         is_active=True,
         locale='en-us',
     )
     userdata.update(kwargs)
     with self.app.test_request_context():
         user = User.create_with_channel(**userdata)
         self.session.commit()
     return user