Use enums in more models

This commit is contained in:
Mouse Reeve 2022-07-04 20:26:38 -07:00
parent aeefd5a3e9
commit 9948dd2356
4 changed files with 12 additions and 10 deletions

View file

@ -6,12 +6,12 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0151_auto_20220705_0049'),
("bookwyrm", "0151_auto_20220705_0049"),
]
operations = [
migrations.RemoveConstraint(
model_name='notification',
name='notification_type_valid',
model_name="notification",
name="notification_type_valid",
),
]

View file

@ -69,7 +69,7 @@ def automod_task():
with transaction.atomic():
for admin in admins:
notification, _ = notification_model.objects.get_or_create(
user=admin, notification_type="REPORT", unread=True
user=admin, notification_type=notification_model.REPORT, unread=True
)
notification.related_repors.add(reports)

View file

@ -166,7 +166,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
user=list_owner,
related_user=self.user,
related_list_item=self,
notification_type="ADD",
notification_type=model.ADD,
)
if self.book_list.group:
@ -176,7 +176,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
user=membership.user,
related_user=self.user,
related_list_item=self,
notification_type="ADD",
notification_type=model.ADD,
)
def raise_not_deletable(self, viewer):

View file

@ -149,10 +149,12 @@ class UserFollowRequest(ActivitypubMixin, UserRelationship):
self.accept()
model = apps.get_model("bookwyrm.Notification", require_ready=True)
notification_type = "FOLLOW_REQUEST" if manually_approves else "FOLLOW"
model.objects.create(
user=self.user_object,
related_user=self.user_subject,
notification_type = (
model.FOLLOW_REQUEST if manually_approves else model.FOLLOW
)
model.notify(
self.user_object,
self.user_subject,
notification_type=notification_type,
)