Subversion Repositories SmartDukaan

Rev

Rev 7092 | Rev 7987 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7092 Rev 7746
Line 42... Line 42...
42
    coupon = Coupon()
42
    coupon = Coupon()
43
    coupon.promotion = promotion
43
    coupon.promotion = promotion
44
    coupon.coupon_code = coupon_code
44
    coupon.coupon_code = coupon_code
45
    coupon.arguments = ""
45
    coupon.arguments = ""
46
    session.commit()
46
    session.commit()
-
 
47
    
-
 
48
def remove_all_coupons_by_promotion_id(promotion_id):
-
 
49
    promotion = Promotion.get_by(id=promotion_id)
-
 
50
    if(promotion is None):
-
 
51
        raise PromotionException(101, 'Could not find Promotion for id' + str(promotion_id))
-
 
52
    elif(promotion.end_on > datetime.datetime.now()):
-
 
53
        raise PromotionException(111, 'This promotion is still running. Promotion id' + str(promotion_id))
-
 
54
    deletecount = Coupon.query.filter_by(promotion_id = promotion_id).delete()
-
 
55
    session.commit()
-
 
56
    return deletecount
47
 
57
 
48
def create_coupon(promotionId, couponCode, arguments, isCod, prefix=None):
58
def create_coupon(promotionId, couponCode, arguments, isCod, prefix=None):
49
    if promotionId not in (26,27,28):
59
    if promotionId not in (26,27,28):
50
        raise PromotionException(101, 'Only promotion ids 26 and 27 are expected')
60
        raise PromotionException(101, 'Only promotion ids 26 and 27 are expected')
51
    promotion = Promotion.get_by(id = promotionId)
61
    promotion = Promotion.get_by(id = promotionId)