kopia lustrzana https://gitlab.com/marnanel/chapeau
Status sends "reblogged" signal on object creation if the object is a reblog, and "posted" otherwise
rodzic
32e2e145af
commit
fec67697d8
|
@ -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]' % (
|
||||
|
|
|
@ -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):
|
||||
|
|
Ładowanie…
Reference in New Issue