Skip to content

Conversation

@sudip-khanal
Copy link
Contributor

Changes

  • Add alert subscription model
  • Add alert Subscription API

Checklist

Things that should succeed before merging.

  • Updated/ran unit tests
  • Updated CHANGELOG.md

Release

If there is a version update, make sure to tag the repository with the latest version.

@sudip-khanal sudip-khanal changed the title feat(notifications): add alert subscription api Add alert subscription API Nov 30, 2025
@sudip-khanal sudip-khanal force-pushed the feat/add-alert-subscription-api branch 2 times, most recently from bc2af82 to 2b2a505 Compare December 3, 2025 16:42
@sudip-khanal sudip-khanal force-pushed the feat/add-alert-subscription-api branch from 2b2a505 to 9916905 Compare December 11, 2025 04:12
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
id = int
id: int

verbose_name_plural = _("Alert Subscriptions")

def __str__(self):
return f"Alert subscription for {self.user}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return f"Alert subscription for {self.user}"
return f"Alert subscription for {self.user.full_name}"


class HazardTypeSerializer(ModelSerializer):

type_display = serializers.CharField(source="get_alert_type_display", read_only=True)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type_display = serializers.CharField(source="get_alert_type_display", read_only=True)
type_display = serializers.CharField(source="get_type_display", read_only=True)

class AlertSubscriptionAdmin(admin.ModelAdmin):
list_select_related = True
list_display = ("user", "created_at")
autocomplete_fields = ("user",)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
autocomplete_fields = ("user",)
autocomplete_fields = ("user","regions", "countries", "hazard_types")

Comment on lines 119 to 123
viewsets.GenericViewSet,
mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
mixins.UpdateModelMixin,
Copy link
Member

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.

Suggested change
viewsets.GenericViewSet,
mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
mixins.UpdateModelMixin,
viewsets.ModelVewset,

self.user1 = UserFactory.create(email="testuser1@com")
self.user2 = UserFactory.create(email="testuser2@com")

self.region = RegionFactory.create(name=2)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self.region = RegionFactory.create(name=2)
self.region = RegionFactory.create(name=RegionName.ASIA_PACIFIC)

@sudip-khanal sudip-khanal force-pushed the feat/add-alert-subscription-api branch from bd47752 to b5abcec Compare December 12, 2025 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants