mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Use enums in more models
This commit is contained in:
parent
aeefd5a3e9
commit
9948dd2356
4 changed files with 12 additions and 10 deletions
|
@ -6,12 +6,12 @@ from django.db import migrations
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('bookwyrm', '0151_auto_20220705_0049'),
|
("bookwyrm", "0151_auto_20220705_0049"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RemoveConstraint(
|
migrations.RemoveConstraint(
|
||||||
model_name='notification',
|
model_name="notification",
|
||||||
name='notification_type_valid',
|
name="notification_type_valid",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -69,7 +69,7 @@ def automod_task():
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
notification, _ = notification_model.objects.get_or_create(
|
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)
|
notification.related_repors.add(reports)
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
|
||||||
user=list_owner,
|
user=list_owner,
|
||||||
related_user=self.user,
|
related_user=self.user,
|
||||||
related_list_item=self,
|
related_list_item=self,
|
||||||
notification_type="ADD",
|
notification_type=model.ADD,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.book_list.group:
|
if self.book_list.group:
|
||||||
|
@ -176,7 +176,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
|
||||||
user=membership.user,
|
user=membership.user,
|
||||||
related_user=self.user,
|
related_user=self.user,
|
||||||
related_list_item=self,
|
related_list_item=self,
|
||||||
notification_type="ADD",
|
notification_type=model.ADD,
|
||||||
)
|
)
|
||||||
|
|
||||||
def raise_not_deletable(self, viewer):
|
def raise_not_deletable(self, viewer):
|
||||||
|
|
|
@ -149,10 +149,12 @@ class UserFollowRequest(ActivitypubMixin, UserRelationship):
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
model = apps.get_model("bookwyrm.Notification", require_ready=True)
|
model = apps.get_model("bookwyrm.Notification", require_ready=True)
|
||||||
notification_type = "FOLLOW_REQUEST" if manually_approves else "FOLLOW"
|
notification_type = (
|
||||||
model.objects.create(
|
model.FOLLOW_REQUEST if manually_approves else model.FOLLOW
|
||||||
user=self.user_object,
|
)
|
||||||
related_user=self.user_subject,
|
model.notify(
|
||||||
|
self.user_object,
|
||||||
|
self.user_subject,
|
||||||
notification_type=notification_type,
|
notification_type=notification_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue