Fix deletion of collections, and users who own said collections, which have votes.
This commit is contained in:
Родитель
d4d7bda9e8
Коммит
9a664e5807
|
@ -493,8 +493,12 @@ class CollectionVote(models.Model):
|
|||
|
||||
@staticmethod
|
||||
def post_save_or_delete(sender, instance, **kwargs):
|
||||
from . import tasks
|
||||
tasks.collection_votes(instance.collection_id, using='default')
|
||||
# There are some issues with cascade deletes, where the
|
||||
# collection disappears before the votes. Make sure the
|
||||
# collection exists before trying to update it in the task.
|
||||
if Collection.objects.filter(id=instance.collection_id).exists():
|
||||
from . import tasks
|
||||
tasks.collection_votes(instance.collection_id, using='default')
|
||||
|
||||
|
||||
models.signals.post_save.connect(CollectionVote.post_save_or_delete,
|
||||
|
|
Загрузка…
Ссылка в новой задаче