示例#1
0
def submit_form(request):
    params = {}
    if request.method == 'POST':
        print("the method is post")
        form = card_form(request.POST)
        if form.is_valid():
            #charge the API

            #If the transaction is successful do the following
            #make the transaction
            trans = hmod.Transaction()
            trans.customer = request.user
            trans.date = datetime.datetime.now()
            trans.date_paid = datetime.datetime.now()
            trans.payment_id = form.ID
            trans.save()

            print(trans.payment_id)

            ids = trans.id
            print(ids)

            if 'rental_shopping_cart' in request.session:
                #create the rental line items tying each one to the user
                now = datetime.datetime.now()
                rentalItems = request.session['rental_shopping_cart']
                for i in rentalItems:
                    #get the wardrobe item
                    wdbItem = hmod.WardrobeItem.objects.get(id=i)
                    #change its its available for rental status
                    wdbItem.is_available_for_rental = False
                    #save the item
                    wdbItem.save()
                    rentalItem = hmod.RentedLineItem()
                    rentalItem.wardrobe_item_ID = wdbItem
                    rentalItem.date_out = now
                    print('dateout assigned')
                    date_due = now + datetime.timedelta(days=7)
                    print(date_due)
                    rentalItem.date_due = now + datetime.timedelta(days=7)
                    print("date_due assigned")
                    rentalItem.transaction_ID = hmod.Transaction.objects.get(
                        id=ids)
                    print('transaction assigned')
                    rentalItem.save()
                    print('made it to the return statement')

            email_text = ''

            return HttpResponse('''
                <script>
                    window.location.href = "/Store/ShoppingCart.confirmation/%s"
                </script>


            ''' % (request.urlparams[0]))

    params['warnings'] = ''
    params['form'] = form
    print("end of method reached")
    return templater.render_to_response(request,
                                        'ShoppingCart.submit_form.html',
                                        params)
示例#2
0
    event.venue_name = data[5]
    event.save()

for data in [

    [hmod.User.objects.get(id=1), '2015-03-16'],
    [hmod.User.objects.get(id=1), '2015-03-16'],
    [hmod.User.objects.get(id=2), '2015-03-16'],
    [hmod.User.objects.get(id=2), '2015-03-16'],
    [hmod.User.objects.get(id=1), '2015-03-16'],
    [hmod.User.objects.get(id=3), '2015-03-16'],
    [hmod.User.objects.get(id=3), '2015-03-16'],
    [hmod.User.objects.get(id=2), '2015-03-16'],

]:
    transaction = hmod.Transaction()
    transaction.customer = data[0]
    transaction.date = data[1]
    transaction.save()

for data in [

    ['Good', 'Chip on the side', 1.00, 5.00, '2015-04-01', '2015-03-01', None, 15, 6, hmod.WardrobeItem.objects.get(id=1),
     hmod.Transaction.objects.get(id=7)],
    ['Fair', 'Ripped cloth', 2.00, 4.00, '2015-03-16', '2015-04-01', '2015-04-01', 10, 6,
     hmod.WardrobeItem.objects.get(id=1), hmod.Transaction.objects.get(id=1)],
    ['Fair', 'Ripped cloth', 2.00, 4.00, '2015-03-16', '2015-02-2', None, 10, 6, hmod.WardrobeItem.objects.get(id=1),
     hmod.Transaction.objects.get(id=2)],
    ['Fair', 'Ripped cloth', 2.00, 4.00, '2015-03-16', '2014-12-01', None, 10, 6, hmod.WardrobeItem.objects.get(id=2),
     hmod.Transaction.objects.get(id=3)],
    ['Fair', 'Ripped cloth', 2.00, 4.00, '2015-03-16', '2015-01-23', None, 10, 6, hmod.WardrobeItem.objects.get(id=1),
示例#3
0
文件: init_db.py 项目: arkon24/CHF
w.date_acquired = '2012-05-06'
w.cost = '30.99'
w.status = 'used'
w.for_sale = True
w.condition_new = 'used'
w.notes = 'used'
w.size = 'mens 10'
w.size_modifier = 'narrow'
w.gender = 'male'
w.color = 'brown'
w.pattern = ''
w.start_year = '1710'
w.end_year = '1780'
w.save()

tr = hmod.Transaction()
tr.customer = hmod.Users.objects.get(username='******')
tr.date = '2015-03-02'
tr.phone = '201-889-4587'
tr.date_packed = '2015-03-02'
tr.date_shipped = '2015-03-02'
tr.packed_by = hmod.Agent.objects.get(username='******')
tr.shipped_by = hmod.Agent.objects.get(username='******')
tr.tracking_number = '10'
tr.save()

tr = hmod.Transaction()
tr.customer = hmod.Users.objects.get(username='******')
tr.date = '2015-03-01'
tr.phone = '720-554-6851'
tr.date_packed = '2015-03-01'