Exemple #1
0
def delete():
    delete = DeleteForm()
    if delete.validate_on_submit():
        customer = Players.query.filter_by(
            first_name=delete.player_firstname.data,
            last_name=delete.player_lastname.data).first()
        db.session.delete(customer)
        db.session.commit()
        return redirect(url_for('home'))
    delete_genre = DeleteGenreForm()
    if delete_genre.validate_on_submit():
        category = Genres.query.filter_by(
            genre_name=delete_genre.genrename.data).first()
        db.session.delete(category)
        db.session.commit()
        return redirect(url_for('genre'))
    delete_game = DeleteGameForm()
    if delete_game.validate_on_submit():
        item = Games.query.filter_by(
            game_name=delete_game.gamename.data).first()
        db.session.delete(item)
        db.session.commit()
        return redirect(url_for('game'))
    return render_template('delete.html',
                           title='Delete',
                           delete=delete,
                           delete_genre=delete_genre,
                           delete_game=delete_game)
Exemple #2
0
def deleterecipe():
    deleteform = DeleteForm()
    info = "Enter a Recipe to Delete"

    if deleteform.validate_on_submit():
        name = deleteform.deleterecipe.data
        confirm = deleteform.confirmdelete.data

        if confirm == 1 or confirm == "Confirm":
            recipe = Recipes.query.filter_by(name=name).delete()
            db.session.commit()
            info = str(name) + " has been deleted"
            return render_template("delete.html",
                                   title="Delete Recipe",
                                   deleteform=deleteform,
                                   info=info)

        else:
            info = "You must select 'Confirm' to delete " + str(name)
            return render_template("delete.html",
                                   title="Delete Recipe",
                                   deleteform=deleteform,
                                   info=info)

    return render_template("delete.html",
                           title="Delete Recipe",
                           deleteform=deleteform,
                           info=info)
Exemple #3
0
def home():
    postData = Posts.query.all()
    deleteform = DeleteForm()

    if deleteform.validate_on_submit():
        if deleteform.data:
            Posts.query.filter_by(name=deleteform.character_name.data).delete()
            db.session.commit()

    return render_template('home.html',
                           title='Home',
                           posts=postData,
                           destroy=deleteform)
Exemple #4
0
def delete_patient():
    if 'user_id' in session and session['user_type'] == 'E':
        # code here
        form = DeleteForm()
        if form.validate_on_submit():
            sql = text(
                "SELECT  patient_ssn FROM patients WHERE patient_id = :x AND status =:state"
            )
            rslt = db.engine.execute(sql,
                                     x=form.patient_id.data,
                                     state='ACTIVE')
            name = [row[0] for row in rslt]
            if len(name) == 0:
                flash('Patient not found !', 'warning')
            else:
                if form.get.data:
                    set_details(
                        form)  # populating fields and all are read only

                elif form.delete.data and form.patient_name.data:  # to ensure get has been called
                    sql = text(
                        'UPDATE patients SET status = "INACTIVE" WHERE patient_id = :id AND status = :state'
                    )
                    db.engine.execute(sql,
                                      id=form.patient_id.data,
                                      state='ACTIVE')
                    # removing user specific data from patient_diagnostic_table
                    sql = text(
                        'DELETE FROM patient_diagnostics WHERE patient_id =:id '
                    )
                    db.engine.execute(sql, id=form.patient_id.data)
                    # removing user specific data from medicine_track_table
                    sql = text(
                        'DELETE FROM medicine_track_data WHERE patient_id =:id '
                    )
                    db.engine.execute(sql, id=form.patient_id.data)
                    db.session.commit()
                    flash('Patient deletion initiated successfully', 'success')
                    return redirect(url_for('delete_patient'))
                else:
                    flash(
                        'Please fill the fields using GET button then click on UPDATE button',
                        'warning')
        return render_template('delete_patient.html',
                               form=form,
                               title='Delete Patient Details')
    else:
        flash('You are not logged in ', 'danger')
        return redirect(url_for('login'))
Exemple #5
0
def desk_patientsearch():
    if 'username' in session and 'AD' in session['username']:
        form = DeleteForm(request.form)
        if request.method == 'POST':
            if request.form['action'] == 'show':
                con = mysql.connect()
                cursor = con.cursor()
                query = "SELECT * FROM patient WHERE id = %s "
                cursor.execute(query, (form.pid.data, ))
                pdata = cursor.fetchall()
                cursor.close()
                con.commit()
                con.close()
                if pdata:
                    return render_template("desk/search.html",
                                           rudtest=pdata,
                                           form=form,
                                           desk_patient_search_page=True)
                else:
                    flash("Patient not Found")
                    return render_template("desk/search.html",
                                           rudtest=pdata,
                                           form=form,
                                           desk_patient_search_page=True)

        else:
            return render_template("desk/search.html",
                                   form=form,
                                   desk_patient_search_page=True)
    else:
        return redirect(url_for('login'))