Notification emails #80
@ -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
|
||||||
|
@ -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,11 +397,17 @@ class DraftExtensionView(
|
|||||||
extension_form.save()
|
extension_form.save()
|
||||||
add_preview_formset.save()
|
add_preview_formset.save()
|
||||||
form.save()
|
form.save()
|
||||||
action.send(
|
# setup initial followers
|
||||||
self.request.user,
|
moderators = Group.objects.get(name='moderators').user_set.all()
|
||||||
verb='submitted for review', # FIXME map the type into a "registered" verb
|
audience = list(moderators) + list(extension_form.instance.authors.all())
|
||||||
target=extension_form.instance,
|
for recipient in audience:
|
||||||
)
|
follow(recipient, extension_form.instance, send_action=False)
|
||||||
|
if 'submit_draft' in self.request.POST:
|
||||||
|
action.send(
|
||||||
|
self.request.user,
|
||||||
|
verb='submitted for review', # FIXME map the type into a "registered" verb
|
||||||
|
target=extension_form.instance,
|
||||||
|
)
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
except forms.ValidationError as e:
|
except forms.ValidationError as e:
|
||||||
if 'hash' in e.error_dict:
|
if 'hash' in e.error_dict:
|
||||||
|
Loading…
Reference in New Issue
Block a user