Beispiel #1
0
        'high_price': '30.74',
        'artisan_name': 'Thomas',
        'photo': 'product6.jpg'
    },
    {
        'area': 'Guest Services',
        'name': 'Yo Yo',
        'description': 'Description 7',
        'low_price': '10.00',
        'high_price': '29.74',
        'artisan_name': 'Conan',
        'photo': 'product7.jpg'
    },
]:

    d = hmod.SaleItem()
    for k, v in data.items():
        setattr(d, k, v)
    d.save()

for data in [
    {
        'name': 'Cannonball',
        'description': 'Weapons',
        'current_price': '48.99',
        'photo': 'product1.jpg'
    },
    {
        'name': 'Pistol',
        'description': 'Weapons',
        'current_price': '5.43',
Beispiel #2
0
     hmod.User.objects.get(id=1), hmod.User.objects.get(id=2)],
    ['Old Timey baking adventure',
     'a walk through of the daily process required for feeding oneself during colonial times', 1, hmod.Event.objects.get(id=1), hmod.User.objects.get(id=2), hmod.User.objects.get(id=3)],
    ['Old Timey arms display', 'a display of the progress of colonial weaponry through the time period', 1,
     hmod.Event.objects.get(id=2), hmod.User.objects.get(id=3), hmod.User.objects.get(id=2)],
]:
    area = hmod.Area()
    area.name = data[0]
    area.description = data[1]
    area.placeNumber = data[2]
    area.event_ID = data[3]
    area.coordinator_ID = data[4]
    area.supervisor_ID = data[5]
    area.save()
    
    
for data in [

    ['Colonial Knife', 'a dull, rusty knife', 22.50, 35.50, hmod.Area.objects.get(id=1)],
    ['Colonial Broom', 'an atrsy colonial broom', 22.50, 40.50, hmod.Area.objects.get(id=1)],
    ['Colonial Stool', 'a typical colonial stool', 52.50, 55.50, hmod.Area.objects.get(id=2)],
    ['Colonial spood', 'a spoon typical of the time period', 32.50, 35.50, hmod.Area.objects.get(id=3)],

        ]:
    saleItem = hmod.SaleItem()
    saleItem.name = data[0]
    saleItem.description = data[1]
    saleItem.low_price = data[2]
    saleItem.high_price = data[3]
    saleItem.area_ID = data[4]
    saleItem.save()
Beispiel #3
0
def process_cc(request):
    params = {}

    API_URL = 'http://dithers.cs.byu.edu/iscore/api/v1/charges'
    API_KEY = '5ac6b61282edafc1b039a0cd314d11d9'

    #All of this data will be dynamic during INTEX_II. For now, it's hardcoded.
    r = requests.post(
        API_URL,
        data={
            'apiKey': API_KEY,
            'currency': 'usd',
            'amount': '5.99',  #Get from form
            'type': 'Visa',
            'number': '4732817300654',  #Get from form
            'exp_month': '10',  #Get from form
            'exp_year': '15',  #Get from form
            'cvc': '411',  #Get from form
            'name': 'Cosmo Limesandal',  #Get from form
            'description': 'Charge for [email protected]"',  #Get from form
        })

    resp = r.json()

    if 'error' in resp:  # error?
        print("ERROR: ", resp['error'])
        return HttpResponseRedirect('/homepage/checkout/')

    else:
        a = hmod.Address.objects.all().order_by("-id").first()
        order = hmod.Order()
        order.phone = request.user.phone,
        order.order_date = datetime.today()
        order.date_paid = datetime.today()
        order.ships_to = a
        order.customer = request.user
        order.save()

        if "rental" in request.session['ptype']:
            rentalProductDictionary = {}
            orderTotal = 0
            for k, v in request.session['rentalShopCartDict'].items():
                rentalProductObject = hmod.RentalProduct.objects.get(id=k)
                rentalProductDictionary[rentalProductObject] = int(v)
                orderTotal += rentalProductObject.price_per_day * v
                ri = hmod.RentalItem()
                ri.date_out = datetime.today()
                ri.date_due = datetime.today() + timedelta(days=int(v))
                ri.rental_product = hmod.RentalProduct.objects.get(id=k)
                ri.amount = rentalProductObject.price_per_day * v
                ri.order = hmod.Order.objects.all().order_by("-id").first()
                ri.discount_percent = 0
                ri.save()

            params['orderTotal'] = orderTotal
            params['rentals'] = rentalProductDictionary

            ##Jong's Email Idea:
            user_email = request.user.email
            emailbody = templater.render(request, 'checkout_rental_email.html',
                                         params)
            send_mail("Thank You -- CHF Receipt",
                      emailbody,
                      '*****@*****.**', [user_email],
                      html_message=emailbody,
                      fail_silently=False)

            request.session['rentalShopCartDict'].clear()
            request.session.modified = True

            return HttpResponseRedirect('/homepage/thank_you/')

        else:
            productDictionary = {}
            orderTotal = 0
            for k, v in request.session['shopCartDict'].items():
                productObject = hmod.SerializedProduct.objects.get(id=k)
                productDictionary[productObject] = int(v)
                orderTotal += productObject.product_specification.price * v
                si = hmod.SaleItem()
                si.quantity = v
                si.product = hmod.SerializedProduct.objects.get(id=k)
                si.amount = productObject.product_specification.price * v
                si.order = hmod.Order.objects.all().order_by("-id").first()
                si.save()

            params['orderTotal'] = orderTotal
            params['products'] = productDictionary

            print(">>>>>>>>>>>>")
            print(request.session['shopCartDict'])

            ##Jong's Email Idea:
            user_email = request.user.email
            emailbody = templater.render(request,
                                         'checkout_product_email.html', params)
            send_mail("Thank You -- CHF Receipt",
                      emailbody,
                      '*****@*****.**', [user_email],
                      html_message=emailbody,
                      fail_silently=False)

            request.session['shopCartDict'].clear()
            request.session.modified = True

            return HttpResponseRedirect('/homepage/thank_you/')