-
Notifications
You must be signed in to change notification settings - Fork 256
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
Events API #628 #760
Events API #628 #760
Conversation
Thank you for the pull request!The activist team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Development rooms once you're in. It'd be great to have you! Maintainer checklist
|
✅ Deploy Preview for activist-org ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thanks for the hard work here, @josueemartinezz! As an initial check on all of this, would you want to go through the backend check and send along fixes for all of that? @to-sta and I can then take a look afterwards :) |
Two minor things that I just shared with another contributor that would be helpful for you, @josueemartinezz:
Want to stress that there's no issue on our end with the checks failing! All this is very appreciated, and doing the steps above will just take it all to the next level 🚀 |
backend/entities/views.py
Outdated
@@ -43,6 +43,11 @@ class OrganizationViewSet(viewsets.ModelViewSet[Organization]): | |||
serializer_class = OrganizationSerializer | |||
pagination_class = CustomPagination | |||
throttle_classes = [AnonRateThrottle, UserRateThrottle] | |||
|
|||
def list(self, request: Request, *args: str, **kwagrs: int) -> Response: | |||
queryset = Organization.objects.all() |
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.
The variable queryset
is unused and redundant 😅.
queryset = Event.objects.all()
serializer = self.get_serializer(self.queryset, many=True)
backend/entities/views.py
Outdated
@@ -70,7 +75,7 @@ def destroy(self, request: Request, *args: str, **kwargs: int) -> Response: | |||
instance = get_object_or_404(Organization, pk=kwargs["pk"]) | |||
instance.delete() | |||
data = {"message": f'Organization {kwargs["pk"]} has been deleted successfully'} | |||
return Response(data, status=status.HTTP_204_NO_CONTENT) | |||
return Response(status=status.HTTP_202_ACCEPTED) |
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.
Minor thing here. Accepted is good status for this but we generally use the status.HTTP_201_CREATED
in case we create an instance.
backend/events/models.py
Outdated
@@ -26,11 +26,14 @@ | |||
class Event(CreationDeletionMixin): | |||
id = models.UUIDField(primary_key=True, default=uuid4, editable=False) | |||
name = models.CharField(max_length=255) | |||
tagline = models.CharField(max_length=255, blank=True) | |||
tagline = models.CharField(max_length=255, blank=True, null=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.
In django CharField and TextField are never saved as NULL values, therefore there is no need for null=True.
backend/events/models.py
Outdated
@@ -41,6 +44,8 @@ class Event(CreationDeletionMixin): | |||
event_icon = models.OneToOneField( | |||
"content.Image", on_delete=models.CASCADE, null=True, blank=True | |||
) | |||
creation_date = models.DateTimeField(auto_now_add=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.
creation_date
and deletion_date
are added by the mixin:
class Event(CreationDeletionMixin):
...
backend/entities/views.py
Outdated
@@ -70,7 +75,7 @@ def destroy(self, request: Request, *args: str, **kwargs: int) -> Response: | |||
instance = get_object_or_404(Organization, pk=kwargs["pk"]) | |||
instance.delete() | |||
data = {"message": f'Organization {kwargs["pk"]} has been deleted successfully'} |
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.
The variable data is created but it is not used. You have to add it to the response.
@josueemartinezz Thanks for contribution 😃. I added a few comments. How did you test the API? |
Hi! Thank you so much for your review. I'll get these fixed right away. I tested the API by using Swagger-UI for all the HTTP methods, ensuring bad user input passed the Event model's field validation requirements. If it did, like a user's end_time precedes start_time, I raised exceptions in serializers.py. I tested for foreign key existence, but this again was accounted for by the key checks done by the field type. Please let me know of any testing strategies tips apart from just playing around with inputs on Swagger-UI. |
1. Added (list, create, retrieve, update, partial_update, destroy) HTTP methods 2. Modified serializers to validate non-trivial input from user. Trivial validation is ensured by the model setup. 3. Added missing fields for Event model (according to Figma designs)
1. fixed pre-commit and ruff formatting 2. discarded redundant fields from mixin 3. removed null CharField & TextField 4. fixed request status for Destroy instance. 5. removed unused/redundant variables.
Heyo @josueemartinezz! We have the other priority backend PRs merged and will get to this when we can! Sorry for the wait! Map for events has been taking some major strides, so the feature set is definitely there for when this is brought in 😊 |
Contributor checklist
Description
TESTING
NOTE:
Related issue