Skip to content
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

Conversation

elichad
Copy link
Contributor

@elichad elichad commented Oct 23, 2023

Depends on #2552 . Closes #2533. Updated 08 Nov.

This PR:

@elichad elichad added this to the v4.3 milestone Oct 23, 2023
@elichad elichad self-assigned this Oct 23, 2023
@elichad
Copy link
Contributor Author

elichad commented Oct 24, 2023

@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?
I'm trying to understand if any nuance is necessary when validating the code and discovering there are no workshops left, or if it's okay to just block submission in that case.

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 elichad marked this pull request as draft October 24, 2023 09:08
@sheraaronhurt
Copy link
Contributor

@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 :)

@elichad
Copy link
Contributor Author

elichad commented Oct 25, 2023

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?

@Talishask
Copy link

Great questions.

Member Workshops
When members need additional workshops they typically submit a workshop request form before contacting us and then we discuss this with them. My current process is to update the number of allowed workshops once the member is invoiced. In most cases Danielle is already working with them. The downside of updating the allowed workshops field is that we lose data on added workshops, so this is not optimal. We used to have a 'Members included in membership" and an 'Additional workshops' field but we lost the second field with some updates last year. I agree and would be excited to get that field back.

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
The current discounted workshops field assumes that any COWs above the allowed workshops are discounted. That is not correct. Typically these are workshops that are either above the limit or not yet paid. It would be more helpful for workshop allowances to be structured just the same as IT seats with "allowed", "used", "remaining".

Alacarte Workshops
Alacarte workshops are a little bit different. Our current workflow is to create the membership (so that we can tie the event to it because planning can start while we are working on paperwork), but wait to add the allowed workshop until the invoicing happens. Essentially we are waiting to confirm payment before adding the allowed workshop. We changed this order for a la carte workshops because they are easier to fall through the cracks and not get invoiced. I have a report that lets me see workshops where the allowed is zero then I check to see if we received payment or not and update the allowed workshops once we invoice it. It might be a good idea to have a conversation with the TT about some of these things to help me find better solutions and standardize more with our regular workflows.

@elichad
Copy link
Contributor Author

elichad commented Oct 30, 2023

@Talishask Thanks for this information, I'll schedule a short call with you to talk through a couple of follow-up questions I have

@elichad
Copy link
Contributor Author

elichad commented Nov 1, 2023

From conversation with @Talishask:

  • remove the check for workshops remaining. We often do invoicing for extra workshops alongside the planning process, so we need to be able to get workshops into the database before
  • instead, add a warning message on the WR details page if the workshop would exceed the member's allocation
  • add the 'additional workshops' field back into the Membership model, and display it similarly to how we do IT seats (best to do this as part of Allow additional inperson/online workshops for each membership #2391)

@elichad elichad force-pushed the feature/2533-Member-codes-Add-further-checks-for-invalid-code-to-all-workshop-request-forms branch from a041201 to 364a923 Compare November 7, 2023 11:10
@elichad elichad marked this pull request as ready for review November 8, 2023 11:34
@elichad
Copy link
Contributor Author

elichad commented Nov 8, 2023

@pbanaszkiewicz this is now ready for review!

Copy link
Contributor

@pbanaszkiewicz pbanaszkiewicz left a 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):
Copy link
Contributor

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):
Copy link
Contributor

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.'
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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:
Copy link
Contributor

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".

@elichad
Copy link
Contributor Author

elichad commented Nov 16, 2023

Thanks Piotr! I addressed all your comments so I'll go ahead and merge.

@elichad elichad merged commit b962bd5 into feature/member-codes Nov 16, 2023
2 checks passed
@elichad elichad deleted the feature/2533-Member-codes-Add-further-checks-for-invalid-code-to-all-workshop-request-forms branch November 16, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants