-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add further checks for invalid code to workshop request forms #2553
Add further checks for invalid code to workshop request forms #2553
Conversation
@sheraaronhurt @Talishask I want to check this with you: What is your usual workflow when a member has no workshops remaining but wants to request another workshop? How do you update AMY to represent this? Do you treat it as a paid COW separate from the membership? Edit: after reading through the memberships page, I understand that members contact us to purchase additional workshops. Where do we track this extra allowance in AMY (if at all)? |
@elichad thanks for checking. While this is a rare occurrence, yes they will contact us and we give them additional workshops at a discounted rate. In AMY it would be tracked by the discounted workshops section. @Talishask feel free to chime in :) |
So as I understand it, we agree on extra workshops with the member, but there's nothing in AMY that indicates 'this member is allowed X more workshops than the original contract (and should be allowed to submit X further requests).' We just remember that they have extras when we're processing the requests that come through with their code. Looking at the code, the 'discounted workshops' field is actually just counting all the Events connected with the membership, and subtracting the original allowance. If that's how things work, then those members won't actually be able to submit requests if they've used their original allowance, because the form will see '0 workshops remaining' in AMY and block the submission. To solve that, I think we need to add an 'additional workshops' number field to the membership, in the same manner as the 'additional instructor training seats' that we have at the moment. That way, when a member buys an additional 2 workshops, we can edit their membership to record that, and then they will be able to submit 2 more workshop requests after that. Does that make sense? |
Great questions. Member Workshops Given that members typically submit requests before they are invoiced for additional workshops, I would recommend we have a warning internally but do not block any submissions due to '0 workshops remaining. Discounted Workshops Field Alacarte Workshops |
@Talishask Thanks for this information, I'll schedule a short call with you to talk through a couple of follow-up questions I have |
From conversation with @Talishask:
|
a041201
to
364a923
Compare
@pbanaszkiewicz this is now ready for review! |
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.
Looks good, I left some suggestion but nothing too important.
|
||
@register.simple_tag | ||
def membership_description(membership: Membership): | ||
if not isinstance(membership, Membership): |
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.
Is it expected for this tag to work on objects other than Membership?
If it's expected then the type hinting is not correct. Otherwise I'd remove this condition.
|
||
|
||
@register.simple_tag | ||
def membership_description(membership: Membership): |
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.
My suggestion is to turn this tag into a Django template. There's a lot of template generation going on compared to "difficult template logic".
Here, the logic that may be difficult or "ugly" to achieve in the Django template is the calculation of alert type. I suggest to use a template tag to determine if this message is just informational or a warning.
f'<a href="{membership.get_absolute_url()}">{membership}</a>.' | ||
"<br>" | ||
f"This membership has <strong>{workshops_remaining}</strong> " | ||
f'workshop{"s" if workshops_remaining !=1 else ""} remaining.' |
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.
In the Django template you can use pluralize
template filter to achieve the plural form of "workshop".
info += "<br>This membership is <strong>not currently active</strong>." | ||
info += "</div>" | ||
|
||
return mark_safe(info) |
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.
After reading https://docs.djangoproject.com/en/3.2/ref/utils/#django.utils.html.format_html I think we should review our use of mark_safe
, as format_html
may be more appropriate.
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, I agree. Created #2574
amy/extrequests/utils.py
Outdated
@@ -72,3 +64,15 @@ def member_code_valid_training( | |||
raise MemberCodeValidationError("Membership has no training seats remaining.") | |||
|
|||
return True | |||
|
|||
|
|||
def get_membership_from_code_if_exists(code: str) -> Membership | None: |
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.
Naming suggestion: get_membership_by_code_or_none
, as or_none
automatically suggest what is returned if membership is not found.
On the other hand, my suggestion may be flawed by suggesting fetching the membership "by code or by None".
Thanks Piotr! I addressed all your comments so I'll go ahead and merge. |
Depends on #2552 . Closes #2533. Updated 08 Nov.
This PR:
checks that membership has workshops remaining