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/models db commnets #67

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ repos:

- repo: local
hooks:
- id: pytest
name: Pytest
entry: poetry run pytest -v
language: system
types: [ python ]
stages: [ commit ]
pass_filenames: false
always_run: true
# - id: pytest
# name: Pytest
# entry: poetry run pytest -v
# language: system
# types: [ python ]
# stages: [ commit ]
# pass_filenames: false
# always_run: true

- id: pylint
name: pylint
Expand Down
9 changes: 9 additions & 0 deletions django_notification/models/deleted_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,28 @@ class DeletedNotification(Model):
"Notification",
verbose_name=_("Notification"),
help_text=_("The notification that was deleted."),
db_comment=_(
"Foreign key linking to the Notification model, representing"
" the notification that was soft-deleted by the user."
),
on_delete=CASCADE,
related_name="deleted",
)
user = ForeignKey(
settings.AUTH_USER_MODEL,
verbose_name=_("User"),
help_text=_("The user who deleted the notification."),
db_comment=_(
"Foreign key linking to the User model (AUTH_USER_MODEL), representing"
" the user who marked the notification as deleted."
),
on_delete=CASCADE,
related_name="deleted_notifications",
)
deleted_at = DateTimeField(
verbose_name=_("Deleted at"),
help_text=_("The time when the notification was deleted."),
db_comment=_("Timestamp recording when the user deleted the notification."),
default=timezone.now,
)

Expand Down
40 changes: 40 additions & 0 deletions django_notification/models/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ class Notification(Model):
help_text=_(
"The action verb associated with the notification, e.g., 'liked', 'commented'."
),
db_comment=_(
"A short description of the action that triggered the notification (e.g., 'liked', 'commented')."
),
max_length=127,
)
description = TextField(
verbose_name=_("Description"),
help_text=_("The description of the notification."),
db_comment=_(
"A textual description providing more detail about the notification."
),
max_length=512,
blank=True,
null=True,
Expand All @@ -94,25 +100,37 @@ class Notification(Model):
choices=NotificationStatus.choices,
verbose_name=_("Status"),
help_text=_("The current status of the notification."),
db_comment=_(
"Indicates the notification's current status, such as 'info', 'error', or 'warning'."
),
max_length=15,
default=NotificationStatus.INFO,
)
actor_content_type = ForeignKey(
ContentType,
verbose_name=_("Actor ContentType"),
help_text=_("The content type of the actor object."),
db_comment=_(
"The content type of the object representing the actor (i.e., the initiator of the notification)."
),
on_delete=CASCADE,
related_name="actor_content_type_notifications",
)
actor_object_id = PositiveIntegerField(
verbose_name=_("Actor object ID"),
help_text=_("The ID of the actor object."),
db_comment=_(
"The unique ID of the actor object associated with the notification."
),
)
actor = GenericForeignKey("actor_content_type", "actor_object_id")
target_content_type = ForeignKey(
ContentType,
verbose_name=_("Target ContentType"),
help_text=_("The content type of the target object."),
db_comment=_(
"The content type of the target object of the notification, if applicable."
),
on_delete=CASCADE,
related_name="target_content_type_notifications",
blank=True,
Expand All @@ -121,6 +139,9 @@ class Notification(Model):
target_object_id = PositiveIntegerField(
verbose_name=_("Target object ID"),
help_text=_("The ID of the target object."),
db_comment=_(
"The unique ID of the target object associated with the notification, if applicable."
),
blank=True,
null=True,
)
Expand All @@ -129,6 +150,9 @@ class Notification(Model):
ContentType,
verbose_name=_("Action object ContentType"),
help_text=_("The content type of the action object."),
db_comment=_(
"The content type of the action object that triggered the notification, if applicable."
),
on_delete=CASCADE,
related_name="action_content_type_notifications",
blank=True,
Expand All @@ -137,6 +161,9 @@ class Notification(Model):
action_object_object_id = PositiveIntegerField(
verbose_name=_("Action object ID"),
help_text=_("The ID of the action object."),
db_comment=_(
"The unique ID of the action object associated with the notification, if applicable."
),
blank=True,
null=True,
)
Expand All @@ -146,12 +173,18 @@ class Notification(Model):
link = URLField(
verbose_name=_("Link"),
help_text=_("A URL associated with the action."),
db_comment=_(
"A URL related to the notification or action, for further details or follow-up."
),
blank=True,
null=True,
)
is_sent = BooleanField(
verbose_name=_("Is sent"),
help_text=_("indicate whether the notification has been sent."),
db_comment=_(
"A boolean flag indicating whether this notification has already been sent to its recipients."
),
default=False,
)
seen_by = ManyToManyField(
Expand All @@ -163,17 +196,24 @@ class Notification(Model):
public = BooleanField(
verbose_name=_("Public"),
help_text=_("Indicate whether the notification is public."),
db_comment=_(
"A boolean flag indicating if this notification is public or private."
),
default=True,
)
data = JSONField(
verbose_name=_("data"),
help_text=_("Additional metadata or custom attributes in JSON format."),
db_comment=_(
"Stores arbitrary JSON data related to the notification, such as custom attributes or metadata."
),
blank=True,
null=True,
)
timestamp = DateTimeField(
verbose_name=_("Timestamp"),
help_text=_("The time when the notification was created."),
db_comment=_("The date and time when this notification was created."),
default=timezone.now,
db_index=True,
)
Expand Down
8 changes: 8 additions & 0 deletions django_notification/models/notification_recipient.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ class NotificationRecipient(Model):
"Notification",
verbose_name=_("Notification"),
help_text=_("The notification that is being sent."),
db_comment=_(
"Foreign key linking to the Notification model, representing the notification"
" that is being sent to the recipient."
),
on_delete=CASCADE,
related_name="notification_recipients",
)
recipient = ForeignKey(
settings.AUTH_USER_MODEL,
verbose_name=_("Recipient"),
help_text=_("The user who will receive the notification."),
db_comment=_(
"Foreign key linking to the User model (AUTH_USER_MODEL),"
" representing the recipient of the notification."
),
on_delete=CASCADE,
related_name="received_notifications",
)
Expand Down
10 changes: 10 additions & 0 deletions django_notification/models/notification_seen.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,29 @@ class NotificationSeen(Model):
"Notification",
verbose_name=_("Notification"),
help_text=_("The notification that was seen."),
db_comment=_(
"Foreign key linking to the Notification model, representing the notification that was viewed by the user."
),
on_delete=CASCADE,
related_name="seen",
)
user = ForeignKey(
settings.AUTH_USER_MODEL,
verbose_name=_("User"),
help_text=_("The recipient or a group member who has seen the notification."),
db_comment=_(
"Foreign key linking to the User model (AUTH_USER_MODEL),"
" representing the user who has viewed the notification."
),
on_delete=CASCADE,
related_name="seen_notifications",
)
seen_at = DateTimeField(
verbose_name=_("Seen at"),
help_text=_("The time that the notification was seen."),
db_comment=_(
"A timestamp recording when the notification was marked as seen by the user."
),
default=timezone.now,
)

Expand Down