def save(self, request): 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) if email_re.match(contact): send_mail(u'[WolneLektury] ' + 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.""") + u""" -- """ + ugettext(u'''Message sent automatically. Please do not reply.'''), '*****@*****.**', [contact], fail_silently=True)
def save(self, request): 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, ) if email_re.match(contact): send_mail( u"[WolneLektury] " + 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.""" ) + u""" -- """ + ugettext(u"""Message sent automatically. Please do not reply."""), "*****@*****.**", [contact], fail_silently=True, )
def report(request): suggest_form = forms.SuggestForm(request.POST) if suggest_form.is_valid(): contact = suggest_form.cleaned_data['contact'] description = suggest_form.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) if email_re.match(contact): send_mail(u'[WolneLektury] ' + _(u'Thank you for your suggestion.'), _(u"""\ Thank you for your comment on WolneLektury.pl. The suggestion has been referred to the project coordinator.""") + u""" -- """ + _(u'''Message sent automatically. Please do not reply.'''), '*****@*****.**', [contact], fail_silently=True) response_data = {'success': True, 'message': _('Report was sent successfully.')} else: response_data = {'success': False, 'errors': suggest_form.errors} return HttpResponse(LazyEncoder(ensure_ascii=False).encode(response_data))
def save(self, request): 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_mail(u'[WolneLektury] ' + 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.""") + u""" -- """ + ugettext(u'''Message sent automatically. Please do not reply.'''), '*****@*****.**', [contact], fail_silently=True)
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)