Exemplo n.º 1
0
def registr_6(message):
    gas_supply_id = message.text
    if len((session.query(Supply).filter(
            Supply.gas_supply_id == gas_supply_id)).all()) != 0:
        botuseon.send_message(message.from_user.id, 'Цей номер вже зайнятий')
        botuseon.register_next_step_handler(message, registr_6)
    elif gas_supply_id.isdigit():
        supply.gas_supply_id = gas_supply_id
        new_user = UserProfile(user_id=user.id,
                               user_name=user.name,
                               user_phone=user.phone,
                               user_email=user.email)
        new_supply = Supply(user_id_fk=supply.id,
                            water_supply_id=supply.water_supply_id,
                            power_supply_id=supply.power_supply_id,
                            gas_supply_id=supply.gas_supply_id)
        session.add(new_user)
        session.commit()
        session.add(new_supply)
        session.commit()
        user.state = 1
        botuseon.send_message(
            message.from_user.id,
            'Вітаємо з реестрацією. Далі Ви можете передати дані або додати картку',
            reply_markup=keyboard2)
    else:
        botuseon.send_message(
            message.from_user.id,
            'Введіть корректний номер особового рахунку газопостачання')
        botuseon.register_next_step_handler(message, registr_6)
Exemplo n.º 2
0
def profile():
    form = CreateProfile()
    if request.method == "POST" and form.validate_on_submit():
        try:
        
            created_on=str(datetime.datetime.now()).split()[0]

            photo=form.Profile_picture.data
           
            photo_filename = secure_filename(photo.filename)
            
        
            user=UserProfile(form.Firstname.data,form.Lastname.data,form.Gender.data,form.Location.data,form.Biography.data,created_on,photo_filename)
      
        
            db.session.add(user)
            db.session.commit()
            photo.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
        
            flash("Profile Added", "success")
            return redirect(url_for("profiles"))
        except :
            db.session.rollback()
            flash("Internal Error", "danger")
            return render_template("profile.html", form =form)
    
    return render_template("profile.html", form =form)
Exemplo n.º 3
0
def createNewUser(fname, lname, email):
	newUser = UserProfile.getFromEmail(email)
	if newUser == None:
		newUser = UserProfile(id=email, fname=fname, lname=lname, email=email)
		newUser.put()
		logging.info('User %s created.' % email)
	else:
		logging.error('User already exists.')
Exemplo n.º 4
0
def create_profile_return_id(user_id, date):
    """ creates a new facor profile and returns user_factor_profile_id"""

    new_profile = UserProfile(user_id=user_id, date=date)
    db.session.add(new_profile)
    db.session.commit()
    new_profile = UserProfile.query.filter(
        UserProfile.user_id == user_id).first()
    profile_id = new_profile.profile_id

    return profile_id
Exemplo n.º 5
0
def profile():
    form = RegisterForm()
    if request.method == 'POST':
        User_Fname = request.form['firstname']
        User_Lname = request.form['lastname']
        User_Age = request.form['age']
        User_Gender = request.form['gender']
        User_Bio = request.form['bio']
        User_name = request.form['username']
        file_folder = app.config['UPLOAD_FOLDER']
        file = request.files['file']
        filename = secure_filename(file.filename)
        file.save(os.path.join(file_folder, filename))
        ID = makeId()
        date = timeinfo()
        user = UserProfile(User_name, User_Fname, User_Lname, User_Age,
                           User_Gender, User_Bio, date)
        db.session.add(user)
        db.session.commit()
        return redirect('home.html')

    else:
        flash('All fields are required')
        return render_template('user.html', form=form)
Exemplo n.º 6
0
from database_connection import engine
from sqlalchemy.orm import sessionmaker
from model import UserProfile, Card, Supply, WaterSupply, PowerSupply, GasSupply
from sqlalchemy import func

Session = sessionmaker(bind=engine)
session = Session()

bob = UserProfile(user_name='Bob',
                  user_phone='+380123456789',
                  user_email='*****@*****.**')
boba = UserProfile(user_name='Boba',
                   user_phone='+380123456780',
                   user_email='*****@*****.**')

session.add(bob)
session.commit()
session.add(boba)
session.commit()

bob_id = (session.query(UserProfile).filter(
    UserProfile.user_phone == '+380123456789')[0]).user_id
boba_id = (session.query(UserProfile).filter(
    UserProfile.user_phone == '+380123456780')[0]).user_id

bobs_card = Card(user_id_fk=bob_id,
                 card_number='1234567890123456',
                 card_name='Bob Bobovich',
                 card_date=func.current_date(),
                 card_ccv='123')
bobas_card = Card(user_id_fk=boba_id,