Ejemplo n.º 1
0
def newanimal():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    elif session['user']['userType'] == 'customer':
        return redirect('login')

    u = userList()
    u.getAll()

    if request.form.get('animalName') is None:
        a = animalList()
        a.set('animalName', '')
        a.set('animalType', '')
        a.set('animalBreed', '')
        a.set('animalAge', '')
        a.set('animalGender', '')
        a.set('animalSize', '')
        a.set('animalPhoto', '')
        a.set('animalStatus', '')
        a.set('userID', '')
        a.add()
        return render_template('animal/newanimal.html',
                               title='New Animal',
                               animal=a.data[0],
                               users=u.data)
    else:
        a = animalList()
        a.set('animalName', request.form.get('animalName'))
        a.set('animalType', request.form.get('animalType'))
        a.set('animalBreed', request.form.get('animalBreed'))
        a.set('animalAge', request.form.get('animalAge'))
        a.set('animalGender', request.form.get('animalGender'))
        a.set('animalSize', request.form.get('animalSize'))
        a.set('animalPhoto', request.form.get('animalPhoto'))
        a.set('animalStatus', request.form.get('animalStatus'))
        a.set('userID', request.form.get('userID'))

        if request.form.get('animalPhoto') == '':
            a.set('animalPhoto', 'noPhoto.jpg')

        a.add()
        if a.verifyNew():
            a.insert()
            print(a.data)
            return render_template('animal/savedanimal.html',
                                   title='Animal Saved',
                                   animal=a.data[0],
                                   users=u.data)
        else:
            return render_template('animal/newanimal.html',
                                   title='Animal Not Saved',
                                   animal=a.data[0],
                                   msg=a.errorList,
                                   users=u.data)
Ejemplo n.º 2
0
def adoptionevent():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')

    an = animalList()
    animalID = ''
    animalID = request.args.get('animalID')
    an.getById(animalID)
    #print('a.data before :', an.data[0])
    #print('USER:'******'user']['userID'])
    if session['user']['userID'] <= 0:
        return redirect('login')
    an.data[0]['animalStatus'] = 'Adopted'
    an.data[0]['userID'] = session['user']['userID']
    an.add()
    #print('an.data[0][animalStatus]', an.data[0]['animalStatus'])
    '''
    a.set('animalStatus','Adopted')
    a.set('userID',session['user']['userID'])
    a.add()
    '''
    #print('a.data after :', an.data[0])
    an.update()

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

    t = transactionList()
    transactionID = ''
    transactionID = request.args.get('transactionID')
    t.getById(transactionID)

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

    e = eventList()
    e.set('eventType', 'Adoption')
    e.set('eventCompletedDate', 'n/a')
    e.set('eventName', 'Adoption of ' + an.data[0]['animalName'])
    e.set('eventResult', 'n/a')
    e.set('animalID', an.data[0]['animalID'])
    e.set('userID', session['user']['userID'])
    e.set('transactionID', transactionID)

    e.add()
    if e.verifyNew():
        e.insert()
        print(e.data)
        return render_template('event/adoptionsuccessful.html',
                               title='event Saved',
                               event=e.data[0])
    else:
        return render_template('event/adoptionevent.html',
                               title='event Not Saved',
                               event=e.data[0],
                               msg=e.errorList)
Ejemplo n.º 3
0
def newadoptiontransaction():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    print(request.args.getlist('param'))

    a = animalList()
    animalID = ''
    animalID = request.args.get('animalID')
    a.getById(animalID)

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

    adoptionFee = 0
    if a.data[0]['animalType'] == 'Dog':
        adoptionFee = 150
    elif a.data[0]['animalType'] == 'Cat':
        adoptionFee = 50

    if request.form.get('transactionType') is None:
        t = transactionList()
        t.set('transactionDate', '')
        t.set('transactionType', '')
        t.set('transactionAmount', '')
        t.set('userID', '')
        t.add()
        return render_template('transaction/newadoptiontransaction.html',
                               title='New Adoption Transaction',
                               transaction=t.data[0],
                               animal=a.data[0],
                               fee=adoptionFee)
    else:
        t = transactionList()
        t.set('transactionID', request.form.get('transactionID'))
        t.set('transactionType', request.form.get('transactionType'))
        t.set('transactionAmount', request.form.get('transactionAmount'))
        t.set('userID', session['user']['userID'])
        t.add()

        if t.verifyNew():
            t.insert()
            #print(t.data)
            return render_template('event/adoptionevent.html',
                                   title='Adoption Transaction Saved',
                                   transaction=t.data[0],
                                   animal=a.data[0],
                                   fee=adoptionFee)
        else:
            return render_template('transaction/newadoptiontransaction.html',
                                   title='Adoption Transaction Not Saved',
                                   transaction=t.data[0],
                                   msg=t.errorList,
                                   animal=a.data[0],
                                   fee=adoptionFee)
Ejemplo n.º 4
0
def viewanimal():
    #customer facing
    a = animalList()
    if request.args.get(a.pk) is None:
        return render_template('error.html', msg='No animal id given.')

    a.getById(request.args.get(a.pk))
    if len(a.data) <= 0:
        return render_template('error.html', msg='Animal not found.')

    print(a.data)
    return render_template('animal/viewanimal.html',
                           title='Animal',
                           animal=a.data[0])
Ejemplo n.º 5
0
def animals():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    elif session['user']['userType'] == 'customer':
        return redirect('login')

    a = animalList()
    a.getAll()

    print(a.data)
    #return ''
    return render_template('animal/animals.html',
                           title='Animal List',
                           animals=a.data)
Ejemplo n.º 6
0
def adoptable():
    #customer facing
    a = animalList()
    animalType = ''
    animalType = request.args.get('animalType', animalType)
    if animalType is None or animalType == '':
        a.getByField('animalStatus', 'available')
        return render_template('animal/adoptable.html',
                               title='Adoptable Animals',
                               animals=a.data,
                               type='Animal')
    else:
        a.getByFields('animalType', animalType, 'animalStatus', 'available')
        return render_template('animal/adoptable.html',
                               title='Adoptable Animals',
                               animals=a.data,
                               type=animalType)

    return render_template('animal/adoptable.html',
                           title='Adoptable Animals',
                           animals=a.data)
Ejemplo n.º 7
0
def event():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    elif session['user']['userType'] == 'customer':
        return redirect('login')

    allAnimals = animalList()
    allAnimals.getAll()

    e = eventList()
    if request.args.get(e.pk) is None:
        return render_template('error.html', msg='No event id given.')

    e.getById(request.args.get(e.pk))
    if len(e.data) <= 0:
        return render_template('error.html', msg='Event not found.')

    #print(e.data)
    return render_template('event/event.html',
                           title='Event Details',
                           event=e.data[0],
                           al=allAnimals.data)
Ejemplo n.º 8
0
def animal():
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')
    elif session['user']['userType'] == 'customer':
        return redirect('login')

    u = userList()
    u.getAll()

    a = animalList()
    if request.args.get(a.pk) is None:
        return render_template('error.html', msg='No animal id given.')

    a.getById(request.args.get(a.pk))
    if len(a.data) <= 0:
        return render_template('error.html', msg='Animal not found.')

    print(a.data)
    return render_template('animal/animal.html',
                           title='Animal',
                           animal=a.data[0],
                           users=u.data)
Ejemplo n.º 9
0
def newappointment():
    #customer facing
    if checkSession() == False:  #check to make sure user is logged in
        return redirect('login')

    userID = session['user']['userID']
    animals = animalList()
    animals.getByField('userID', str(userID))

    if request.form.get('eventType') is None:
        t = transactionList()
        t.set('transactionType', '')
        t.set('transactionAmount', '')
        t.set('userID', '')
        t.add()

        e = eventList()
        e.set('eventType', '')
        e.set('eventScheduleDate', '')
        e.set('eventCompletedDate', '')
        e.set('eventName', '')
        e.set('eventResult', '')
        e.set('animalID', '')
        e.set('userID', '')
        e.set('transactionID', '')
        e.add()

        allAnimals = animalList()
        allAnimals.getAll()
        return render_template('event/newappointment.html',
                               title='New Event',
                               event=e.data[0],
                               animals=animals.data,
                               user=session['user']['userFName'])
    else:
        t = transactionList()
        t.set('transactionType', request.form.get('eventType'))
        t.set('transactionAmount', 0)
        t.set('userID', session['user']['userID'])
        t.add()

        e = eventList()
        e.set('eventID', request.form.get('eventID'))
        e.set('eventType', request.form.get('eventType'))
        e.set('eventCompletedDate', request.form.get('eventCompletedDate'))
        e.set('eventName', request.form.get('eventName'))
        e.set('eventResult', request.form.get('eventResult'))
        e.set('animalID', request.form.get('animalID'))
        e.set('userID', session['user']['userID'])
        #e.set('transactionID',request.form.get('transactionID'))

        e.add()
        if e.verifyNew():
            t.verifyNew()
            t.insert()

            e.set('transactionID', t.data[0]['transactionID'])
            e.add()
            e.insert()

            #print('eventdata:',e.data)
            #print('transactiondata:',t.data)
            return render_template('event/savedappointment.html',
                                   title='event Saved',
                                   event=e.data[0])
        else:
            return render_template('event/newappointment.html',
                                   title='event Not Saved',
                                   event=e.data[0],
                                   msg=e.errorList,
                                   user=session['user']['userFName'],
                                   animals=animals.data)