Esempio n. 1
0
def setting_settings_other(user):

    user = user_personal.query.join(user_contact, user_account).add_columns(
        user_personal.id, user_contact.email_address, user_personal.first_name,
        user_personal.surname, user_personal.blood_group,
        user_contact.is_donor,
        user_account.status).filter_by(id=current_user.id).first()

    user_update = user_contact.query.filter_by(id=current_user.user_id).first()

    form = IsDonor_Form()

    if form.validate_on_submit():

        if form.action.data == 'Y':
            user_update.is_donor = form.action.data
        else:
            user_update.is_donor = form.action.data

        db.session.commit()

        return redirect(
            url_for('users.setting_settings_other', user=current_user.user_id))

    return render_template('setting/settings_other.html',
                           title='setting| Settings | Other Settings ',
                           user=user,
                           form=form,
                           user_update=user_update)


#------------------------- SETTINGS END -------------------------
Esempio n. 2
0
def inventory_add():

    form = HospitalInventoryForm()

    if form.validate_on_submit():

        resource_id = blood_resource.query.all()
        resource_id = len(resource_id) + 1

        value = blood_resource(id=resource_id,
                               blood_group=form.blood_group.data,
                               bag_type=form.bag_type.data,
                               event_id='1',
                               center_id=current_user.user_id,
                               extraction_date=form.extraction_date.data,
                               cost=form.cost.data,
                               status='A')

        db.session.add(value)
        db.session.commit()

        return "Resource Added!"

    return render_template('admin_hospital/inventory/add.html',
                           title='Hospital | Inventory | Add',
                           forms=form)
Esempio n. 3
0
def project_form():
	form = NewProjectForm()
	if form.validate_on_submit():
		project = Canvas()
		project.project_name = form.project_name.data
		project.scale_type = form.scale_type.data
		project.width = form.width.data
		project.height = form.height.data
		project.mounting_distance = form.mounting_distance.data
		project.origin_distance = form.origin_distance.data
		if form.scale_type.data == '0':	#inches
			project.widthPx = form.width.data*100
			project.heightPx = form.height.data*100
			project.origin_distance = form.origin_distance.data*100
		#elif form.scale_type.data == '1':		#foot
		#	project.widthPx = form.width.data*3600
		#	project.heightPx = form.height.data*3600
		#	project.origin_distance = form.origin_distance.data*3600
		#else:		#meter
		#	project.widthPx = form.width.data*(283465/24)
		#	project.heightPx = form.height.data*(283465/24)
		#	project.origin_distance = form.origin_distance.data*(283465/24)
		db.session.add(project)
		db.session.commit()
		return redirect(url_for('calibration_page',id=project.id))
	return render_template('project_form.html', form=form)
Esempio n. 4
0
def index():
    name=Name
    form=NameForm()
    if form.validate_on_submit():
        name=form.name.data
        form.name.data=""
        return render_template('index.html',form=form,name=name)
Esempio n. 5
0
def login():
    
    form = LoginForm()
    if request.method == 'POST':
        db = get_db()
        form = LoginForm()  # Se instancia el objeto form --> WTForm
        if form.validate_on_submit():  # Se valida si el usuario envia un metodo POST con los datos validos
                usuario = form.usuario.data  # Con estos datos se valida en la BD si esta registrado
                contrasena = form.contrasena.data
                user = db.execute('SELECT * FROM usuarios WHERE username = ?', (usuario,)
                       ).fetchone()
                if user is None:    #Si el no se encuentra en la base de datos
                    error = 'Usuario o contrasena invalidos'
                    flash(error)
                    return render_template("ingreso.html", form=form)
                           #Si se encuentra, se crea la session y se devuelve a la pagina principal

                if check_password_hash(user['password'], contrasena):
                    session.clear()
                    session['user_id'] = user[0]
                    return redirect(url_for('index'))
                else:
                    error = 'Usuario o contrasena invalidos'
                    flash(error)
                    return render_template("ingreso.html", form=form)
        else:
            return render_template("ingreso.html", form=form)

    if request.method == 'GET':
        return render_template("ingreso.html", form=form)  # Solo es ejecuta en el metodo GET
Esempio n. 6
0
def login():
    """
    Compare user inputted data to a text file with all users. 
    If not found send user back to index page. 
    If found send user to panel page. 
    Save username and rank into a session.
    """
    # Open the user file to read from
    user_file = open('users.txt', 'r')
    lines = user_file.readlines()
    page = {'pagename': 'login'}
    # noinspection PyShadowingNames
    form = LoginForm()
    if form.validate_on_submit():
        # Save the data as a local variable
        username = form.username.data
        password = form.password.data
        # Loop through every line in the users file and find if the user exists or not
        for line in lines:
            saved_username, saved_password, saved_rank = line.split(".")
            if username == saved_username and password == saved_password:
                # Save the rank and username of the user into a session item
                session['rank'] = saved_rank
                session['username'] = username
                return redirect(url_for('panel'))
            else:
                # If user is not found
                continue
        # If user doesn't input true values send him back to the index page
        return redirect(url_for('index'))

    return render_template('/html/login.html',
                           title='Login',
                           page=page,
                           form=form)
Esempio n. 7
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        flash('Login requested for user {}, remember_me={}'.format(
            form.username.data, form.remember_me.data))
        return redirect(url_for('index'))
    return render_template('login.html', title='Sign In', form=form)
Esempio n. 8
0
def request_form(center_id):

    form = RequestForm()
    center = blood_center.query.get(center_id)

    if form.validate_on_submit():

        total = blood_request.query.all()
        id = len(total) + 1

        values = blood_request(id=id,
                               user_id=current_user.user_id,
                               hospital_id=center_id,
                               patient=form.patient.data,
                               quantity=form.quantity.data,
                               blood_group=form.blood_group.data,
                               purpose=form.purpose.data,
                               date_created=datetime.now(),
                               date_processed=None,
                               remarks=None,
                               status='N')

        db.session.add(values)
        db.session.commit()

        return redirect(url_for('users.request'))

    return render_template('request/request_form.html',
                           title='Request | Request Form',
                           form=form,
                           center=center)
Esempio n. 9
0
def login():
    form = LoginForm()

    if form.validate_on_submit():
        return '<h1>' + form.username.data + ' ' + form.password.data + '</h1>'

    return render_template('login.html', form=form)
Esempio n. 10
0
def setting_settings_password(user):

    user_update = user_personal.query.join(
        user_address, user_contact, user_account).add_columns(
            user_personal.id, user_personal.surname, user_personal.first_name,
            user_personal.blood_group, user_contact.email_address,
            user_account.username, user_account.password,
            user_contact.is_donor,
            user_account.status).filter_by(id=current_user.id).first()

    form = PasswordForm_Update()

    if form.validate_on_submit():

        # testname = blood_center.query.filter_by(name=form.name.data).first()

        # if testname is not None and not testname.name==hospital.name:
        #   flash('Hospital name is already taken.')
        #   return redirect(url_for('backend.phlebotomist_edit', phlebotomist=testname.id))

        if user_update.user_account.password == form.password.data:
            if form.password_new.data == form.password_confirm.data:
                user_update.user_account.password = form.password_new.data

        return 'Password not updated'

        db.session.commit()

    return render_template('setting/settings_password.html',
                           title='setting | Settings | Password',
                           user_update=user_update,
                           form=form,
                           user=user_update)
Esempio n. 11
0
    def reqister():
        form = RegisterForm()
        if form.validate_on_submit():
            if form.password.data != form.password_again.data:
                return render_template('register.html',
                                       title='Регистрация',
                                       form=form,
                                       message="Пароли не совпадают")
            session = db_session.create_session()
            if session.query(User).filter(
                    User.email == form.email.data).first():
                return render_template('register.html',
                                       title='Регистрация',
                                       form=form,
                                       message="Такой пользователь уже есть")

            user = User(name=form.name.data,
                        surname=form.surname.data,
                        email=form.email.data)

            user.set_password(form.password.data)
            session.add(user)
            session.commit()
            return redirect('/login')
        return render_template('register.html',
                               title='Регистрация.',
                               form=form)
Esempio n. 12
0
def book():
    form = BookRoom()
    if form.validate_on_submit():
        a = rooms.query.filter_by(category=form.category.data).first()

        if (a.available >= form.quantity.data):
            var = form.quantity.data
            for var in range(0, var):
                b = booking(category=form.category.data, checkin=form.checkin.data, checkout=form.checkout.data,
                            name=form.name.data, mobno=form.mobno.data, status='NOT AVAILABLE')
                db.session.add(b)
                db.session.commit()
            b=booking.query.filter_by(mobno=form.mobno.data).first()
            a.available = a.available - form.quantity.data
            a.booked = a.booked + form.quantity.data
            db.session.commit()
            # 465
            Subject = "Booked Confirmed"
            MESSAGE = "Your Room has been Succsesfully booked\n"+"-"*100+"\n"+"| "+"Booking Number: "+str(b.roomno)+"\n| "+"Number of Rooms: "+str(form.quantity.data)+"\n| "+"Name: "+form.name.data+"\n| "+"Phone Number: "+str(form.mobno.data)+"\n| "+"Check IN: "+str(form.checkin.data)+"\n| "+"Check Out: "+str(form.checkout.data)+"\n"+"-"*100+"\n ** Thank you For your Booking We Wish You Having A Great Time! **"
            m = 'from:{}\nto:{}\nsubject:{}\n{}\n'.format("Maldives Hotel", form.email.data, Subject, MESSAGE)
            server = smtplib.SMTP("smtp.gmail.com", 587)
            server.starttls()
            server.login("*****@*****.**", p)
            server.sendmail("*****@*****.**", form.email.data, m)
            server.quit()
            flash("Your Room has been Successfully Booked\nWe have sent you an email", 'success')
        else:
            flash("Not enough rooms available for the selected category!", 'danger')
        return redirect(url_for('rdirect'))
    return render_template("book.html", title="Book Now", form=form)
def login():
    form = LoginForm(request.form)
    if request.method == 'POST':
        if not form.validate_on_submit():
            abort(400)
        user = User.query.filter(User.email.ilike(f"{form.email.data}")).first()

        if not user:
            flash("شما ثبت نام نکرده اید", category='error')
            return render_template('users/login.html', form=form)

        if not user.check_password(form.password.data):
            flash("نام کاربری / رمز ورود  نادرست است", category='error')
            return render_template('users/login.html', form=form)
        
        # if user:
        #     flash("شما از قبل وارد شده اید", category='error')
        #     return(redirect(url_for('index')))
        
        session['email'] = user.email
        session['user_id'] = user.id
        session['username'] = user.username

        # return redirect(url_for('index'))
    if session.get('email') is not None:
        flash("ورود با موفقیت انجام شد", category='')
        return redirect(url_for('index'))
    return render_template('users/login.html', form=form)
Esempio n. 14
0
def registro():
    form = RegistroForm()
    if request.method == 'POST':
        form = RegistroForm()
        if form.validate_on_submit():
            db = get_db()
            nombre = form.nombre.data
            usuario = form.usuario.data
            email = form.email.data
            contrasena = form.contrasena.data

            #Si el usuario ya existe
            if db.execute('SELECT id_usuario FROM usuarios WHERE username = ?',
                          (usuario, )).fetchone() is not None:
                error = 'El correo {} ya existe'.format(usuario)
                flash(error)
                return render_template('registro.html', form=form)

            #Si el correo ya existe
            if db.execute('SELECT id_usuario FROM usuarios WHERE email = ?',
                          (email, )).fetchone() is not None:
                error = 'El correo {} ya existe'.format(email)
                flash(error)
                return render_template('registro.html', form=form)

            db.execute(  #Ejecucion del query
                'INSERT INTO usuarios (username, email, password, name) VALUES (?,?,?,?)',
                (usuario, email, contrasena, nombre))
            db.commit()  #Chequear informacion en la BD
            flash('Revisa tu correo para activar tu cuenta')
            enviar_mensaje_activacion(email=email)
            return redirect(url_for('index'))

    return render_template("registro.html", form=form)
Esempio n. 15
0
def register():
    form = registrationform()
    if form.validate_on_submit():
        flash(f'Account created for {form.username.data}!')
        return redirect(url_for('home'))
    return render_template('register.html',
                           title='Registration Page',
                           form=form)
Esempio n. 16
0
def login():
    form = loginform()
    if form.validate_on_submit():
        if form.email.data == '*****@*****.**' and form.password.data == 'password':
            flash('you have been logged in!')
            return redirect(url_for('home'))
        else:
            flash('Login unsuccessful. Please check your details')
    return render_template('login.html', title='Login Page', form=form)
Esempio n. 17
0
def reset_password_token():
    form = PasswordResetToken()

    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        send_reset_email(user)
        flash('Token has been sent to your email')
        return redirect(url_for('login'))

    return render_template('reset_password_token.html', form=form)
Esempio n. 18
0
def olvidaPass():
    form = OlvidaPassForm()
    if form.validate_on_submit():
        email = form.email.data

        next = request.args.get('next', None)
        if next:
            return redirect(next)
        return redirect(url_for('enviar_mensaje', email=email))
    return render_template('olvidaPass.html', form=form)
Esempio n. 19
0
def test():
    form = testform
    if request.method == 'POST':
        if form.validate_on_submit():
            number = form.number.data
            print(number + "This is the string")
            number = int(number)
            print(number)

    return render_template('/html/test.html')
Esempio n. 20
0
def index():
    name = None
    form = NameForm()
    if form.validate_on_submit():
        name = form.name.data
        form.name.data = ""
        return render_template('index.html',form = form , name = name)

    if __name__=="__main__":
    app.run(debug=True)
Esempio n. 21
0
def addcommit():
    commit = Commit()
    userform = UserInfo()
    if form.validate_on_submit():
        commit = NoticeInfo(ntext=commit.ntext.data,
                            nauid=current_user.__name__)
        db.session.add(commit)
        db.session.commit()
        return redirect(url_for('main.post'))
    return render_template('main/contact.html')
Esempio n. 22
0
def newroom():
    form = NewRoom()
    if form.validate_on_submit():
        image = _compat.to_bytes(form.image.name) #Turn string into binary(bytes) to be able to save it in the database 
        rtype = rooms(category=form.category.data, quantity=form.quantity.data, beds=form.beds.data,
                      available=form.quantity.data, price=form.price.data, facilities=form.facilities.data, image=image)
        db.session.add(rtype)
        db.session.commit()
        flash("Your Room has been Successfully Booked", 'success')
        return redirect(url_for('rdirect'))
    return render_template("room_category.html", title="Add RoomType", form=form)
Esempio n. 23
0
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        flash(f'New account has been created', 'success')
        return redirect("/")
    return render_template('registration.html', form=form)
Esempio n. 24
0
def addnotice():
    notice = NoticeInfo()
    userform = UserInfo()
    if form.validate_on_submit():
        notice = NoticeInfo(ntext=notice.ntext.data,
                            nauid=current_user.__name__)
        db.session.add(notice)
        db.session.commit()
        return redirect(url_for('main.index'))
    return render_template('admin/back-add-notice.html',
                           changeuserform=userform)
Esempio n. 25
0
def cambiaPass():
    form = CambiaPassForm()
    if form.validate_on_submit():
        contrasena = form.contrasena.data
        confirmar = form.confirmar.data

        next = request.args.get('next', None)
        if next:
            return redirect(next)
        return redirect(url_for('index'))
    return render_template('cambiaPass.html', form=form)
Esempio n. 26
0
def options():
    form = chooseProfile()
    if request.method == 'POST':
        if form.validate_on_submit():
            profilename = form.profileName.data
            saicalls.sendprof(profilename)
            time.sleep(10)
            saicalls.trigger()
            print('sending profile')

    return render_template('/html/options.html', form=form)
Esempio n. 27
0
def newpost():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data,
                    content=form.content.data,
                    author=current_user)
        db.session.add(post)
        db.session.commit()
        flash('your post has been created')
        return redirect(url_for('home'))
    return render_template('newpost.html', title="newpost", form=form)
Esempio n. 28
0
def createforum():
    form = ForumForm()
    if form.validate_on_submit():
        user = Forum(userID=current_user.id, book_title=form.book_title.data, author=form.author.data)
        db.session.add(user)
        db.session.commit()

        flash('Created new forum: {}'.format(
            form.book_title.data))
        final_form = ForumForm()
        render_template('createforum.html', title='New Post', form=final_form)
    return render_template('createforum.html',title='New Post', form=form)
Esempio n. 29
0
def login():
    form = LoginForm()
    user = User.query.filter_by(username=form.username.data).first()
    if current_user.is_authenticated:
        return redirect(url_for('index', user=user))
    if form.validate_on_submit():
        if user is None or not user.check_password(form.password.data):
            flash('Invalid username or password')
            return redirect(url_for('login'))
        login_user(user, remember=form.remember_me.data)
        return redirect(url_for('index', user=user))
    return render_template('login.html', title='Sign In', form=form)
Esempio n. 30
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        flash('Congratulations, you are now a registered user!')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)