Пример #1
0
def testRentals():
    rental1 = rental("1", "12", "date", "10")
    rental2 = rental("2", "31", "date1", "11")
    rental3 = rental("3", "32", "date2", "14")
    rental4 = rental("4", "41", "date3", "100")

    assert rental1.returnCustomerId() == "1"
    assert rental2.returnCustomerId() == "2"
    assert rental3.returnCustomerId() == "3"
    assert rental4.returnCustomerId() == "4"

    assert rental1.returnBookId() == "12"
    assert rental2.returnBookId() == "31"
    assert rental3.returnBookId() == "32"
    assert rental4.returnBookId() == "41"

    assert rental1.returnDate() == "date"
    assert rental2.returnDate() == "date1"
    assert rental3.returnDate() == "date2"
    assert rental4.returnDate() == "date3"

    assert rental1.returnDays() == "10"
    assert rental2.returnDays() == "11"
    assert rental3.returnDays() == "14"
    assert rental4.returnDays() == "100"

    assert rental1.returnDateYear() == "date"
    assert rental2.returnDateYear() == "date"
    assert rental3.returnDateYear() == "date"
    assert rental4.returnDateYear() == "date"
Пример #2
0
def edit_rentalcustomer(rental_id):
    emsg = ''
    if not checkSession(1):
        return redirect("/mainmenu")
    r = rental()
    v = vehicle()
    v.getAvailableVehicles()
    if request.args.get('action') == 'insert':
        r.createBlank()
        print r.data
        r.data[0]['rental_startdate'] = request.form.get('rental_startdate')
        r.data[0]['rental_duration'] = request.form.get('rental_duration')
        r.data[0]['rental_price'] = request.form.get('rental_price')
        r.data[0]['rental_insurance'] = request.form.get('rental_insurance')
        r.data[0]['user_id'] = session['user_data']['user_id']
        r.data[0]['vehicle_id'] = request.form.get('vehicle_id')
        if r.verify_rental():
            r.insert()
            emsg = 'Rental added.'
        else:
            emsg = '<div style="color:red;">' + r.getErrorHTML() + '</div>'

    if rental_id == 'new':
        r.createBlank()
        w = 'Add'
        a = 'insert'
    else:
        r.getById(rental_id)
        w = 'Edit'
        a = 'update'
    html = '''
    <b>''' + w + ''' Rental ''' + rental_id + '''</b><br><br>
    ''' + emsg + '''
    <form action="/rental/''' + str(
        rental_id) + '''?action=''' + a + '''" method="POST">
        Rental Start Date<br>
        <input name="rental_startdate" type="date" value="''' + r.data[0][
            'rental_startdate'] + '''" /><br>
        Rental Duration<br>
        <input name="rental_duration" type="number" value="''' + r.data[0][
                'rental_duration'] + '''" /><br>
        Vehicle<br>
        ''' + v.getAvailableDropDown() + '''<br>
        Rental Price<br>
        <input name="rental_price" type="text" value="''' + str(
                    r.data[0]['rental_price']) + '''" /><br>
        Rental Insurance<br>
        <input name="rental_insurance" type="text" value="''' + r.data[0][
                        'rental_insurance'] + '''" /><br>
        <br><br>
        <input type="submit" value="Submit"/><br>
        <a href="/mainmenu">Main Menu</a><br>
    </form>
    
    '''

    return header() + html + footer()
Пример #3
0
def list_customerrental():
    if not checkSession(1):
        return redirect("/mainmenu")
    html = ''' <b> Customer Rentals</b>
    <table style="width:600px;">
        <tr style="background-color:#bbb;">
            <td>User ID</td>
            <td>Rental ID</td>
            <td>Start Date</td>
            <td>Duration</td>
            <td>Rental Price</td>
            <td>Rental Insurance</td>
            <td>Make</td>
            <td>Model</td>
        </tr>'''
    r = rental()
    r.getCustomerRentals(session['user_data']['user_id'])
    i = 0
    for row in r.data:
        c = '#eee;'
        if i % 2 == 0:
            c = '#ddd;'
        html += '''<tr style="background-color:''' + c + ''''">
            <td>''' + str(row['user_id']) + '''</td>
            <td>''' + str(row['rental_id']) + '''</td>
            <td>''' + str(row['rental_startdate']) + '''</td>
            <td>''' + str(row['rental_duration']) + '''</td>
            <td>''' + str(row['rental_price']) + '''</td>
            <td>''' + str(row['rental_insurance']) + '''</td>
            <td>''' + str(row['make']) + '''</td>
            <td>''' + str(row['modelr']) + '''</td>
        </tr>'''
        i += 1

    html += '''</table>
    <a href="rental/new">Add New Rental</a>
    <br><a href = "/mainmenu">Main Menu</a><br>
    '''
    return header() + html + footer()
Пример #4
0
 def add(self, rentData):
     self._rentalRepo.append(
         rental(rentData[0], rentData[1], rentData[2], rentData[3]))