From 082f39e9dc264aff277ac8c49797c584b5946112 Mon Sep 17 00:00:00 2001
From: Levi
Date: Thu, 13 Oct 2016 23:33:48 -0500
Subject: [PATCH] Added url in booking&price menu bar button. Fixed bug when
user booked for 1 days and two free days were being given. Created
UserBillingAddress. Created UserBillingAddress Form.Created
UserBillingAddress after first user payment. Added Previous Billing data to
booking payment view if there is one. Moved booking button. Fixed error on
free days in booking invoice. Added modal to cancel subscription page. Now a
member can booking without entering his billing address or credit card info.
Fixed error on free days.Current user billing address is showed on billing
and booking order details. Edit billing address form added.Added
user_billing_address.html. Added user billing address get views. Filled user
billing address view with current user billing address.Now an user can edit
his billing address. Added is_free flag in Select Booking Dates in order to
now if a booking is free. Changed Booking Order Model in order to allow free
payments. Added free payment template. Added free payment into Booking
Payment View. Fixed issue #2586: new digitalglarus navbar font change.Fixed
issue #2608 : style fix new DG.Fixed #2617: fix input fields and btn
responsiveness on DG payment page. Fixed #2620: responsive issue in DG order
summary.Fixed #2623: Order history style fix for deativate button and message
below.Fixed #2625: DG membership activation page fix. Fixed #2616: fix navbar
responsivness for new DG. Fixed #2619: credit card input field responsiveness
fix
---
digitalglarus/forms.py | 2 +-
.../migrations/0020_auto_20161013_0253.py | 35 ++++++
digitalglarus/mixins.py | 6 +-
digitalglarus/models.py | 32 +++--
.../static/digitalglarus/css/agency.css | 4 +-
.../static/digitalglarus/css/price.css | 4 +-
.../static/digitalglarus/js/payment.js | 9 ++
.../digitalglarus/booking_orders_list.html | 12 +-
.../digitalglarus/booking_payment.html | 63 +++++++---
.../digitalglarus/membership_activated.html | 2 +-
.../digitalglarus/membership_deactivated.html | 26 ++++-
.../membership_orders_detail.html | 1 +
.../digitalglarus/membership_orders_list.html | 53 ++++++---
.../digitalglarus/membership_payment.html | 6 +-
.../digitalglarus/user_billing_address.html | 83 +++++++++++++
digitalglarus/templates/new_base_glarus.html | 2 +-
digitalglarus/test_views.py | 27 +++--
digitalglarus/urls.py | 3 +-
digitalglarus/views.py | 110 +++++++++++++++++-
utils/forms.py | 15 ++-
utils/migrations/0003_userbillingaddress.py | 34 ++++++
utils/migrations/0004_auto_20161013_0253.py | 22 ++++
utils/models.py | 29 ++++-
23 files changed, 500 insertions(+), 80 deletions(-)
create mode 100644 digitalglarus/migrations/0020_auto_20161013_0253.py
create mode 100644 digitalglarus/templates/digitalglarus/user_billing_address.html
create mode 100644 utils/migrations/0003_userbillingaddress.py
create mode 100644 utils/migrations/0004_auto_20161013_0253.py
diff --git a/digitalglarus/forms.py b/digitalglarus/forms.py
index 4084ced5..6982037f 100644
--- a/digitalglarus/forms.py
+++ b/digitalglarus/forms.py
@@ -57,7 +57,7 @@ class MembershipOrderForm(forms.ModelForm):
class BookingBillingForm(BillingAddressForm):
- token = forms.CharField(widget=forms.HiddenInput())
+ token = forms.CharField(widget=forms.HiddenInput(), required=False)
start_date = forms.DateField(widget=forms.HiddenInput())
end_date = forms.DateField(widget=forms.HiddenInput())
price = forms.FloatField(widget=forms.HiddenInput())
diff --git a/digitalglarus/migrations/0020_auto_20161013_0253.py b/digitalglarus/migrations/0020_auto_20161013_0253.py
new file mode 100644
index 00000000..f9d49868
--- /dev/null
+++ b/digitalglarus/migrations/0020_auto_20161013_0253.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2016-10-13 02:53
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('digitalglarus', '0019_auto_20160929_0324'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='bookingorder',
+ name='cc_brand',
+ field=models.CharField(blank=True, max_length=10),
+ ),
+ migrations.AlterField(
+ model_name='bookingorder',
+ name='last4',
+ field=models.CharField(blank=True, max_length=4),
+ ),
+ migrations.AlterField(
+ model_name='membershiporder',
+ name='cc_brand',
+ field=models.CharField(blank=True, max_length=10),
+ ),
+ migrations.AlterField(
+ model_name='membershiporder',
+ name='last4',
+ field=models.CharField(blank=True, max_length=4),
+ ),
+ ]
diff --git a/digitalglarus/mixins.py b/digitalglarus/mixins.py
index 013cdd78..5392ad37 100644
--- a/digitalglarus/mixins.py
+++ b/digitalglarus/mixins.py
@@ -32,8 +32,8 @@ class Ordereable(models.Model):
billing_address = models.ForeignKey(BillingAddress)
created_at = models.DateTimeField(auto_now_add=True)
approved = models.BooleanField(default=False)
- last4 = models.CharField(max_length=4)
- cc_brand = models.CharField(max_length=10)
+ last4 = models.CharField(max_length=4, blank=True)
+ cc_brand = models.CharField(max_length=10, blank=True)
stripe_charge_id = models.CharField(max_length=100, null=True)
class Meta:
@@ -43,6 +43,8 @@ class Ordereable(models.Model):
def create(cls, data):
stripe_charge = data.pop('stripe_charge', None)
instance = cls.objects.create(**data)
+ if not stripe_charge:
+ return instance
instance.stripe_charge_id = stripe_charge.id
instance.last4 = stripe_charge.source.last4
instance.cc_brand = stripe_charge.source.brand
diff --git a/digitalglarus/models.py b/digitalglarus/models.py
index 17621bfd..9d423f3d 100644
--- a/digitalglarus/models.py
+++ b/digitalglarus/models.py
@@ -71,12 +71,12 @@ class Membership(models.Model):
@classmethod
def is_digitalglarus_active_member(cls, user):
past_month = (datetime.today() - relativedelta(months=1)).month
- has_booking_current_month = Q(membershiporder__customer__user=user,
- membershiporder__created_at__month=datetime.today().month)
- has_booking_past_month = Q(membershiporder__customer__user=user,
- membershiporder__created_at__month=past_month)
+ has_order_current_month = Q(membershiporder__customer__user=user,
+ membershiporder__created_at__month=datetime.today().month)
+ has_order_past_month = Q(membershiporder__customer__user=user,
+ membershiporder__created_at__month=past_month)
active_membership = Q(active=True)
- return cls.objects.filter(has_booking_past_month | has_booking_current_month).\
+ return cls.objects.filter(has_order_past_month | has_order_current_month).\
filter(active_membership).exists()
def deactivate(self):
@@ -147,7 +147,7 @@ class Booking(models.Model):
def get_ramaining_free_days(cls, user, start_date, end_date):
TWO_DAYS = 2
-
+ ONE_DAY = 1
start_month = start_date.month
end_month = end_date.month
months = abs(start_month - (end_month + 12) if end_month < start_month
@@ -156,6 +156,10 @@ class Booking(models.Model):
current_month_bookings = cls.objects.filter(bookingorder__customer__user=user,
start_date__month=current_date.month)
free_days_this_month = TWO_DAYS - sum(map(lambda x: x.free_days, current_month_bookings))
+
+ if start_date == end_date and free_days_this_month == TWO_DAYS:
+ free_days_this_month = ONE_DAY
+
total_free_days = months * TWO_DAYS + free_days_this_month
return total_free_days
@@ -190,11 +194,11 @@ class Booking(models.Model):
# Calculating membership required months price for booking
required_membership_months = 0
membership_booking_price = 0.0
- if BookingOrder.user_has_not_bookings(user):
- today = datetime.today().date()
- membership_price = MembershipType.objects.get(name=MembershipType.STANDARD).price
- required_membership_months = cls.membership_required_booking_months(today, end_date)
- membership_booking_price = membership_price * required_membership_months
+ # if not BookingOrder.user_has_not_bookings(user):
+ today = datetime.today().date()
+ membership_price = MembershipType.objects.get(name=MembershipType.STANDARD).price
+ required_membership_months = cls.membership_required_booking_months(today, end_date)
+ membership_booking_price = membership_price * required_membership_months
# Add required membership months to final prices
final_booking_price += membership_booking_price
@@ -210,11 +214,15 @@ class BookingOrder(Ordereable, models.Model):
membership_required_months = models.IntegerField(default=0)
membership_required_months_price = models.FloatField(default=0)
-
@classmethod
def user_has_not_bookings(cls, user):
return cls.objects.filter(customer__user=user).exists()
+ def get_booking_cc_data(self):
+ return {
+ 'last4': self.last4,
+ 'cc_brand': self.cc_brand,
+ }
def booking_days(self):
return (self.booking.end_date - self.booking.start_date).days + 1
diff --git a/digitalglarus/static/digitalglarus/css/agency.css b/digitalglarus/static/digitalglarus/css/agency.css
index 7be17307..39289c6e 100755
--- a/digitalglarus/static/digitalglarus/css/agency.css
+++ b/digitalglarus/static/digitalglarus/css/agency.css
@@ -241,6 +241,8 @@ fieldset[disabled] .btn-xl.active {
.navbar-default .navbar-collapse {
border-color: rgba(255,255,255,.02);
+ padding-right: 100px;
+ text-align: right;
}
.navbar-default .navbar-toggle {
@@ -259,7 +261,7 @@ fieldset[disabled] .btn-xl.active {
.navbar-default .nav li a {
text-transform: uppercase;
- font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-weight: 400;
letter-spacing: 1px;
color: #fff;
diff --git a/digitalglarus/static/digitalglarus/css/price.css b/digitalglarus/static/digitalglarus/css/price.css
index 22d37b99..359b47fe 100644
--- a/digitalglarus/static/digitalglarus/css/price.css
+++ b/digitalglarus/static/digitalglarus/css/price.css
@@ -197,7 +197,7 @@
}
.glyphicon-ok {
- font-size: 42px;
+ font-size: 28px;
display: block;
text-align: center;
margin-bottom: 20px;
@@ -364,7 +364,7 @@
}
.form-control {
- color: #999;
+ color: #000;
border-radius: 0px;
box-shadow: none;
}
diff --git a/digitalglarus/static/digitalglarus/js/payment.js b/digitalglarus/static/digitalglarus/js/payment.js
index dd6c64d4..d9c6e0f7 100644
--- a/digitalglarus/static/digitalglarus/js/payment.js
+++ b/digitalglarus/static/digitalglarus/js/payment.js
@@ -24,12 +24,21 @@ $( document ).ready(function() {
}
});
+ var submit_form_btn = $('#payment_button');
+ submit_form_btn.on('click', submit_payment);
+
+ function submit_payment(e){
+ $('#billing-form').submit();
+ // $form.submit();
+ }
+
var $form = $('#payment-form');
$form.submit(payWithStripe);
/* If you're using Stripe for payments */
function payWithStripe(e) {
+ console.log("submiting");
e.preventDefault();
/* Visual feedback */
diff --git a/digitalglarus/templates/digitalglarus/booking_orders_list.html b/digitalglarus/templates/digitalglarus/booking_orders_list.html
index bff0e231..9fa3d793 100644
--- a/digitalglarus/templates/digitalglarus/booking_orders_list.html
+++ b/digitalglarus/templates/digitalglarus/booking_orders_list.html
@@ -39,11 +39,15 @@
- Billing AdressEdit
- Nico Schottelius
- In der Au 7 8762 Schwanden
- Switzerland
+ Billing AdressEdit
+
+ {{request.user.name}}
+
+ {{billing_address.street_address}},{{billing_address.postal_code}}
+ {{billing_address.city}}, {{billing_address.country}}.
+
+
diff --git a/digitalglarus/templates/digitalglarus/booking_payment.html b/digitalglarus/templates/digitalglarus/booking_payment.html
index fda2a0e2..8613dcab 100644
--- a/digitalglarus/templates/digitalglarus/booking_payment.html
+++ b/digitalglarus/templates/digitalglarus/booking_payment.html
@@ -27,7 +27,7 @@
Booking
- Billing Adress
+
Your Digital Glarus Membership enables
you to use our coworking space and it includes
@@ -37,7 +37,25 @@
15CHF per day. More than 17 days a month it
will charge only 290CHF/month.
+ {% if is_free %}
+ Billing Adress
+
+
+
+
+
+ Your Booking is TOTALLY FREE
+
+ {% else %}
+ Billing Adress
- Credit Card
+ {% if credit_card_data %}
+
+ {% else %}
+ Credit Card (Last used)
diff --git a/digitalglarus/templates/digitalglarus/membership_activated.html b/digitalglarus/templates/digitalglarus/membership_activated.html
index f899f6ec..db641555 100644
--- a/digitalglarus/templates/digitalglarus/membership_activated.html
+++ b/digitalglarus/templates/digitalglarus/membership_activated.html
@@ -24,7 +24,7 @@
Go to Booking
-
Your membership will be automatically renewed each month. For deactivating go tomy page
+
Your membership will be automatically renewed each month. For deactivating go todeactivate page
diff --git a/digitalglarus/templates/digitalglarus/membership_deactivated.html b/digitalglarus/templates/digitalglarus/membership_deactivated.html
index 3bfe3809..7ce1137f 100644
--- a/digitalglarus/templates/digitalglarus/membership_deactivated.html
+++ b/digitalglarus/templates/digitalglarus/membership_deactivated.html
@@ -22,7 +22,28 @@
@@ -32,6 +53,9 @@
+
+
+
diff --git a/digitalglarus/templates/digitalglarus/membership_orders_detail.html b/digitalglarus/templates/digitalglarus/membership_orders_detail.html
index 817c818a..2f1ef140 100644
--- a/digitalglarus/templates/digitalglarus/membership_orders_detail.html
+++ b/digitalglarus/templates/digitalglarus/membership_orders_detail.html
@@ -60,6 +60,7 @@
Membership month {{order.created_at|date:"F"}}
{{order.amount|floatformat}}CHF
+
Total
{{order.amount|floatformat}}CHF
diff --git a/digitalglarus/templates/digitalglarus/membership_orders_list.html b/digitalglarus/templates/digitalglarus/membership_orders_list.html
index 159e1379..8247835a 100644
--- a/digitalglarus/templates/digitalglarus/membership_orders_list.html
+++ b/digitalglarus/templates/digitalglarus/membership_orders_list.html
@@ -38,11 +38,14 @@
{% endfor %}
-
- Billing AdressEdit
- Nico Schottelius
- In der Au 7 8762 Schwanden
- Switzerland
+
+ Billing AdressEdit
+
+ {{request.user.name}}
+
+
+ {{billing_address.street_address}},{{billing_address.postal_code}}
+ {{billing_address.city}}, {{billing_address.country}}.
@@ -50,14 +53,15 @@
Dates: {{membership_start_date|date}} - {{membership_end_date|date}}
-
+
+
-
-
You will be charged on the first of the month until you
- cancel your subscription. Previous charges won't be refunded.
+
+
You will be charged on the first of the month until you
+ cancel your subscription. Previous charges won't be refunded.
@@ -66,19 +70,38 @@
+
-
Thank You!
+
+ {% if messages %}
+
+
Message
+
+ {% for message in messages %}
+ {{ message }}
+ {% endfor %}
+
+ {% else %}
+
+
Thank You!
+
+
+
Digital Glarus lives with your love!
Our coworking space is here because of your love and support.
+
This box is here just to thank you
+
+ {% endif %}
+
+
+
-
This box is here just to thank you
-
-
+
diff --git a/digitalglarus/templates/digitalglarus/membership_payment.html b/digitalglarus/templates/digitalglarus/membership_payment.html
index bde934de..824d46a9 100644
--- a/digitalglarus/templates/digitalglarus/membership_payment.html
+++ b/digitalglarus/templates/digitalglarus/membership_payment.html
@@ -56,14 +56,14 @@