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

Feat/ownership requests #740

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Feat/ownership requests #740

wants to merge 10 commits into from

Conversation

gabeweng
Copy link

Make Ownership Requests feature with new model OwnershipRequest.

@gabeweng gabeweng requested a review from rm03 October 15, 2024 18:45
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.

Off to a great start! Left some comments; feel free to reply/reach out with any questions. Please also add some test cases when you get a chance 🙂

"person__username",
"person__email",
"club__name",
"club__pk",
Copy link
Member

Choose a reason for hiding this comment

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

club_pk might not be as useful as a search field

@@ -0,0 +1,41 @@
# Generated by Django 5.0.4 on 2024-10-06 05:12
Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating a merge file, would recommend deleting this, merging the latest changes from master, and remaking the migration file. After doing this, you might have to fake the migration locally in order to reach a consistent state.

@@ -1122,6 +1122,54 @@ class Meta:
unique_together = (("person", "club"),)


class OwnershipRequest(models.Model):
"""
Used when users request ownership from the owner
Copy link
Member

Choose a reason for hiding this comment

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

nit: would suggest saying something like "Represents a user's request to take ownership of a club"

Comment on lines 1130 to 1131
person = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
club = models.ForeignKey(Club, on_delete=models.CASCADE)
Copy link
Member

Choose a reason for hiding this comment

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

In general, it's good practice to define a related_name for foreign key fields. Also nit: would suggest renaming person field to something like requester

person = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
club = models.ForeignKey(Club, on_delete=models.CASCADE)

withdrew = models.BooleanField(default=False)
Copy link
Member

Choose a reason for hiding this comment

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

nit: withdrawn

)


class OwnershipRequestOwnerViewSet(XLSXFormatterMixin, viewsets.ModelViewSet):
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need the XLSXFormatterMixin here? Don't foresee there being enough ownership requests for them to be exported to CSV

return Response({"success": True})


class OwnershipRequestSuperuserAPIView(generics.ListAPIView):
Copy link
Member

Choose a reason for hiding this comment

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

I'm in favor of consolidating this view into the previous one and renaming it OwnershipRequestManagementViewSet. You should then be able to create a separate route under this viewset to achieve the same functionality. @aviupadhyayula lmk what you think about this

Copy link
Member

Choose a reason for hiding this comment

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

Yup, agreed.

@@ -0,0 +1,17 @@
<!-- TYPES:
Copy link
Member

Choose a reason for hiding this comment

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

nit: ownership_request.html, and rename request.html to membership_request.html

{% extends 'emails/base.html' %}

{% block content %}
<h2>Ownership Request from <b>{{ full_name }}</b> for <b>{{ club_name }}</b></h2>
Copy link
Member

Choose a reason for hiding this comment

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

nit: Request for ownership for club_name from full_name


{% block content %}
<h2>Ownership Request from <b>{{ full_name }}</b> for <b>{{ club_name }}</b></h2>
<p style="font-size: 1.2em"><b>{{ full_name }}</b> sent an ownership request to join <b>{{ club_name }}</b> through the Penn
Copy link
Member

Choose a reason for hiding this comment

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

nit: ...has submitted a request for ownership of club_name...

Copy link
Member

@aviupadhyayula aviupadhyayula 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 the PR, this looks like a great start! Rohan was (very) thorough, not much to add. One last nit: consider updating the PR's title and description to be a little more descriptive. (Take a look at past PRs for examples.) It's a small detail, but when you're reviewing code years in the future, it's great to understand what the author was thinking.

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 57.52212% with 48 lines in your changes missing coverage. Please review.

Project coverage is 71.56%. Comparing base (715ba15) to head (917c1fc).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
backend/clubs/views.py 40.90% 26 Missing ⚠️
backend/clubs/models.py 55.55% 8 Missing ⚠️
backend/clubs/permissions.py 36.36% 7 Missing ⚠️
backend/clubs/serializers.py 84.61% 4 Missing ⚠️
backend/clubs/admin.py 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #740      +/-   ##
==========================================
- Coverage   71.80%   71.56%   -0.24%     
==========================================
  Files          31       31              
  Lines        6901     7013     +112     
==========================================
+ Hits         4955     5019      +64     
- Misses       1946     1994      +48     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants