mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-06 02:16:47 +00:00
* crete setting module to split prod and dev configs * fix calendar midmatch * lint imports using isort * doc: add doctrings
28 lines
821 B
Python
28 lines
821 B
Python
from django.shortcuts import render
|
|
|
|
from rental.forms.contact import ContactForm
|
|
from rental.models.contact import Contact
|
|
|
|
|
|
def view(request):
|
|
"""Handle contactForm."""
|
|
|
|
if request.method == 'POST':
|
|
form = ContactForm(request.POST)
|
|
if form.is_valid():
|
|
contact = Contact.objects.create(
|
|
name=form.cleaned_data['name'],
|
|
email=form.cleaned_data['email'],
|
|
subject=form.cleaned_data['subject'],
|
|
message=form.cleaned_data['message']
|
|
)
|
|
|
|
contact.send_confirmation()
|
|
contact.send_notification()
|
|
|
|
return render(request, 'rental/contact_merci.html', {})
|
|
|
|
else:
|
|
form = ContactForm()
|
|
context = {'form': form}
|
|
return render(request, 'rental/contact.html', context)
|