119 lines
4.5 KiB
Python
119 lines
4.5 KiB
Python
from captcha.fields import CaptchaField
|
|
from crispy_forms.helper import FormHelper
|
|
from crispy_forms.layout import Submit, Layout, Div, Field, HTML, ButtonHolder
|
|
import floppyforms as forms
|
|
from django.forms import HiddenInput
|
|
|
|
from alion_app.models import Room, Booking
|
|
|
|
|
|
class ContactForm(forms.Form):
|
|
name = forms.CharField(required=True)
|
|
email = forms.EmailField(required=True)
|
|
subject = forms.CharField(required=True)
|
|
message = forms.CharField(widget=forms.Textarea)
|
|
captcha = CaptchaField()
|
|
|
|
def __init__(self, *arg, **kwarg):
|
|
super(ContactForm, self).__init__(*arg, **kwarg)
|
|
self.helper = FormHelper()
|
|
self.fields['name'].label = ''
|
|
self.fields['email'].label = 'email'
|
|
self.fields['subject'].label = ''
|
|
self.fields['message'].label = ''
|
|
self.helper.layout = Layout(
|
|
Div(
|
|
HTML('{% load i18n %}{% trans "Όνομα:" %}'),
|
|
Field('name'),
|
|
Field('email'),
|
|
HTML('{% load i18n %}{% trans "Θέμα:" %}'),
|
|
Field('subject'),
|
|
HTML('{% load i18n %}{% trans "Μήνυμα:" %}'),
|
|
Field('message'),
|
|
Field('captcha'),
|
|
HTML("<br>"),
|
|
ButtonHolder(Submit('submit', '{% load i18n %}{% trans "Αποστολή" %}')),
|
|
)
|
|
)
|
|
|
|
|
|
class AvailabilityForm(forms.Form):
|
|
check_in = forms.DateField(
|
|
required=True,
|
|
input_formats=["%d-%m-%Y"],
|
|
widget=forms.DateTimeInput(attrs={'type': 'text', 'id': 'check_in', 'class': 'form-control text-left mr-2'}))
|
|
check_out = forms.DateField(
|
|
required=True,
|
|
input_formats=["%d-%m-%Y"],
|
|
widget=forms.DateTimeInput(attrs={'type': 'text', 'id': 'check_out', 'class': 'form-control text-left ml-2'}))
|
|
room_category = forms.ChoiceField(
|
|
required=True,
|
|
choices=Room.ROOM_CATEGORIES)
|
|
|
|
class BookRequestForm(forms.Form):
|
|
check_in = forms.DateField(
|
|
required=True,
|
|
input_formats=["%d-%m-%Y"],
|
|
widget=forms.DateTimeInput(attrs={'type': 'text', 'id': 'check_in', 'class': 'text-left mr-2', 'readonly': 'readonly' }))
|
|
check_out = forms.DateField(
|
|
required=True,
|
|
input_formats=["%d-%m-%Y"],
|
|
widget=forms.DateTimeInput(attrs={'type': 'text', 'id': 'check_out', 'class': 'text-left ml-2', 'readonly': 'readonly' }))
|
|
#room_category = forms.CheckboxInput(attrs={'type': 'text', 'readonly': 'readonly'})
|
|
room_category = forms.ChoiceField(
|
|
choices=Room.ROOM_CATEGORIES,)
|
|
|
|
name = forms.CharField()
|
|
surname = forms.CharField()
|
|
telephone = forms.CharField()
|
|
email = forms.EmailField(required=False)
|
|
info = forms.CharField(widget=forms.Textarea, required=False)
|
|
captcha = CaptchaField()
|
|
|
|
|
|
def __init__(self, *arg, **kwarg):
|
|
super(BookRequestForm, self).__init__(*arg, **kwarg)
|
|
self.helper = FormHelper()
|
|
self.fields['name'].label = ''
|
|
self.fields['surname'].label = ''
|
|
self.fields['telephone'].label = ''
|
|
self.fields['info'].label = ''
|
|
self.helper.layout = Layout(
|
|
Div(
|
|
HTML('{% load i18n %}{% trans "Όνομα:" %}'),
|
|
Field('name'),
|
|
HTML('{% load i18n %}{% trans "Επώνυμο:" %}'),
|
|
Field('surname'),
|
|
HTML('{% load i18n %}{% trans "Τηλέφωνο:" %}'),
|
|
Field('telephone'),
|
|
HTML('{% load i18n %}{% trans "Πληροφορίες:" %}'),
|
|
Field('info'),
|
|
Field('captcha'),
|
|
HTML("<br>"),
|
|
ButtonHolder(Submit('submit', '{% load i18n %}{% trans "Αποθήκευση" %}')),
|
|
)
|
|
)
|
|
|
|
|
|
class EditBooking(forms.Form):
|
|
name = forms.CharField()
|
|
surname = forms.CharField()
|
|
telephone = forms.CharField()
|
|
email = forms.EmailField(required=False)
|
|
|
|
room_category = forms.ChoiceField(
|
|
choices=Room.ROOM_CATEGORIES,)
|
|
check_in = forms.DateField(
|
|
required=True,
|
|
input_formats=["%d-%m-%Y"],
|
|
widget=forms.DateTimeInput(attrs={'type': 'text', 'id': 'check_in', 'class': 'text-left mr-2', 'readonly': 'readonly' }))
|
|
check_out = forms.DateField(
|
|
required=True,
|
|
input_formats=["%d-%m-%Y"],
|
|
widget=forms.DateTimeInput(attrs={'type': 'text', 'id': 'check_out', 'class': 'text-left ml-2', 'readonly': 'readonly' }))
|
|
final_price = forms.FloatField()
|
|
info = forms.CharField(widget=forms.Textarea, required=False)
|
|
accept = forms.ChoiceField(choices=Booking.ACCEPT_OPTION)
|
|
|
|
|