Status sends "reblogged" signal on object creation if the object is a reblog, and "posted" otherwise

status-serialisers
Marnanel Thurman 2020-10-24 23:27:02 +01:00
rodzic 32e2e145af
commit fec67697d8
2 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -248,7 +248,11 @@ class Status(PolymorphicModel):
super().save(*args, **kwargs)
if send_signal and newly_made:
trilby_signals.posted.send(sender=self)
if self.reblog_of is None:
trilby_signals.posted.send(sender=self)
else:
trilby_signals.reblogged.send(sender=self)
def __str__(self):
return '[Status %s: %s]' % (

Wyświetl plik

@ -21,7 +21,6 @@ from django.conf import settings
import kepi.trilby_api.models as trilby_models
import kepi.trilby_api.utils as trilby_utils
from .serializers import *
import kepi.trilby_api.signals as kepi_signals
from rest_framework import generics, response, mixins
from rest_framework.permissions import IsAuthenticated, \
IsAuthenticatedOrReadOnly
@ -173,12 +172,12 @@ class Reblog(DoSomethingWithStatus):
)
with transaction.atomic():
new_status.save()
new_status.save(
send_signal = True,
)
logger.info(' -- created a reblog')
kepi_signals.reblogged.send(sender=new_status)
return new_status
class Unreblog(DoSomethingWithStatus):