| Line 60... |
Line 60... |
| 60 |
if promotionId not in (26,27,28):
|
60 |
if promotionId not in (26,27,28):
|
| 61 |
raise PromotionException(101, 'Only promotion ids 26 and 27 are expected')
|
61 |
raise PromotionException(101, 'Only promotion ids 26 and 27 are expected')
|
| 62 |
promotion = Promotion.get_by(id = promotionId)
|
62 |
promotion = Promotion.get_by(id = promotionId)
|
| 63 |
if promotion:
|
63 |
if promotion:
|
| 64 |
if couponCode == '':
|
64 |
if couponCode == '':
|
| 65 |
coupon_code = uuid.uuid4().hex[:10] if prefix is None else prefix + uuid.uuid4().hex[:10]
|
65 |
coupon_code = uuid.uuid4().hex[:10] if prefix is None else prefix + uuid.uuid4().hex[:6]
|
| 66 |
else:
|
66 |
else:
|
| 67 |
coupon_code = couponCode
|
67 |
coupon_code = couponCode
|
| 68 |
coupon = Coupon.get_by(coupon_code = coupon_code)
|
68 |
coupon = Coupon.get_by(coupon_code = coupon_code)
|
| 69 |
while coupon is not None:
|
69 |
while coupon is not None:
|
| 70 |
coupon_code = uuid.uuid4().hex[:10] if prefix is None else prefix + uuid.uuid4().hex[:10]
|
70 |
coupon_code = uuid.uuid4().hex[:10] if prefix is None else prefix + uuid.uuid4().hex[:6]
|
| 71 |
coupon = Coupon.get_by(coupon_code = coupon_code)
|
71 |
coupon = Coupon.get_by(coupon_code = coupon_code)
|
| 72 |
|
72 |
|
| 73 |
arguments_map= ast.literal_eval(arguments)
|
73 |
arguments_map= ast.literal_eval(arguments)
|
| 74 |
if arguments_map.has_key('orderId'):
|
74 |
if arguments_map.has_key('orderId'):
|
| 75 |
coupon_code = coupon_code +'#'+ str(arguments_map['orderId'])
|
75 |
coupon_code = coupon_code + 'Id' +str(arguments_map['orderId'])
|
| 76 |
coupon = Coupon()
|
76 |
coupon = Coupon()
|
| 77 |
coupon.promotion = promotion
|
77 |
coupon.promotion = promotion
|
| 78 |
coupon.coupon_code = coupon_code
|
78 |
coupon.coupon_code = coupon_code
|
| 79 |
coupon.arguments = arguments
|
79 |
coupon.arguments = arguments
|
| 80 |
coupon.coupon_category = couponCategory
|
80 |
coupon.coupon_category = couponCategory
|