Added membership pricing view. Added membership pricing html. Added membership pricing url. Started booking view. Started integrating booking.js. Added calendar date range js lib. Fixing date picker. Added function to calculate remaining free days. Updated function to calculate booking price. Added BookingDatesForm. Added backend validation for booking dates. fixed booking form. adding pricing to booking payment view. Added free days to booking payment view. Started booking payment stripe flow. Redefined dispatch method to booking view. Now login is required for payment selecting dates and booking. Added date range to booking payment. Fixed booking select dates view. Added form validations to booking form. Created a order after a confirm a booking. Added free_days to booking model in order to facilitate free_days Availability for the next booking. Creating a Stripe charge. Creating Booking model instance. Refactor booking payment views. Associated an order to a stripe charge. Associated booking order instance with a booking instance.
This commit is contained in:
parent
1152e41b6e
commit
2eb2c90b1f
16 changed files with 783 additions and 25 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from utils.models import BillingAddress
|
||||
from utils.forms import LoginFormMixin, SignupFormMixin, BillingAddressForm
|
||||
|
|
@ -34,3 +34,46 @@ class MembershipBillingForm(BillingAddressForm):
|
|||
'postal_code': _('Postal Code'),
|
||||
'country': _('Country'),
|
||||
}
|
||||
|
||||
|
||||
class BookingBillingForm(BillingAddressForm):
|
||||
token = forms.CharField(widget=forms.HiddenInput())
|
||||
start_date = forms.DateField(widget=forms.HiddenInput())
|
||||
end_date = forms.DateField(widget=forms.HiddenInput())
|
||||
price = forms.FloatField(widget=forms.HiddenInput())
|
||||
|
||||
class Meta:
|
||||
model = BillingAddress
|
||||
fields = ['start_date', 'end_date', 'price', 'street_address',
|
||||
'city', 'postal_code', 'country']
|
||||
labels = {
|
||||
'street_address': _('Street Address'),
|
||||
'city': _('City'),
|
||||
'postal_code': _('Postal Code'),
|
||||
'country': _('Country'),
|
||||
}
|
||||
|
||||
|
||||
class BookingDateForm(forms.Form):
|
||||
start_date = forms.DateField(required=False)
|
||||
end_date = forms.DateField(required=False)
|
||||
date_range = forms.CharField(required=False)
|
||||
|
||||
def clean_date_range(self):
|
||||
date_range = self.cleaned_data.get('date_range')
|
||||
dates = date_range.replace(' ', '').split('-')
|
||||
try:
|
||||
start_date, end_date = [datetime.strptime(date_string, "%m/%d/%Y").date()
|
||||
for date_string in dates]
|
||||
except ValueError:
|
||||
raise forms.ValidationError("Submit valid dates.")
|
||||
|
||||
if start_date >= end_date:
|
||||
raise forms.ValidationError("Your end date must be greather than your start date.")
|
||||
return start_date, end_date
|
||||
|
||||
def clean(self):
|
||||
start_date, end_date = self.cleaned_data.get('date_range')
|
||||
self.cleaned_data['start_date'] = start_date
|
||||
self.cleaned_data['end_date'] = end_date
|
||||
return self.cleaned_data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue