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

Change club serialization based on approval status #733

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

aviupadhyayula
Copy link
Member

@aviupadhyayula aviupadhyayula commented Oct 4, 2024

Re-hauls serialization to show clubs differently based on their approval status and the current time (whether we're in a renewal period or not). Adds tests to serialization logic and aligns view-related unit tests to this change.

This lets us deprecate the ghost attribute and should simplify the display flow. See this Slack thread for more info.

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.69%. Comparing base (245e557) to head (f7f54c0).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #733      +/-   ##
==========================================
+ Coverage   71.67%   71.69%   +0.02%     
==========================================
  Files          31       31              
  Lines        6855     6860       +5     
==========================================
+ Hits         4913     4918       +5     
  Misses       1942     1942              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

self.user.user_permissions.add(
Permission.objects.get(codename="see_pending_clubs")
)
request = self.factory.get(reverse("clubs-detail", args=[self.club.code]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for not using client like in the other test files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to actually send the request to the API -- we just want to create the request object, and then pass it to the serializer. This lets us test the serializer itself instead of the entire view.

The user_permissions.add pattern was unintentional. Changed to self.user.is_superuser = True instead.


def test_non_privileged_user_during_renewal_period(self):
# Simulate deactivation at the beginning of the renewal period
self.club.save()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

self.club.name = "Current Cycle Approved Version"
self.club.approved = True
self.club.approved_on = approved_date
self.club.save()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there is internal logic in club.save or serializer.to_representation that uses django.utils.timezone.now, we might not need the with clauses since we are explicitly setting club.approved_on

Copy link
Member

@rm03 rm03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this!

Return the previous approved version of a club for users
that should not see unapproved content.
Return appropriate version of club based on user permissions and club status:
- Privileged users see current version (or when bypass=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use case for bypass=True? I don't think clubs should be allowed to show an unapproved version at all

@aviupadhyayula aviupadhyayula changed the title Change how clubs are displayed based on approval status Change club serialization based on approval status Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants