Merge pull request #131 from levivm/feature/new_digitalglarus
Feature/new digitalglarus
This commit is contained in:
commit
9a8af193bc
3 changed files with 13 additions and 5 deletions
|
@ -81,6 +81,10 @@ class BookingDateForm(forms.Form):
|
|||
end_date = forms.DateField(required=False,
|
||||
widget=forms.TextInput(attrs={'id': 'booking-date-2'}))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user')
|
||||
super(BookingDateForm, self).__init__(*args, **kwargs)
|
||||
|
||||
def clean_start_date(self):
|
||||
start_date = self.cleaned_data.get('start_date')
|
||||
if not start_date:
|
||||
|
@ -94,7 +98,6 @@ class BookingDateForm(forms.Form):
|
|||
return end_date
|
||||
|
||||
def clean(self):
|
||||
|
||||
start_date = self.cleaned_data.get('start_date')
|
||||
end_date = self.cleaned_data.get('end_date')
|
||||
|
||||
|
@ -104,8 +107,10 @@ class BookingDateForm(forms.Form):
|
|||
if start_date > end_date:
|
||||
raise forms.ValidationError("Your end date must be greather than your start date.")
|
||||
|
||||
q1 = Q(start_date__lte=start_date, end_date__gte=start_date)
|
||||
q2 = Q(start_date__gt=start_date, start_date__lte=end_date)
|
||||
q1 = Q(bookingorder__customer__user=self.user,
|
||||
start_date__lte=start_date, end_date__gte=start_date)
|
||||
q2 = Q(bookingorder__customer__user=self.user,
|
||||
start_date__gt=start_date, start_date__lte=end_date)
|
||||
if Booking.objects.filter(q1 | q2).exists():
|
||||
raise forms.ValidationError("You already have a booking in these dates.")
|
||||
|
||||
|
|
|
@ -67,8 +67,6 @@ class Command(BaseCommand):
|
|||
'amount': current_membership_price
|
||||
}
|
||||
membership_order_form = MembershipOrderForm(membership_order_data)
|
||||
import pdb
|
||||
pdb.set_trace()
|
||||
if membership_order_form.is_valid():
|
||||
membership_order = membership_order_form.save()
|
||||
|
||||
|
|
|
@ -96,6 +96,11 @@ class BookingSelectDatesView(LoginRequiredMixin, MembershipRequiredMixin, FormVi
|
|||
login_url = reverse_lazy('digitalglarus:login')
|
||||
success_url = reverse_lazy('digitalglarus:booking_payment')
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(BookingSelectDatesView, self).get_form_kwargs()
|
||||
kwargs.update({'user': self.request.user})
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form):
|
||||
user = self.request.user
|
||||
start_date = form.cleaned_data.get('start_date')
|
||||
|
|
Loading…
Reference in a new issue