Beispiel #1
0
def CouponsGenerate(request, reward_id):
	amount = 5
	reward = get_object_or_404(Reward,pk = reward_id)
	for i in range(amount):
		coupon = Coupon(reward = reward)
		coupon.save()
	return redirect(reverse('rewards-vendor-coupons', kwargs={'reward_id': reward_id}))
Beispiel #2
0
def generate_coupon(coin, description, producer):
    if coin is None or description is None:
        raise Error("coin and description required")

    coupon = Coupon(coin=coin, description=description, producer=producer)

    try:
        coupon.save()
        return coupon
    except ValidationError:
        raise Error("invalid value")
Beispiel #3
0
    def on_post(self, req, resp, id):
        try:
            coupon = Coupon(id=id)
            couponBody = req.json

            for key in couponBody.keys():
                coupon[key] = couponBody[key]

            print(coupon.save())

        except Exception as e:
            ResponseUtil.error(e, resp)
Beispiel #4
0
    def on_post(self, req, resp, id):
        try:
            coupon = Coupon(id=id)
            couponBody = req.json

            for key in couponBody.keys():
                coupon[key] = couponBody[key]

            item = coupon.save()
            ResponseUtil.makeBody(resp, item.to_json())
        except Exception as e:
            print(e)
            ResponseUtil.error(e, resp)