mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
add forms folder, put forms into different files and renamed ReservationForm to BookingForm
This commit is contained in:
parent
fed5732204
commit
2833cf0652
3 changed files with 51 additions and 51 deletions
|
|
@ -1,14 +1,10 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from rental.models.booking import Booking
|
from rental.models.booking import Booking
|
||||||
from rental.models.contact import Contact
|
|
||||||
from rental.models.guest import Guest
|
|
||||||
from rental.models.picture import Picture
|
|
||||||
from rental.models.place import Place
|
from rental.models.place import Place
|
||||||
from rental.models.testimonial import Testimonial
|
|
||||||
from rental.enums import PlaceNames
|
from rental.enums import PlaceNames
|
||||||
|
|
||||||
|
|
||||||
class ReservationForm(forms.Form):
|
class BookingForm(forms.Form):
|
||||||
|
|
||||||
name = forms.CharField(
|
name = forms.CharField(
|
||||||
label="",
|
label="",
|
||||||
|
|
@ -76,46 +72,3 @@ class ReservationForm(forms.Form):
|
||||||
'class': 'form-control form-control-lg form-control-a',
|
'class': 'form-control form-control-lg form-control-a',
|
||||||
'placeholder': '31/12/2020 *'}),
|
'placeholder': '31/12/2020 *'}),
|
||||||
required=True)
|
required=True)
|
||||||
|
|
||||||
|
|
||||||
class ContactForm(forms.Form):
|
|
||||||
|
|
||||||
name = forms.CharField(
|
|
||||||
label='',
|
|
||||||
widget=forms.TextInput(attrs={
|
|
||||||
'class': 'form-control form-control-lg form-control-a',
|
|
||||||
'placeholder': 'Nom *'
|
|
||||||
}),
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
email = forms.EmailField(
|
|
||||||
label='',
|
|
||||||
widget=forms.EmailInput(attrs={
|
|
||||||
'class': 'form-control form-control-lg form-control-a',
|
|
||||||
'placeholder': 'Email *'
|
|
||||||
}),
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
subject = forms.CharField(
|
|
||||||
label='',
|
|
||||||
widget=forms.TextInput(attrs={
|
|
||||||
'class': 'form-control form-control-lg form-control-a',
|
|
||||||
'placeholder': 'Sujet *'
|
|
||||||
}),
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
message = forms.CharField(
|
|
||||||
label='',
|
|
||||||
# max_length=100,
|
|
||||||
min_length=4,
|
|
||||||
widget=forms.Textarea(attrs={
|
|
||||||
'class': 'form-control',
|
|
||||||
'cols': '45',
|
|
||||||
'rows': '8',
|
|
||||||
'placeholder': 'Message *'
|
|
||||||
}),
|
|
||||||
required=True
|
|
||||||
)
|
|
||||||
46
rental/forms/contact.py
Normal file
46
rental/forms/contact.py
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
from django import forms
|
||||||
|
from rental.models.contact import Contact
|
||||||
|
from rental.models.place import Place
|
||||||
|
|
||||||
|
|
||||||
|
class ContactForm(forms.Form):
|
||||||
|
|
||||||
|
name = forms.CharField(
|
||||||
|
label='',
|
||||||
|
widget=forms.TextInput(attrs={
|
||||||
|
'class': 'form-control form-control-lg form-control-a',
|
||||||
|
'placeholder': 'Nom *'
|
||||||
|
}),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
email = forms.EmailField(
|
||||||
|
label='',
|
||||||
|
widget=forms.EmailInput(attrs={
|
||||||
|
'class': 'form-control form-control-lg form-control-a',
|
||||||
|
'placeholder': 'Email *'
|
||||||
|
}),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
subject = forms.CharField(
|
||||||
|
label='',
|
||||||
|
widget=forms.TextInput(attrs={
|
||||||
|
'class': 'form-control form-control-lg form-control-a',
|
||||||
|
'placeholder': 'Sujet *'
|
||||||
|
}),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
message = forms.CharField(
|
||||||
|
label='',
|
||||||
|
# max_length=100,
|
||||||
|
min_length=4,
|
||||||
|
widget=forms.Textarea(attrs={
|
||||||
|
'class': 'form-control',
|
||||||
|
'cols': '45',
|
||||||
|
'rows': '8',
|
||||||
|
'placeholder': 'Message *'
|
||||||
|
}),
|
||||||
|
required=True
|
||||||
|
)
|
||||||
|
|
@ -3,7 +3,8 @@ from django.db import IntegrityError
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rental.forms import ReservationForm, ContactForm
|
from rental.forms.booking import BookingForm
|
||||||
|
from rental.forms.contact import ContactForm
|
||||||
from rental.models.booking import Booking
|
from rental.models.booking import Booking
|
||||||
from rental.models.contact import Contact
|
from rental.models.contact import Contact
|
||||||
from rental.models.guest import Guest
|
from rental.models.guest import Guest
|
||||||
|
|
@ -54,7 +55,7 @@ def reservation(request):
|
||||||
|
|
||||||
def handle_reservation_form(request, context={}, init_template='rental/reservation.html'):
|
def handle_reservation_form(request, context={}, init_template='rental/reservation.html'):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = ReservationForm(request.POST)
|
form = BookingForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
name = form.cleaned_data['name']
|
name = form.cleaned_data['name']
|
||||||
email = form.cleaned_data['email']
|
email = form.cleaned_data['email']
|
||||||
|
|
@ -105,7 +106,7 @@ def handle_reservation_form(request, context={}, init_template='rental/reservati
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
form.errors['internal'] = "Une erreur interne est apparue. Merci de recommencer votre requête."
|
form.errors['internal'] = "Une erreur interne est apparue. Merci de recommencer votre requête."
|
||||||
else:
|
else:
|
||||||
form = ReservationForm()
|
form = BookingForm()
|
||||||
|
|
||||||
context['form'] = form
|
context['form'] = form
|
||||||
context['errors'] = form.errors.items()
|
context['errors'] = form.errors.items()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue