-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
self.user.user_permissions.add( | ||
Permission.objects.get(codename="see_pending_clubs") | ||
) | ||
request = self.factory.get(reverse("clubs-detail", args=[self.club.code])) |
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 there a reason for not using client
like in the other test files?
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.
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() |
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 this intentional?
self.club.name = "Current Cycle Approved Version" | ||
self.club.approved = True | ||
self.club.approved_on = approved_date | ||
self.club.save() |
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.
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
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.
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) |
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.
What's the use case for bypass=True
? I don't think clubs should be allowed to show an unapproved version at all
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.