Notification emails #80

Merged
Oleg-Komarov merged 31 commits from notifications into main 2024-04-18 16:11:20 +02:00
2 changed files with 13 additions and 23 deletions
Showing only changes of commit ff3a13c1fe - Show all commits

View File

@ -1,7 +1,5 @@
from typing import Union from typing import Union
from actstream.actions import follow
from django.contrib.auth.models import Group
from django.db.models.signals import pre_save, post_save, post_delete from django.db.models.signals import pre_save, post_save, post_delete
from django.dispatch import receiver from django.dispatch import receiver
@ -37,22 +35,6 @@ def _update_search_index(sender, instance, **kw):
pass # TODO: update search index pass # TODO: update search index
@receiver(post_save, sender=extensions.models.Extension)
def setup_initial_followers(
sender: object,
instance: extensions.models.Extension,
created: bool,
**kwargs: object,
) -> None:
if not created:
return
moderators = Group.objects.get(name='moderators').user_set.all()
audience = list(moderators) + list(instance.authors.all())
for recipient in audience:
follow(recipient, instance, send_action=False)
def extension_should_be_listed(extension): def extension_should_be_listed(extension):
return ( return (
extension.latest_version is not None extension.latest_version is not None

View File

@ -1,5 +1,7 @@
"""Contains views allowing developers to manage their add-ons.""" """Contains views allowing developers to manage their add-ons."""
from actstream import action from actstream import action
from actstream.actions import follow
from django.contrib.auth.models import Group
from django import forms from django import forms
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.contrib.messages.views import SuccessMessageMixin from django.contrib.messages.views import SuccessMessageMixin
@ -395,6 +397,12 @@ class DraftExtensionView(
extension_form.save() extension_form.save()
add_preview_formset.save() add_preview_formset.save()
form.save() form.save()
# setup initial followers
moderators = Group.objects.get(name='moderators').user_set.all()
audience = list(moderators) + list(extension_form.instance.authors.all())
for recipient in audience:
follow(recipient, extension_form.instance, send_action=False)
if 'submit_draft' in self.request.POST:
action.send( action.send(
self.request.user, self.request.user,
verb='submitted for review', # FIXME map the type into a "registered" verb verb='submitted for review', # FIXME map the type into a "registered" verb