Subversion Repositories SmartDukaan

Rev

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

Rev 6570 Rev 6649
Line 43... Line 43...
43
    coupon.coupon_code = coupon_code
43
    coupon.coupon_code = coupon_code
44
    coupon.arguments = ""
44
    coupon.arguments = ""
45
    session.commit()
45
    session.commit()
46
 
46
 
47
def create_coupon(promotionId, endOn, email, amount, isCod, usage, prefix=None):
47
def create_coupon(promotionId, endOn, email, amount, isCod, usage, prefix=None):
48
    if promotionId not in (26,27):
48
    if promotionId not in (26,27,28):
49
        raise PromotionException(101, 'Only promotion ids 26 and 27 are expected')
49
        raise PromotionException(101, 'Only promotion ids 26 and 27 are expected')
50
    promotion = Promotion.get_by(id = promotionId)
50
    promotion = Promotion.get_by(id = promotionId)
51
    if promotion:     
51
    if promotion:     
52
        coupon_code = uuid.uuid4().hex[:10] if prefix is None else prefix + uuid.uuid4().hex[:10]
52
        coupon_code = uuid.uuid4().hex[:10] if prefix is None else prefix + uuid.uuid4().hex[:10]
53
        coupon = Coupon.get_by(coupon_code = coupon_code)
53
        coupon = Coupon.get_by(coupon_code = coupon_code)