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 backend support for ownership requests #740

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

Conversation

gabeweng
Copy link

@gabeweng gabeweng commented Oct 15, 2024

Implement backend for new Ownership Requests feature and update Membership Request feature.

New:

  • OwnershipRequest model
  • UserMembershipRequestSerializer and OwnershipRequestViewSet to see/create/destroy Ownership Requests for a user
  • Routes for users to manage their own requests under api/requests/ownership
  • OwnershipRequestSerializer and OwnershipRequestManagementViewSet for management (including accept and deny) of Ownership Requests by club admin and site admin
  • Routes for clubs and superusers to manage requests under api/clubs/{club_code}/ownershiprequests
  • Email template for sending out ownership requests

Modified:

  • MembershipRequest model (person renamed to requester, withdrew renamed to withdrawn, related names for MembershipRequest added for requester and club)
  • api/requests/membership used instead of api/requests/ for membership requests

@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 🙂

backend/clubs/admin.py Outdated Show resolved Hide resolved
backend/clubs/migrations/0114_ownershiprequest.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/views.py Outdated Show resolved Hide resolved
backend/clubs/views.py Outdated Show resolved Hide resolved
backend/templates/emails/ownershiprequest.html Outdated Show resolved Hide resolved
backend/templates/emails/ownershiprequest.html Outdated Show resolved Hide resolved
backend/templates/emails/ownershiprequest.html Outdated Show resolved Hide resolved
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 90.90909% with 13 lines in your changes missing coverage. Please review.

Project coverage is 72.60%. Comparing base (b280dc0) to head (ecd4de6).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
backend/clubs/admin.py 66.66% 6 Missing ⚠️
backend/clubs/views.py 93.10% 4 Missing ⚠️
backend/clubs/models.py 91.30% 2 Missing ⚠️
backend/clubs/permissions.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #740      +/-   ##
==========================================
+ Coverage   71.95%   72.60%   +0.64%     
==========================================
  Files          32       32              
  Lines        6953     7055     +102     
==========================================
+ Hits         5003     5122     +119     
+ Misses       1950     1933      -17     

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

@gabeweng gabeweng force-pushed the feat/ownership-requests branch from 8808888 to d5e4b6c Compare November 8, 2024 03:23
@gabeweng gabeweng marked this pull request as ready for review November 10, 2024 17:17
@aviupadhyayula aviupadhyayula changed the title Feat/ownership requests Add backend support for ownership requests Nov 13, 2024
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 resolving the comments from earlier! Left a few more, but mostly looks good to me!

backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/serializers.py Outdated Show resolved Hide resolved
backend/clubs/views.py Outdated Show resolved Hide resolved
backend/tests/clubs/test_views.py Show resolved Hide resolved
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.

Great work Gabe! Rohan did a great job with his review, so not much to add outside of minor comments.

backend/tests/clubs/test_views.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/serializers.py Outdated Show resolved Hide resolved
backend/clubs/views.py Outdated Show resolved Hide resolved
backend/templates/emails/ownership_request.html Outdated Show resolved Hide resolved
backend/templates/emails/ownership_request.html Outdated Show resolved Hide resolved
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.

lgtm aside from a few nits! sorry for taking so long to get to this

@@ -1077,49 +1077,89 @@ def __str__(self):
return "<SearchQuery: {} at {}>".format(self.query, self.created_at)


class MembershipRequest(models.Model):
class Request(models.Model):
Copy link
Member

Choose a reason for hiding this comment

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

nit: something more descriptive like JoinRequest

accept:
Accept an ownership request as a club owner.

old_requests:
Copy link
Member

Choose a reason for hiding this comment

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

nit: make this consistent with the new route

request_object.delete()
return Response({"success": True})

@action(detail=False, methods=["get"], permission_classes=[IsSuperuser])
def all_requests(self, request, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

nit: all

@rm03 rm03 requested a review from aviupadhyayula January 1, 2025 19:16
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.

LGTM! Thanks for fixing up the tests.

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