Beispiel #1
0
async def register(message: types.Message):
    data = message.from_user.values
    User.create(external_id=data['id'],
                name=message.from_user.full_name,
                username=data.get('username', 'nouser'),
                lang=data.get('language_code', 'es'),
                extra=str(data))
    await message.reply(f'Bienvenid@ {message.from_user.full_name}!')
Beispiel #2
0
 def _create_user_with_membership(self):
     """
     Create a user and a member
     """
     u = User.create(account_id=self.account_id, secret_key=self.secret_key)
     m = Member.create(account_id=u.account_id, email=self.email)
     return [u, m]
Beispiel #3
0
def create():
    print "Creating tables..."
    db.create_all()

    print "Fixture: Creating Frontier's system account"
    if User.create(account_id="aabacd", secret_key="123", email="*****@*****.**"):
        print "Fixture: Create Success!"
Beispiel #4
0
def seed():
    NUM_RIDERS = 12
    NUM_STOPS = 8

    schedule = Schedule.create()
    schedule_stops = []

    for ss in ScheduleStopFactory.create_batch(NUM_STOPS):
        instance = ScheduleStop.create(address=ss.address,
                                       latitude=ss.latitude,
                                       longitude=ss.longitude,
                                       timestamp=ss.timestamp,
                                       schedule=schedule)
        schedule_stops.append(instance)

    for i, r in enumerate(RideFactory.create_batch(NUM_RIDERS)):
        user = User.create(username=r.user.username,
                           first_name=r.user.first_name,
                           last_name=r.user.last_name,
                           email=r.user.email)
        ride = Ride.create(user=user,
                           capacity=r.capacity,
                           wheelchair=r.wheelchair,
                           status=r.status)

        # Pick a stop for this rider. Once we fill all stops, randomize the remaining rides
        if i < NUM_STOPS:
            schedule_stop = schedule_stops[i]
        else:
            schedule_stop = random.choice(schedule_stops)

        ScheduleStopRide.create(stop=schedule_stop,
                                ride=ride,
                                stop_type=random.choice(STOP_TYPE_CHOICES))
Beispiel #5
0
def bot_user():
    user = User.create(
        chat_id=383716,
        user_name='wildsearch_test_user',
        full_name='Wonder Sell',
    )

    return user
Beispiel #6
0
def portal():
    form = SignUpLoginForm()
    if form.validate_on_submit():
        secret_key, account_id = request.form.get('secret_key'), request.form.get('account_id')

        # whether enrolling or login in: we need to check if account with current info already exists
        user = User.query.filter(User.secret_key == secret_key, User.account_id == account_id).first()

        if request.form.get('submit') == 'Login':
            if not user:
                return render_template('portal.html', form=form, errors=["User does not exist. Please sign up first."])
        elif request.form.get('submit') == 'Sign Up':
            if user:
                return render_template('portal.html', form=form, errors=["Account exists, you may just Login"])
            user = User.create(secret_key=secret_key, account_id=account_id)

        # whether login or enroll, login the user eventually
        login_user(user)
        return redirect(url_for('profile'))

    return render_template('portal.html', form=form, errors=form.get_error_msgs())
 def _create_purchase_with_member_with_user(self):
     u = User.create(account_id=self.account_id, secret_key=self.secret_key)
     m = Member.create(email=self.email, account_id=u.account_id)
     p = Purchase.create(title='TEST', price=100, member_id=m.id)
     return [p, m, u]
def test_user_get_by_chat_id():
    u_created = User.create(chat_id=1234)

    u_fetched = user_get_by_chat_id(chat_id=1234)

    assert u_created == u_fetched
Beispiel #9
0
 def _create_user(self):
     return User.create(account_id=self.account_id, secret_key=self.secret_key)