X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/9c5d9a4e77a10b4e60d89d3890e49002bd7f3993..e977b7baf9a6e653d6040e9487b7a6cb5fda5fa2:/apps/suggest/views.py diff --git a/apps/suggest/views.py b/apps/suggest/views.py index 5d007f6df..9b3de55d5 100644 --- a/apps/suggest/views.py +++ b/apps/suggest/views.py @@ -2,10 +2,13 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from django.core.mail import send_mail, mail_managers +from django.core.urlresolvers import reverse +from django.core.validators import email_re from django.http import HttpResponse, HttpResponseRedirect +from django.utils.translation import ugettext as _ from django.views.decorators import cache from django.views.decorators.http import require_POST -from django.utils.translation import ugettext as _ from suggest import forms from suggest.models import Suggestion @@ -28,8 +31,32 @@ def report(request): suggestion.user = request.user suggestion.save() + mail_managers(u'Nowa sugestia na stronie WolneLektury.pl', u'''\ +Zgłoszono nową sugestię w serwisie WolneLektury.pl. +%(url)s + +Użytkownik: %(user)s +Kontakt: %(contact)s + +%(description)s''' % { + 'url': reverse('admin:suggest_suggestion_change', args=[suggestion.id]), + 'user': str(request.user), + '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.'''), + 'no-reply@wolnelektury.pl', [contact], fail_silently=True) + response_data = {'success': True, 'message': _('Report was sent successfully.')} else: response_data = {'success': False, 'errors': suggest_form.errors} - print LazyEncoder(ensure_ascii=False).encode(response_data) return HttpResponse(LazyEncoder(ensure_ascii=False).encode(response_data))