-
Notifications
You must be signed in to change notification settings - Fork 10
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
Vouchers for user promotion - Part 2: Redemption #671
Conversation
(since we use the association field now, introduced a few commits beforehand)
This is due to the form not being completely loaded while we already go on.
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.
Finally, after quite some time, I approve this PR. With this, we have a really nice voucher system at MaMpf, thank you 🎉
Please make sure to review the changes I've made before squash-merging. Follow-ups to this PR will be a redesign of the profile page where we can make the voucher redemption more prominent. I will also add a warning box to dropdowns that don't allow non-admin users to search for arbitrary users anymore. Just to not confuse them when no results are shown in the dropdown search box.
This PR continues #670. Vouchers can be redeemed in order to take over tutorials, become a lecture editor, become a teacher or become a speaker (of a talk in a seminar).
To Dos
Further To Dos (for reviewer)
Out of scope
views/administration/index/_my_courses.html.erb
.Allow instance methods to be passed to specFactoriesController
for Cypress specs-> moved to Allow dynamic instance method calls on FactoryBot objects in Cypress #696
RefactorUserCreatorController
for Cypress specs-> moved to Allow dynamic instance method calls on FactoryBot objects in Cypress #696
Notes for the reviewer
The redemption of Vouchers is basically done via two actions of the
VouchersController
, namely#verify
and#redeem
.In order to keep the controller lean, I introduced a service model
VoucherProcessor
inapp/services
(see e.g. here). Also, I extracted some stuff into theNotifier
concern inapps/controllers/concerns
since this contains some code also used by theLecturesController
. On the model side, two newActiveRecord
models are used to store redemptions of vouchers:Redemption
andClaim
. The first one is basically a join table betweenUser
andVoucher
(it stores that a certain user redeemed a certain voucher at a given time). The second one is a (polymorphic) join table betweenRedemption
and so calledClaimables
, where the latter ones can be tutorials or talks. A claim describes what was taken over ("claimed") in the act of redeeming a voucher. In order to understand things it is probably best to play around a little in the GUI (with two users, one who is creating vouchers and one who is redeeming them) and observe what happens in the database. There are four different kinds of vouchers, hence there should be a lot to play around with. Depending on what kind of voucher that is redeemed, notifications in MaMpf and by email are issued:For each kind of voucher, notifications in MaMpf are created for the teacher and editors of the lecture. Additionally,
Note that redemptions only work additively: E.g. you can only take over tutorials, not resign from ones you are already a tutor of; similarly for the other kinds of vouchers. This is deliberate and by design: If you want to resign from a tutorial as a tutor you should contact a lecture editor. The same goes for the other kinds of status upgrades provided by vouchers.
I wrote unit tests for the vouchers model, the voucher processor and some security relevant routes in the vouchers controller. I have not yet written unit tests for some newly defined methods in the lecture model.