Exemple #1
0
def employee():
    # if current_user.is_authenticated:
    #     return redirect(url_for('portal'))
    form = LoginForm()
    if form.validate_on_submit():
        return redirect(url_for('portal'))
    return render_template('employee.html', form=form)
Exemple #2
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password, form.password.data):
            login_user(user, remember=form.remember.data)
            next_page = request.args.get('next')
            return redirect(next_page) if next_page else redirect(url_for('home'))
        else:
            flash('Login Unsuccessful. Please check email and password', 'danger')
    return render_template('login.html', title='Login', form=form)
Exemple #3
0
def upload():
    if current_user.is_authenticated:

        form = UploadGene()

        if form.validate_on_submit():
            filename = secure_filename(form.file.data.filename)
            form.file.data.save('' + filename)
            flash("Gene files uploaded!", "success")
            return redirect(url_for('upload'))

        return render_template('upload.html', form=form)
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #4
0
def delete_rf():
    if current_user.is_authenticated:
        form = RFDelete()
        if form.validate_on_submit():
            RF_Model.query.filter_by(gene_id=form.gene_id.data,
                                     population_id=form.pop_id.data).delete()
            db.session.commit()
            flash("The gene has been deleted", "success")
            return redirect(url_for('home'))
        return render_template('delete_rf.html',
                               title='Delete Gene Model',
                               form=form,
                               legend='Delete RF Model')
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #5
0
def deleteuser():
    if current_user.is_authenticated:
        form = UserDeleteForm.new()

        if form.validate_on_submit():
            User.query.filter_by(user_id=form.user.data).delete()
            db.session.commit()
            flash('User has been deleted.', 'success')
            return redirect(url_for('home'))
        return render_template('delete_user.html',
                               title='Delete Regular User',
                               form=form,
                               legend='Delete Regular User')
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #6
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('choices'))
    form = LoginForm()
    if form.validate_on_submit():
        Employee = employee.query.filter_by(
            username=form.username.data).first()
        if Employee and bcrypt.check_password_hash(Employee.password,
                                                   form.password.data):
            login_user(Employee, remember=form.remember.data)
            identity_changed.send(current_app._get_current_object(),
                                  identity=Identity(Employee.employeeID))

            return redirect(url_for('front'))
        else:
            flash('Login Unsuccessful. Please confirm password', 'danger')
    return render_template('signin.html', form=form)
Exemple #7
0
def rf_model():
    if current_user.is_authenticated:

        form = RF()
        if form.validate_on_submit():
            gene = Gene.query.filter_by(gene_name=form.genename.data).first()
            rf = RF_Model(gene_id=gene.gene_id,
                          population_id=form.pop_id.data,
                          cross_val_performance=form.cross_val.data,
                          trees=form.tree.data)
            db.session.add(rf)
            db.session.commit()
            flash("You have added the gene model")
            return redirect(url_for('home'))
        return render_template('rf_model.html',
                               title='New RF Gene Model',
                               form=form,
                               legend='RF Model')
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #8
0
def basic():
    genes = Gene.query.all()
    if current_user.is_authenticated:
        form = GeneForm()
        if form.validate_on_submit():
            geneID = form.gene.data
            geneinfo = db.engine.execute(
                "SELECT * FROM gene WHERE gene_id = %s", geneID).fetchone()

            knn = db.engine.execute(
                "SELECT population_description, cross_val_performance FROM knn_model NATURAL JOIN population WHERE gene_id = %s",
                geneID).fetchall()
            rf = db.engine.execute(
                "SELECT population_description, cross_val_performance FROM rf_model NATURAL JOIN population WHERE gene_id = %s",
                geneID).fetchall()
            svr = db.engine.execute(
                "SELECT population_description, cross_val_performance FROM svr_model NATURAL JOIN population WHERE gene_id = %s",
                geneID).fetchall()

            count1 = db.engine.execute(
                "SELECT COUNT(*) FROM knn_model WHERE gene_id = %s",
                geneID).scalar()
            count2 = db.engine.execute(
                "SELECT COUNT(*) FROM rf_model WHERE gene_id = %s",
                geneID).scalar()
            count3 = db.engine.execute(
                "SELECT COUNT(*) FROM svr_model WHERE gene_id = %s",
                geneID).scalar()
            count = count1 + count2 + count3

            return render_template('results_basic.html',
                                   title='Results',
                                   geneinfo=geneinfo,
                                   knn=knn,
                                   rf=rf,
                                   svr=svr,
                                   count=count)
        return render_template('query_basic.html',
                               title='Basic Gene Search',
                               form=form,
                               legend='Basic Gene Search')
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #9
0
def svr_model():
    if current_user.is_authenticated:
        form = SVR()
        if form.validate_on_submit():
            gene = Gene.query.filter_by(gene_name=form.genename.data).first()
            svr = SVR_Model(gene_id=gene.gene_id,
                            population_id=form.pop_id.data,
                            cross_val_performance=form.cross_val.data,
                            kernel=form.kernel.data,
                            degree=form.degree.data,
                            c=form.c.data)
            db.session.add(svr)
            db.session.commit()
            flash("You have added the gene model")
            return redirect(url_for('home'))
        return render_template('svr_model.html',
                               title='New SVR Gene Model',
                               form=form,
                               legend='SVR Model')
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #10
0
def knn_model():
    if current_user.is_authenticated:

        form = KNN()
        if form.validate_on_submit():
            gene = Gene.query.filter_by(gene_name=form.genename.data).first()
            knn = KNN_Model(gene_id=gene.gene_id,
                            population_id=form.pop_id.data,
                            cross_val_performance=form.cross_val.data,
                            neighbors=form.neigbor.data,
                            weight=form.weight.data,
                            p=form.p.data)
            db.session.add(knn)
            db.session.commit()
            flash("You have added the gene model")
            return redirect(url_for('home'))
        return render_template('knn_model.html',
                               title='New KNN Gene Model',
                               form=form,
                               legend='KNN Model')
    return render_template('login.html', title='Login', form=LoginForm())
Exemple #11
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = LoginForm()
    if form.validate_on_submit():
        user = Users.query.filter_by(name=form.username.data).first()
        if user and bcrypt.check_password_hash(user.password,
                                               form.password.data):
            login_user(user, remember=form.remember.data)
            flash('login successful', 'success')
            Admins = db.session.query(Admin.adminID)
            for row in Admins:
                if row.adminID == user.userID:
                    flash(current_user.get_id(), 'success')
                    return redirect(url_for('adminPage'))
            next_page = request.args.get('next')
            return redirect(next_page) if next_page else redirect(
                url_for('home'))
        else:
            flash('Login Unsuccessful. Please check email and password',
                  'danger')
    return render_template('login.html', title='Login', form=form)
Exemple #12
0
def employee():
    form = LoginForm()
    if form.validate_on_submit():
        return redirect(url_for('portal'))
    return render_template('employee.html', form=form)
Exemple #13
0
def submit_job():
    if current_user.is_authenticated:

        return "<h2> This page is under construction</h2>"
    return render_template('login.html', title='Login', form=LoginForm())