Skip to content

Instantly share code, notes, and snippets.

@edvm
Created April 13, 2015 18:28
Show Gist options
  • Select an option

  • Save edvm/f1f90a9e7218db6cd5bc to your computer and use it in GitHub Desktop.

Select an option

Save edvm/f1f90a9e7218db6cd5bc to your computer and use it in GitHub Desktop.
if (coupon.group.ctype == SINGLE_USE_ONE_MEMBER_ONLY
and CouponStatus.objects.filter(coupon=coupon).exists()):
log("Member %s tried to redeem a single-use single-member coupon, failed: %s" % (
member.pk, code,
))
return (False, u'Only one promo code may be redeemed per transaction')
elif coupon.group.ctype == ONCE_PER_MEMBER_MAX_USES:
if 0 < coupon.max_users <= CouponStatus.objects.filter(coupon=coupon).count():
log("Member %s tried to redeem a once-per-member max user coupon that "
"was maxed out, failed: %s" % (member.pk, code))
return (False, u'Code has already been redeemed!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment