Ejemplo n.º 1
0
def newadmin():
    if checkSession() == False:
        return redirect('login')
    if request.form.get('fname') is None:
        a = adminList()
        a.set('fname', '')
        a.set('lname', '')
        a.set('email', '')
        a.set('password', '')
        a.set('subscribed', '')
        a.add()
        return render_template('newadmin.html',
                               title='New Admin',
                               admin=a.data[0])
    else:
        a = adminList()
        a.set('fname', request.form.get('fname'))
        a.set('lname', request.form.get('lname'))
        a.set('email', request.form.get('email'))
        a.set('password', request.form.get('password'))
        a.set('subscribed', request.form.get('subscribed'))
        a.add()
        if a.verifyNew():
            a.insert()
            print(a.data)
            return render_template('savedadmin.html',
                                   title='Admin Saved',
                                   admin=a.data[0])
        else:
            return render_template('newadmin.html',
                                   title='Admin Not Saved',
                                   admin=a.data[0],
                                   msg=a.errorList)
Ejemplo n.º 2
0
def login():

    if request.form.get('username') is not None and request.form.get(
            'password') is not None:
        a = adminList()
        if a.tryLogin(request.form.get('username'),
                      request.form.get('password')):
            print('login ok')
            session['user'] = a.data[0]
            session['active'] = time.time()
            print(session['user'])
            return redirect(
                'home'
            )  #redirecting to an html template in reponse valid to user input
        else:  #INVALID VREDENTIALS
            print('login failed')
            return render_template('login.html',
                                   title='Login',
                                   msg='Incorrect login.')
    else:  #THIS IS FOR AN INVALID SESSION NOT INVALID CREDENTIALS
        if 'msg' not in session.keys() or session['msg'] is None:
            m = 'Type your username and password to continue.'
        else:
            m = session['msg']
            session['msg'] = None
        return render_template('login.html', title='Login', msg=m)
Ejemplo n.º 3
0
def newtransaction():
    if checkSession() == False:
        return redirect('login')
    AllPatients = patientList()
    AllPatients.getAll()
    #print(AllPatients.data)
    AllProviders = providerList()
    AllProviders.getAll()
    #print(AllProviders.data)
    AllAdmins = adminList()
    AllAdmins.getAll()
    #print(AllAdmins.data)
    if request.form.get('TransactionID') is None:
        t = transactionList()
        t.set('TransactionID', '')
        t.set('Date', '')
        t.set('Amount', '')
        t.set('Status', '')
        t.set('Insurance', '')
        t.set('Notes', '')
        t.set('AdminID', '')
        t.set('PatientID', '')
        t.set('PCPID', '')
        t.add()
        return render_template('transaction/newtransaction.html',
                               title='New Transaction',
                               transaction=t.data[0],
                               pl=AllPatients.data,
                               prl=AllProviders.data,
                               al=AllAdmins.data)
    else:
        t = transactionList()
        t.set('TransactionID', request.form.get('TransactionID'))
        t.set('Date', request.form.get('Date'))
        t.set('Amount', request.form.get('Amount'))
        t.set('Status', request.form.get('Status'))
        t.set('Insurance', request.form.get('Insurance'))
        t.set('Notes', request.form.get('Notes'))
        t.set('AdminID', request.form.get('AdminID'))
        t.set('PatientID', request.form.get('PatientID'))
        t.set('PCPID', request.form.get('PCPID'))
        t.add()
        if t.verifyNew():
            t.insert()
            print(t.data)
            return render_template('transaction/savedtransaction.html',
                                   title='Transaction Saved',
                                   transaction=t.data[0],
                                   pl=AllPatients.data,
                                   prl=AllProviders.data,
                                   al=AllAdmins.data)
        else:
            return render_template('Transaction/newtransaction.html',
                                   title='Transaction Not Saved',
                                   transaction=t.data[0],
                                   msg=t.errorList,
                                   pl=AllPatients.data,
                                   prl=AllProviders.data,
                                   al=AllAdmins.data)
Ejemplo n.º 4
0
def deleteadmin():
    if checkSession() == False:
        return redirect('login')
    a = adminList()
    a.deleteByID(request.form.get('id'))
    return render_template('deletedAdmin.html',
                           title='Admin Deleted',
                           msg='Admin deleted.')
Ejemplo n.º 5
0
def admins():
    if checkSession() == False:
        return redirect('login')
    a = adminList()
    a.getAll()

    print(a.data)
    return render_template('admins.html', title='Admin List', admins=a.data)
Ejemplo n.º 6
0
def admin():
    if checkSession() == False:
        return redirect('login')
    a = adminList()
    if request.args.get(a.pk) is None:
        return render_template('error.html', msg='No admin id given.')

    a.getById(request.args.get(a.pk))

    if len(a.data) <= 0:
        return render_template('error.html', msg='Admin not found.')

    print(a.data)
    #return''
    return render_template('admin.html', title='Admin', admin=a.data[0])
Ejemplo n.º 7
0
def saveadmin():
    if checkSession() == False:
        return redirect('login')
    a = adminList()
    a.set('id', request.form.get('id'))
    a.set('fname', request.form.get('fname'))
    a.set('lname', request.form.get('lname'))
    a.set('email', request.form.get('email'))
    a.set('password', request.form.get('password'))
    a.set('subscribed', request.form.get('subscribed'))
    a.add()
    a.update()
    print(a.data)
    #return ''
    return render_template('savedadmin.html',
                           title='Admin Saved',
                           admin=a.data[0])
Ejemplo n.º 8
0
def loginadmin():
    if request.form.get('email') is not None and request.form.get(
            'password') is not None:
        a = adminList()
        if a.tryLogin(request.form.get('email'), request.form.get('password')):
            session['user'] = a.data[0]
            session['active'] = time.time()

            return redirect('mainAdmin')
        else:
            return render_template('loginadmin.html',
                                   title='Login',
                                   msg='Incorrect credentials.')
    else:
        if 'msg' not in session.keys() or session['msg'] is None:
            m = 'Type your email and password to continue.'
        else:
            m = session['msg']
            session['msg'] = None

        return render_template('loginadmin.html', title='Login', msg=m)