2021-10-26 16:02:11 +00:00
|
|
|
from django.conf import settings
|
2021-10-26 16:02:55 +00:00
|
|
|
from django.core.mail import EmailMessage
|
2021-10-26 15:47:06 +00:00
|
|
|
from django.shortcuts import render
|
2021-10-28 11:10:26 +00:00
|
|
|
from app.video.utils import render_to_json_response
|
2021-10-26 15:47:06 +00:00
|
|
|
from . import forms
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
def index(request):
|
2021-10-28 11:10:26 +00:00
|
|
|
success = True
|
2021-10-26 15:47:06 +00:00
|
|
|
if request.method == 'POST':
|
|
|
|
form = forms.ContactForm(request.POST)
|
|
|
|
if form.is_valid():
|
|
|
|
message = 'From: %s\n\n%s' % (form.cleaned_data['email'], form.cleaned_data['message'])
|
|
|
|
subject = 'Phantas.ma/polis contact message'
|
|
|
|
from_ = settings.CONTACT_FROM_EMAIL
|
2021-10-26 16:51:21 +00:00
|
|
|
to = [settings.CONTACT_TO_EMAIL]
|
2021-10-26 15:47:06 +00:00
|
|
|
msg = EmailMessage(subject, message, from_, to, reply_to=[form.cleaned_data['email']])
|
|
|
|
msg.send(fail_silently=True)
|
|
|
|
else:
|
2021-10-28 11:10:26 +00:00
|
|
|
success = False
|
|
|
|
else:
|
|
|
|
success = False
|
|
|
|
return render_to_json_response({'success': success})
|