Notification emails #80
@ -8,3 +8,5 @@ class Verb:
|
|||||||
COMMENTED = 'commented'
|
COMMENTED = 'commented'
|
||||||
REQUESTED_CHANGES = 'requested changes'
|
REQUESTED_CHANGES = 'requested changes'
|
||||||
REQUESTED_REVIEW = 'requested review'
|
REQUESTED_REVIEW = 'requested review'
|
||||||
|
|
||||||
|
RATED_EXTENSION = 'rated extension'
|
||||||
|
@ -7,3 +7,6 @@ class RatingsConfig(AppConfig):
|
|||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
import ratings.signals # noqa: F401
|
import ratings.signals # noqa: F401
|
||||||
|
from actstream import registry
|
||||||
|
|
||||||
|
registry.register(self.get_model('Rating'))
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
from actstream import action
|
||||||
from django.db.models.signals import pre_save, post_save
|
from django.db.models.signals import pre_save, post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from constants.activity import Verb
|
||||||
from ratings.models import Rating
|
from ratings.models import Rating
|
||||||
|
|
||||||
|
|
||||||
@ -17,3 +19,24 @@ def _update_rating_counters(sender, instance, *args, **kwargs):
|
|||||||
|
|
||||||
version = instance.version
|
version = instance.version
|
||||||
version.recalculate_average_score()
|
version.recalculate_average_score()
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=Rating)
|
||||||
|
def create_action_from_rating(
|
||||||
|
sender: object,
|
||||||
|
instance: Rating,
|
||||||
|
created: bool,
|
||||||
|
raw: bool,
|
||||||
|
**kwargs: object,
|
||||||
|
) -> None:
|
||||||
|
if raw:
|
||||||
|
return
|
||||||
|
if not created:
|
||||||
|
return
|
||||||
|
|
||||||
|
action.send(
|
||||||
|
instance.user,
|
||||||
|
verb=Verb.RATED_EXTENSION,
|
||||||
|
action_object=instance,
|
||||||
|
target=instance.extension,
|
||||||
|
)
|
||||||
|
@ -39,7 +39,15 @@ def update_user(
|
|||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Action)
|
@receiver(post_save, sender=Action)
|
||||||
def create_notification(sender: object, instance: Action, created: bool, **kwargs: object) -> None:
|
def create_notification(
|
||||||
|
sender: object,
|
||||||
|
instance: Action,
|
||||||
|
created: bool,
|
||||||
|
raw: bool,
|
||||||
|
**kwargs: object,
|
||||||
|
) -> None:
|
||||||
|
if raw:
|
||||||
|
return
|
||||||
if not created:
|
if not created:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user