-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added admin-only bulk enrollment form #178
Conversation
@pdpinch Screenshots ^^^ |
Codecov Report
@@ Coverage Diff @@
## master #178 +/- ##
==========================================
+ Coverage 92.69% 93.28% +0.59%
==========================================
Files 134 142 +8
Lines 3845 4143 +298
Branches 222 232 +10
==========================================
+ Hits 3564 3865 +301
+ Misses 240 235 -5
- Partials 41 43 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is meant to be used for Coupon
s related to CouponPaymentVersion
objects with coupon_type='single-use'
. There should be n
number of these Coupon
objects equal to CouponPaymentVersion.num_coupon_codes
, each with its own unique code. Each user should get sent a different coupon code, no two users should get the same code. So there will also need to be a check that there are at least as many coupon codes as there are emails in the csv file.
There is a form you can use to create these coupons here: /ecommerce/admin/coupons
Also heads up that there may be some changes to what's allowed to be a product (maybe just |
Might be good to also track which coupon is sent to which user. I've got a |
|
@mbertrand Sounds good. Tracking the sending of coupons to users should be easy enough. I'll follow up with you about sending each user a different code |
@mbertrand Ready for another look |
1059fa9
to
a3e3370
Compare
ecommerce/api.py
Outdated
.filter(coupon__enabled=True, coupon__payment=coupon_payment) | ||
.distinct("product") | ||
) | ||
if product_coupons.count() != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to have multiple CouponEligibility
objects for the same coupon. I made my 100% off coupon apply to 3 products so I always get the message "In order to perform bulk enrollment, there must be 100%-off coupons applied to products. None were found."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, if a coupon has more than 1 product it shouldn't be listed
ecommerce/views.py
Outdated
return Response( | ||
status=status.HTTP_400_BAD_REQUEST, | ||
data={ | ||
"errors": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is correctly returned when the csv file has more emails than there are coupons, but is not displayed on the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, forgot about this one. Will fix
ecommerce/views.py
Outdated
|
||
send_bulk_enroll_emails(emails, product_coupons) | ||
|
||
return Response( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response is returned but nothing on the page indicates success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, looks like I messed up the success message after my most recent commit. Will fix
ecommerce/api.py
Outdated
) | ||
if product_coupons.count() != 1: | ||
continue | ||
yield coupon_payment, product_coupons[0].product |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dropdown list only shows one of the products that a coupon is valid for, there may be more than one. I made a coupon valid for 3 products, the dropdown showed one of those products but then different emails got sent different products that the coupon applied to:
This should probably be changed to show the coupon for every product that it is applicable to, and then emails should get sent for that particular product to all user emails if selected:
for product_coupon in product_coupons:
yield coupon_payment, product_coupon.product
Though maybe no one will ever create a 100% off coupon that applies to multiple products (nothing on the coupon creation form prevents you from doing so however) - @pdpinch what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS this is after I removed the if product_coupons.count() != 1
condition to see what would happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our primary use case is where bulk enrollment apply to one product (program, course, or courserun). Can we limit the form to only coupons of that type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limiting the bulk enrollment to one product also will simplify the mailing: just one one email for each email address uploaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it already is here, so good as is @gsidebo!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to be more explicit about that in the message and in the code comments. I'll add some clarification
1063be2
to
90ba824
Compare
@mbertrand Ready for you again. I'll work on rebasing |
@mbertrand I ended up just solving #188 and preventing repeated invites for the same product coupons in one shot. That's what made the most sense. Give it another try. You should see and error when I'll rebase after your review so I can squash the commits first |
cc1e29a
to
d9e6e51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 works great
d9e6e51
to
9ba33e0
Compare
Pre-Flight checklist
What are the relevant tickets?
Closes #112
What's this PR do?
/ecommerce/admin/
)How should this be manually tested?
/ecommerce/admin/enroll/
, select your CSV file, choose one of your coupons in the dropdown, and click the enroll button.Where should the reviewer start?
Probably
static/js/containers/pages/admin/BulkEnrollmentPage.js
Any background context you want to provide?
CouponEligibility
object is all we need to map a coupon to those objects. We didn't need the separate dropdownScreenshots (if appropriate)