Example #1
0
    def save(self):
        subscription = self.cleaned_data['subscription']
        subscription.active = False
        subscription.save()

        context = {'subscription': subscription}
        # refactor to send_noreply_mail
        send_noreply_mail(
            ugettext(u'Unsubscribe from Wolne Lektury\'s newsletter.'),
            render_to_string('newsletter/unsubscribe_email.html', context),
            [subscription.email], fail_silently=True)
Example #2
0
    def save(self, request):
        super(PublishingSuggestForm, self).save()
        contact = self.cleaned_data['contact']
        suggestion_text = self.cleaned_data['books'].strip(', \n\r')

        books = suggestion_text if self.cleaned_data['ebook'] else ''
        audiobooks = suggestion_text if self.cleaned_data['audiobook'] else ''

        suggestion = PublishingSuggestion(
            contact=contact, books=books,
            audiobooks=audiobooks, ip=request.META['REMOTE_ADDR'])
        if request.user.is_authenticated():
            suggestion.user = request.user
        suggestion.save()

        if not suggestion.is_spam():
            mail_managers(u'Konsultacja planu wydawniczego na WolneLektury.pl', u'''\
    Zgłoszono nową sugestię nt. planu wydawniczego w serwisie WolneLektury.pl.
    %(url)s

    Użytkownik: %(user)s
    Kontakt: %(contact)s

    Książki:
    %(books)s

    Audiobooki:
    %(audiobooks)s''' % {
                'url': request.build_absolute_uri(reverse('admin:suggest_suggestion_change', args=[suggestion.id])),
                'user': str(request.user) if request.user.is_authenticated() else '',
                'contact': contact,
                'books': books,
                'audiobooks': audiobooks,
            }, fail_silently=True)

            try:
                validate_email(contact)
            except ValidationError:
                pass
            else:
                send_noreply_mail(
                    ugettext(u'Thank you for your suggestion.'),
                    ugettext(u"""\
Thank you for your comment on WolneLektury.pl.
The suggestion has been referred to the project coordinator."""),
                    [contact], fail_silently=True)
Example #3
0
 def save(self):
     try:
         # multiple inheritance mode
         super(NewsletterForm, self).save()
     except AttributeError:
         pass
     if not self.cleaned_data.get('agree_newsletter'):
         return
     email = self.cleaned_data[self.email_field]
     try:
         validate_email(email)
     except ValidationError:
         pass
     else:
         subscription, created = Subscription.objects.get_or_create(email=email, defaults={'active': False})
         send_noreply_mail(
             ugettext(u'Confirm your subscription to Wolne Lektury newsletter'),
             render_to_string('newsletter/subscribe_email.html', {'subscription': subscription}), [email])
Example #4
0
    def save(self, request):
        super(SuggestForm, self).save()
        contact = self.cleaned_data['contact']
        description = self.cleaned_data['description']

        suggestion = Suggestion(contact=contact, description=description, ip=request.META['REMOTE_ADDR'])
        if request.user.is_authenticated():
            suggestion.user = request.user
        suggestion.save()

        mail_managers(u'Nowa sugestia na stronie WolneLektury.pl', u'''\
Zgłoszono nową sugestię w serwisie WolneLektury.pl.
http://%(site)s%(url)s

Użytkownik: %(user)s
Kontakt: %(contact)s

%(description)s''' % {
            'site': Site.objects.get_current().domain,
            'url': reverse('admin:suggest_suggestion_change', args=[suggestion.id]),
            'user': str(request.user) if request.user.is_authenticated() else '',
            'contact': contact,
            'description': description,
            }, fail_silently=True)

        try:
            validate_email(contact)
        except ValidationError:
            pass
        else:
            send_noreply_mail(
                ugettext(u'Thank you for your suggestion.'),
                ugettext(u"""\
Thank you for your comment on WolneLektury.pl.
The suggestion has been referred to the project coordinator."""),
                [contact], fail_silently=True)
Example #5
0
    def save(self, request):
        super(SuggestForm, self).save()
        contact = self.cleaned_data['contact']
        description = self.cleaned_data['description']

        suggestion = Suggestion(contact=contact, description=description, ip=request.META['REMOTE_ADDR'])
        if request.user.is_authenticated():
            suggestion.user = request.user
        suggestion.save()

        mail_managers(u'Nowa sugestia na stronie WolneLektury.pl', u'''\
Zgłoszono nową sugestię w serwisie WolneLektury.pl.
http://%(site)s%(url)s

Użytkownik: %(user)s
Kontakt: %(contact)s

%(description)s''' % {
            'site': Site.objects.get_current().domain,
            'url': reverse('admin:suggest_suggestion_change', args=[suggestion.id]),
            'user': str(request.user) if request.user.is_authenticated() else '',
            'contact': contact,
            'description': description,
            }, fail_silently=True)

        try:
            validate_email(contact)
        except ValidationError:
            pass
        else:
            send_noreply_mail(
                ugettext(u'Thank you for your suggestion.'),
                ugettext(u"""\
Thank you for your comment on WolneLektury.pl.
The suggestion has been referred to the project coordinator."""),
                [contact], fail_silently=True)