Ejemplo n.º 1
0
def feedback(request):
    from website.forms import FeedbackForm
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            subject = u'Вопрос с сайта'
            recipients = []
            recipients.extend(emails_list(request.settings.email))
            letter_context = form.cleaned_data
            letter_context.update({'site': request.settings.project})
            letter_content = render_to_string('feedback_letter.txt', letter_context)
            send_mail(subject, letter_content,
                      letter_context['email'] or recipients[0], recipients)
            messages.add_message(request, messages.SUCCESS, u"Ваше письмо успешно отправлено администрации сайта.")
            return redirect('')
    else:
        form = FeedbackForm()
    return render(request, 'feedback.html', {'form': form})
Ejemplo n.º 2
0
def feedback(request):
    if request.method == 'POST':
        form = FeedbackForm( request.POST )
        if form.is_valid():
            f = open(os.path.join(settings.MEDIA_ROOT, 'feedback.txt'), 'a')
            data = form.cleaned_data
            f.write( str(timezone.now()) )
            f.write( str('\n') )
            f.write( data['text'] )
            f.write( str('\n\n\n') )
            return HttpResponseRedirect('/')
    else:
        form = FeedbackForm()

    return render(request, 'feedback.html', {
        'form' : form,
    },
    )
Ejemplo n.º 3
0
def feedback(request):
    from website.forms import FeedbackForm
    if request.method == 'POST':
        form = FeedbackForm(request.POST)
        if form.is_valid():
            subject = u'Вопрос с сайта'
            recipients = []
            recipients.extend(emails_list(request.settings.email))
            letter_context = form.cleaned_data
            letter_context.update({'site': request.settings.project})
            letter_content = render_to_string('feedback_letter.txt',
                                              letter_context)
            send_mail(subject, letter_content, letter_context['email']
                      or recipients[0], recipients)
            messages.add_message(
                request, messages.SUCCESS,
                u"Ваше письмо успешно отправлено администрации сайта.")
            return redirect('')
    else:
        form = FeedbackForm()
    return render(request, 'feedback.html', {'form': form})
Ejemplo n.º 4
0
 def test_feedback_form(self):
     form = FeedbackForm(data={
         'model': ['Feedback'],
         'fields': ['dina', 'balua', 'message']
     })