-
Notifications
You must be signed in to change notification settings - Fork 7
Add alert subscription API #2600
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
base: project/alert-system-workflow
Are you sure you want to change the base?
Add alert subscription API #2600
Conversation
bc2af82 to
2b2a505
Compare
2b2a505 to
9916905
Compare
notifications/models.py
Outdated
| created_at = models.DateTimeField(auto_now_add=True, verbose_name=_("Created At")) | ||
| updated_at = models.DateTimeField(auto_now=True, verbose_name=_("Updated At")) | ||
| # Typing | ||
| id = int |
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.
| id = int | |
| id: int |
notifications/models.py
Outdated
| verbose_name_plural = _("Alert Subscriptions") | ||
|
|
||
| def __str__(self): | ||
| return f"Alert subscription for {self.user}" |
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.
| return f"Alert subscription for {self.user}" | |
| return f"Alert subscription for {self.user.full_name}" |
notifications/serializers.py
Outdated
|
|
||
| class HazardTypeSerializer(ModelSerializer): | ||
|
|
||
| type_display = serializers.CharField(source="get_alert_type_display", read_only=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.
| type_display = serializers.CharField(source="get_alert_type_display", read_only=True) | |
| type_display = serializers.CharField(source="get_type_display", read_only=True) |
notifications/admin.py
Outdated
| class AlertSubscriptionAdmin(admin.ModelAdmin): | ||
| list_select_related = True | ||
| list_display = ("user", "created_at") | ||
| autocomplete_fields = ("user",) |
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.
| autocomplete_fields = ("user",) | |
| autocomplete_fields = ("user","regions", "countries", "hazard_types") |
notifications/drf_views.py
Outdated
| viewsets.GenericViewSet, | ||
| mixins.ListModelMixin, | ||
| mixins.RetrieveModelMixin, | ||
| mixins.CreateModelMixin, | ||
| mixins.UpdateModelMixin, |
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 might need to delete the subscriptions.
| viewsets.GenericViewSet, | |
| mixins.ListModelMixin, | |
| mixins.RetrieveModelMixin, | |
| mixins.CreateModelMixin, | |
| mixins.UpdateModelMixin, | |
| viewsets.ModelVewset, |
notifications/tests.py
Outdated
| self.user1 = UserFactory.create(email="testuser1@com") | ||
| self.user2 = UserFactory.create(email="testuser2@com") | ||
|
|
||
| self.region = RegionFactory.create(name=2) |
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.
| self.region = RegionFactory.create(name=2) | |
| self.region = RegionFactory.create(name=RegionName.ASIA_PACIFIC) |
bd47752 to
b5abcec
Compare
Changes
Checklist
Things that should succeed before merging.
Release
If there is a version update, make sure to tag the repository with the latest version.