Merge branch 'task/3756/landing_billing_page' of https://github.com/tiwariav/dynamicweb into tiwariav-task/3756/landing_billing_page

This commit is contained in:
PCoder 2017-09-21 02:41:26 +05:30
commit 143f40bd2d
9 changed files with 401 additions and 290 deletions

View file

@ -65,24 +65,6 @@ msgstr "Bitte gib einen Wert von 10 bis 200 ein."
msgid "GB Storage (SSD)" msgid "GB Storage (SSD)"
msgstr "GB Storage (SSD)" msgstr "GB Storage (SSD)"
msgid "Name"
msgstr ""
msgid "Your Name"
msgstr "Dein Name"
msgid "Please enter your name."
msgstr "Bitte gib Deinen Namen ein."
msgid "Email"
msgstr "E-Mail-Adresse"
msgid "Your Email"
msgstr "Deine E-Mail"
msgid "Please enter a valid email address."
msgstr "Bitte gib eine gültige E-Mailadresse ein."
msgid "Continue" msgid "Continue"
msgstr "Weiter" msgstr "Weiter"
@ -95,6 +77,18 @@ msgstr "Vielen Dank für Deine Nachricht."
msgid "Get in touch with us!" msgid "Get in touch with us!"
msgstr "Sende uns eine Nachricht." msgstr "Sende uns eine Nachricht."
msgid "Name"
msgstr ""
msgid "Please enter your name."
msgstr "Bitte gib Deinen Namen ein."
msgid "Email"
msgstr "E-Mail-Adresse"
msgid "Please enter a valid email address."
msgstr "Bitte gib eine gültige E-Mailadresse ein."
msgid "Message" msgid "Message"
msgstr "Nachricht" msgstr "Nachricht"
@ -188,13 +182,13 @@ msgid "All Rights Reserved"
msgstr "Alle Rechte vorbehalten" msgstr "Alle Rechte vorbehalten"
msgid "Toggle navigation" msgid "Toggle navigation"
msgstr "Konfiguration" msgstr "Umschalten"
msgid "Why Data Center Light?" msgid "Why Data Center Light?"
msgstr "Warum Data Center Light?" msgstr "Warum Data Center Light?"
msgid "Login" msgid "Login"
msgstr "" msgstr "Anmelden"
msgid "Dashboard" msgid "Dashboard"
msgstr "" msgstr ""
@ -264,6 +258,39 @@ msgstr "Kontaktiere uns"
msgid "Switzerland " msgid "Switzerland "
msgstr "Schweiz " msgstr "Schweiz "
msgid "Welcome back"
msgstr "Willkommen zurück"
msgid ""
"Review your billing address and card details and proceed to make payment."
msgstr ""
"Überprüfe die Rechnungsadresse und Kreditkartendaten und fahre mit der "
"Zahlung fort."
msgid "Log in"
msgstr "Anmelden"
msgid ""
"Already signed up?<br>By logging in you can retrieve saved billing "
"information."
msgstr ""
"Bereits eingeloggt? Nach der Anmeldung kannst Du gespeicherte "
"Rechnungsinformationen abrufen."
msgid "LOGIN"
msgstr "ANMELDEN"
msgid "Don't have an account yet?"
msgstr "Besitzt du kein Benutzerkonto?"
msgid "You can sign up by filling in the information below."
msgstr ""
"Du kannst Dich anmelden, indem Du die die untenstehenden Informationen "
"ausfüllst."
msgid "Forgot password?"
msgstr "Passwort vergessen?"
msgid "Your Order" msgid "Your Order"
msgstr "Deine Bestellung" msgstr "Deine Bestellung"
@ -288,6 +315,9 @@ msgstr "inkl. Mehrwertsteuer"
msgid "Month" msgid "Month"
msgstr "Monat" msgstr "Monat"
msgid "Sign up"
msgstr "Registrieren"
msgid "Billing Address" msgid "Billing Address"
msgstr "Rechnungsadresse" msgstr "Rechnungsadresse"
@ -295,15 +325,10 @@ msgid "Credit Card"
msgstr "Kreditkarte" msgstr "Kreditkarte"
msgid "" msgid ""
"\n" "Please fill in your credit card information below. We are using <a href="
" Please fill in your credit card information " "\"https://stripe.com\" target=\"_blank\">Stripe</a> for payment and do not "
"below. We are using <a\n" "store your information in our database."
" href=\"https://stripe.com\" target="
"\"_blank\">Stripe</a> for payment and do not store\n"
" your information in our database.\n"
" "
msgstr "" msgstr ""
"\n"
"Bitte füll Deine Kreditkarteninformationen unten aus. Wir nutzen <a href=" "Bitte füll Deine Kreditkarteninformationen unten aus. Wir nutzen <a href="
"\"https://stripe.com\" target=\"_blank\">Stripe</a> für die Bezahlung und " "\"https://stripe.com\" target=\"_blank\">Stripe</a> für die Bezahlung und "
"speichern keine Informationen in unserer Datenbank." "speichern keine Informationen in unserer Datenbank."
@ -330,6 +355,13 @@ msgstr ""
msgid "Card Type" msgid "Card Type"
msgstr "Kartentyp" msgstr "Kartentyp"
msgid ""
"You are not making any payment yet. After placing your order, you will be "
"taken to the Submit Payment Page."
msgstr ""
"Es wird noch keine Bezahlung vorgenommen. Die Bezahlung wird erst ausgelöst, "
"nachdem Du die Bestellung auf der nächsten Seite bestätigt hast."
msgid "Processing" msgid "Processing"
msgstr "Weiter" msgstr "Weiter"
@ -479,11 +511,23 @@ msgstr "Ungültige RAM-Grösse"
msgid "Invalid storage size" msgid "Invalid storage size"
msgstr "Ungültige Speicher-Grösse" msgstr "Ungültige Speicher-Grösse"
msgid "is not a proper name" msgid "Another user exists with that email!"
msgstr "ist kein gültiger Name" msgstr ""
msgid "is not a proper email" #~ msgid "Email Address"
msgstr "ist keine gültige E-Mailadresse" #~ msgstr "E-Mail-Adresse"
#~ msgid "is not a proper name"
#~ msgstr "ist kein gültiger Name"
#~ msgid "is not a proper email"
#~ msgstr "ist keine gültige E-Mailadresse"
#~ msgid "Your Name"
#~ msgstr "Dein Name"
#~ msgid "Your Email"
#~ msgstr "Deine E-Mail"
#~ msgid "" #~ msgid ""
#~ "\n" #~ "\n"

View file

@ -81,43 +81,6 @@
<!--<div class="description check-ip"> <!--<div class="description check-ip">
<input type="checkbox" name="ipv6"> Ipv6 Only<br> <input type="checkbox" name="ipv6"> Ipv6 Only<br>
</div>--> </div>-->
<div class="form-group">
<div class="description input justify-center">
<label for="name" class="control-label">{% trans "Name"%}</label>
<input type="text" name="name" class="form-control" placeholder="{% trans 'Your Name'%}"
data-minlength="3" data-error="{% trans 'Please enter your name.' %}" required>
</div>
<div class="help-block with-errors">
{% for message in messages %}
{% if 'name' in message.tags %}
<ul class="list-unstyled">
<li>
{{ message|safe }}
</li>
</ul>
{% endif %}
{% endfor %}
</div>
</div>
<div class="form-group">
<div class="description input justify-center">
<label for="email" class="control-label">{% trans "Email"%}</label>
<input name="email" type="email" pattern="^[^@\s]+@([^@\s]+\.)+[^@\s]+$" class="form-control"
placeholder="{% trans 'Your Email' %}"
data-error="{% trans 'Please enter a valid email address.' %}" required>
</div>
<div class="help-block with-errors">
{% for message in messages %}
{% if 'email' in message.tags %}
<ul class="list-unstyled">
<li>
{{ message|safe }}
</li>
</ul>
{% endif %}
{% endfor %}
</div>
</div>
</div> </div>
<input type="submit" class="btn btn-primary disabled" value="{% trans 'Continue' %}"></input> <input type="submit" class="btn btn-primary disabled" value="{% trans 'Continue' %}"></input>
</form> </form>

View file

@ -1,190 +1,182 @@
{% extends "hosting/base_short.html" %} {% extends "hosting/base_short.html" %}
{% load staticfiles bootstrap3 i18n %} {% load staticfiles bootstrap3 i18n %}
{% block css_extra %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paymentfont/1.1.2/css/paymentfont.min.css"/>
{% endblock css_extra %}
{% block navbar %} {% block navbar %}
{% include "datacenterlight/includes/_navbar.html" %} {% include "datacenterlight/includes/_navbar.html" %}
{% endblock navbar %} {% endblock navbar %}
{% block content %} {% block content %}
<!-- Credit card form --> <!-- Credit card form -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/paymentfont/1.1.2/css/paymentfont.min.css"/>
<div class="dcl-order-container"> <div class="dcl-order-container">
<div class="payment-container"> <div class="payment-container">
<div class="row"> <div class="dcl-payment-grid">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 dcl-order-sec"> <div class="dcl-payment-box">
<h3><strong>{%trans "Your Order" %}</strong></h3> <div class="dcl-payment-section">
<div class="col-xs-6 col-sm-12 col-md-12 col-lg-12 dcl-order-table-header"> {% if request.user.is_authenticated %}
<div class="col-xs-12 col-sm-2 col-md-1 col-lg-1 tbl-header"> <div class="dcl-payment-user">
{%trans "Cores" %} <h4>{% trans "Welcome back" %} {{request.user.name}}!</h4>
</div> <p>{% trans "Review your billing address and card details and proceed to make payment." %}</p>
<div class="col-xs-12 col-sm-3 col-md-4 col-lg-4 tbl-header">
{%trans "Memory" %}
</div>
<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3 tbl-header">
{%trans "Disk space" %}
</div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 tbl-header">
{%trans "Configuration" %}
</div>
</div>
<div class="col-xs-6 col-sm-12 col-md-12 col-lg-12 dcl-order-table-content">
<div class="col-xs-12 col-sm-2 col-md-1 col-lg-1 tbl-content">
{{request.session.specs.cpu|floatformat}}
</div>
<div class="col-xs-12 col-sm-3 col-md-4 col-lg-4 tbl-content">
{{request.session.specs.memory|floatformat}} GB
</div>
<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3 tbl-content">
{{request.session.specs.disk_size|floatformat}} GB
</div>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 tbl-content">
{{request.session.template.name}}
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 dcl-order-table-total">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 tbl-tot tbl-no-padding">
{%trans "Total" %} <span>{%trans "including VAT" %}</span>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 tbl-no-padding">
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4"></div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 tbl-total">{{request.session.specs.price}}
CHF<span class="dcl-price-month">/{% trans "Month" %}</span>
</div> </div>
</div> {% else %}
<h3>{%trans "Log in" %}</h3>
<hr class="top-hr">
<p style="margin-bottom: 20px;">{% blocktrans %}Already signed up?<br>By logging in you can retrieve saved billing information.{% endblocktrans %}</p>
<form role="form" id="login-form" method="post" action="{% url 'hosting:login' %}" novalidate>
{% for field in login_form %}
{% csrf_token %}
{% bootstrap_field field show_label=False type='fields'%}
{% endfor %}
<input type='hidden' name='next' value='{{request.path}}'/>
<div class="form-group text-right">
<button type="submit" class="btn btn-wide btn-vm-contact">{% trans "LOGIN" %}</button>
</div>
</form>
<p>
{% trans "Don't have an account yet?" %}<br>
{% trans "You can sign up by filling in the information below." %}<br>
<a href="{% url 'hosting:reset_password' %}">{% trans "Forgot password?" %}</a>
</p>
{% endif %}
</div> </div>
</div> </div>
</div> <div class="dcl-payment-box">
<div class="row"> <div class="dcl-payment-section">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 dcl-billing-sec"> {% if not request.user.is_authenticated %}
<div class="col-xs-12 col-sm-5 col-md-6 billing dcl-billing"> <h3><b>{%trans "Sign up"%}</b></h3>
<h3><b>{%trans "Billing Address"%}</b></h3> {% else %}
<hr> <h3><b>{%trans "Billing Address"%}</b></h3>
{% endif %}
<hr class="top-hr">
{% for message in messages %}
{% if 'duplicate_email' in message.tags %}
<p class="text-danger">{{message}}</p>
{% endif %}
{% endfor %}
<form role="form" id="billing-form" method="post" action="" novalidate> <form role="form" id="billing-form" method="post" action="" novalidate>
{% for field in form %}
{% csrf_token %} {% csrf_token %}
{% for field in form %}
{% bootstrap_field field show_label=False type='fields'%} {% bootstrap_field field show_label=False type='fields'%}
{% endfor %} {% endfor %}
</form> </form>
</div> </div>
<div class="col-xs-12 col-sm-7 col-md-6 creditcard-box dcl-creditcard"> </div>
<div class="dcl-payment-box">
<div class="dcl-payment-section">
<h3>{%trans "Your Order" %}</h3>
<hr class="top-hr">
<div class="dcl-payment-order">
<p>{% trans "Cores"%} <strong class="pull-right">{{request.session.specs.cpu|floatformat}}</strong></p>
<hr>
<p>{% trans "Memory"%} <strong class="pull-right">{{request.session.specs.memory|floatformat}} GB</strong></p>
<hr>
<p>{% trans "Disk space"%} <strong class="pull-right">{{request.session.specs.disk_size|floatformat}} GB</strong></p>
<hr>
<p>{% trans "Configuration"%} <strong class="pull-right">{{request.session.template.name}}</strong></p>
<hr>
<p class="last-p"><strong>{%trans "Total" %}</strong>&nbsp;&nbsp;<small>({%trans "including VAT" %})</small> <strong class="pull-right">{{request.session.specs.price}} CHF/{% trans "Month" %}</strong></p>
</div>
</div>
</div>
<div class="dcl-payment-box">
<div class="dcl-payment-section">
<h3><b>{%trans "Credit Card"%}</b></h3> <h3><b>{%trans "Credit Card"%}</b></h3>
<hr> <hr class="top-hr">
<p>
{% blocktrans %}Please fill in your credit card information below. We are using <a href="https://stripe.com" target="_blank">Stripe</a> for payment and do not store your information in our database.{% endblocktrans %}
</p>
<div> <div>
<div> {% if credit_card_data.last4 %}
<p>
{% blocktrans %}
Please fill in your credit card information below. We are using <a
href="https://stripe.com" target="_blank">Stripe</a> for payment and do not store
your information in our database.
{% endblocktrans %}
</p>
</div>
<br>
<div>
{% if credit_card_data.last4 %}
<form role="form" id="payment-form-with-creditcard" novalidate> <form role="form" id="payment-form-with-creditcard" novalidate>
<h5 class="billing-head">Credit Card</h5> <h5 class="billing-head">Credit Card</h5>
<h5 class="membership-lead">Last 4: *****{{credit_card_data.last4}}</h5> <h5 class="membership-lead">Last 4: *****{{credit_card_data.last4}}</h5>
<h5 class="membership-lead">Type: {{credit_card_data.cc_brand}}</h5> <h5 class="membership-lead">Type: {{credit_card_data.cc_brand}}</h5>
<input type="hidden" name="credit_card_needed" value="false"/> <input type="hidden" name="credit_card_needed" value="false"/>
</form> </form>
<div class="row"> {% if not messages and not form.non_field_errors %}
<div class="col-xs-12"> <p class="card-warning-content card-warning-addtional-margin">
{% if not messages and not form.non_field_errors %} {% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %}
<p class="card-warning-content card-warning-addtional-margin"> </p>
{% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %} {% endif %}
</p> <div id='payment_error'>
{% endif %} {% for message in messages %}
<div id='payment_error'> {% if 'failed_payment' or 'make_charge_error' in message.tags %}
{% for message in messages %} <ul class="list-unstyled"><li>
{% if 'failed_payment' or 'make_charge_error' in message.tags %} <p class="card-warning-content card-warning-error">{{ message|safe }}</p>
<ul class="list-unstyled"><li> </li></ul>
<p class="card-warning-content card-warning-error">{{ message|safe }}</p> {% endif %}
</li></ul> {% endfor %}
{% endif %} {% for error in form.non_field_errors %}
{% endfor %} <p class="card-warning-content card-warning-error">
{% for error in form.non_field_errors %} {{ error|escape }}
<p class="card-warning-content card-warning-error"> </p>
{{ error|escape }} {% endfor %}
</p>
{% endfor %}
</div>
</div>
<div class="col-xs-12">
<div class="col-xs-6 pull-right">
<button id="payment_button_with_creditcard" class="btn btn-success stripe-payment-btn"
type="submit">
{%trans "Submit" %}
</button>
</div>
</div>
</div> </div>
<div class="text-right">
{% else %} <button id="payment_button_with_creditcard" class="btn btn-success btn-vm-contact" type="submit">{%trans "Submit" %}</button>
</div>
{% else %}
<form action="" id="payment-form-new" method="POST"> <form action="" id="payment-form-new" method="POST">
<input type="hidden" name="token"/> <input type="hidden" name="token"/>
<div class="group"> <div class="group">
<div class="col-xs-12 col-sm-12 col-md-10 col-lg-9 credit-card-goup"> <div class="credit-card-goup">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 card-element card-number-element"> <div class="card-element card-number-element">
<label>{%trans "Card Number" %}</label> <label>{%trans "Card Number" %}</label>
<div id="card-number-element" class="field my-input"></div> <div id="card-number-element" class="field my-input"></div>
</div> </div>
<div class="col-xs-5 col-sm-3 col-md-3 col-lg-3 card-element card-expiry-element"> <div class="row">
<label>{%trans "Expiry Date" %}</label> <div class="col-xs-5 card-element card-expiry-element">
<div id="card-expiry-element" class="field my-input"></div> <label>{%trans "Expiry Date" %}</label>
<div id="card-expiry-element" class="field my-input"></div>
</div>
<div class="col-xs-3 col-xs-offset-4 card-element card-cvc-element">
<label>{%trans "CVC" %}</label>
<div id="card-cvc-element" class="field my-input"></div>
</div>
</div> </div>
<div class="col-xs-12 col-sm-2 col-md-6 col-lg-7 hide-mobile"></div> <div class="card-element brand">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-2 card-element card-cvc-element">
<label>{%trans "CVC" %}</label>
<div id="card-cvc-element" class="field my-input"></div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 card-element brand">
<label>{%trans "Card Type" %}</label> <label>{%trans "Card Type" %}</label>
<i class="pf pf-credit-card" id="brand-icon"></i> <i class="pf pf-credit-card" id="brand-icon"></i>
</div> </div>
</div> </div>
</div> </div>
<div id="card-errors" role="alert"></div> <div id="card-errors"></div>
<div class="row"> {% if not messages and not form.non_field_errors %}
<div class="col-xs-12"> <p class="card-warning-content">
{% if not messages and not form.non_field_errors %} {% trans "You are not making any payment yet. After placing your order, you will be taken to the Submit Payment Page." %}
</p>
{% endif %}
<div id='payment_error'>
{% for message in messages %}
{% if 'failed_payment' in message.tags or 'make_charge_error' in message.tags %}
<ul class="list-unstyled">
<li><p class="card-warning-content card-warning-error">{{ message|safe }}</p></li>
</ul>
{% elif not form.non_field_errors %}
<p class="card-warning-content"> <p class="card-warning-content">
{% trans "You are not making any payment yet. After submitting your card information, you will be taken to the Confirm Order Page." %} {% trans "You are not making any payment yet. After placing your order, you will be taken to the Submit Payment Page." %}
</p> </p>
{% endif %} {% endif %}
<div id='payment_error'> {% endfor %}
{% for message in messages %}
{% if 'failed_payment' or 'make_charge_error' in message.tags %}
<ul class="list-unstyled"><li>
<p class="card-warning-content card-warning-error">{{ message|safe }}</p>
</li></ul>
{% endif %}
{% endfor %}
{% for error in form.non_field_errors %} {% for error in form.non_field_errors %}
<p class="card-warning-content card-warning-error"> <p class="card-warning-content card-warning-error">
{{ error|escape }} {{ error|escape }}
</p> </p>
{% endfor %} {% endfor %}
</div> </div>
</div> <div class="text-right">
<div class="col-xs-12"> <button class="btn btn-vm-contact btn-wide" type="submit">{%trans "SUBMIT" %}</button>
<div class="col-xs-6 pull-right">
<button class="btn btn-success stripe-payment-btn" type="submit">{%trans "Submit" %}
</button>
</div>
</div>
</div> </div>
<div class="row" style="display:none;"> <div style="display:none;">
<div class="col-xs-12"> <p class="payment-errors"></p>
<p class="payment-errors"></p>
</div>
</div> </div>
</form> </form>
{% endif %}
{% endif %}
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -39,9 +39,9 @@
<div class="col-xs-12 col-sm-6"> <div class="col-xs-12 col-sm-6">
<address> <address>
<h3><b>{% trans "Billed To:"%}</b></h3> <h3><b>{% trans "Billed To:"%}</b></h3>
{% with request.session.billing_address_data as billing_address %} {% with request.user.billing_addresses.first as billing_address %}
{{billing_address|get_value_from_dict:'cardholder_name'}}<br> {{billing_address|get_value_from_dict:'street_address'}}, {{billing_address|get_value_from_dict:'postal_code'}}<br> {{billing_address.cardholder_name}}<br> {{billing_address.street_address}}, {{billing_address.postal_code}}<br>
{{billing_address|get_value_from_dict:'city'}}, {{billing_address|get_value_from_dict:'country'}}. {{billing_address.city}}, {{billing_address.country}}.
{% endwith %} {% endwith %}
</address> </address>
</div> </div>

View file

@ -1,6 +1,7 @@
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth import login, authenticate
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
@ -12,11 +13,15 @@ from django.views.generic import FormView, CreateView, TemplateView, DetailView
from datacenterlight.tasks import create_vm_task from datacenterlight.tasks import create_vm_task
from hosting.models import HostingOrder from hosting.models import HostingOrder
from hosting.forms import HostingUserLoginForm
from membership.models import CustomUser, StripeCustomer from membership.models import CustomUser, StripeCustomer
from opennebula_api.models import OpenNebulaManager from opennebula_api.models import OpenNebulaManager
from opennebula_api.serializers import VirtualMachineTemplateSerializer, \ from opennebula_api.serializers import (
VMTemplateSerializer VirtualMachineTemplateSerializer, VMTemplateSerializer
from utils.forms import BillingAddressForm )
from utils.forms import (
BillingAddressForm, BillingAddressFormSignup, UserBillingAddressForm
)
from utils.mailer import BaseEmail from utils.mailer import BaseEmail
from utils.stripe_utils import StripeUtils from utils.stripe_utils import StripeUtils
from utils.tasks import send_plain_email_task from utils.tasks import send_plain_email_task
@ -74,7 +79,7 @@ class SuccessView(TemplateView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if 'specs' not in request.session or 'user' not in request.session: if 'specs' not in request.session or 'user' not in request.session:
return HttpResponseRedirect(reverse('datacenterlight:index')) return HttpResponseRedirect(reverse('datacenterlight:index'))
elif 'token' not in request.session: if 'token' not in request.session:
return HttpResponseRedirect(reverse('datacenterlight:payment')) return HttpResponseRedirect(reverse('datacenterlight:payment'))
elif 'order_confirmation' not in request.session: elif 'order_confirmation' not in request.session:
return HttpResponseRedirect( return HttpResponseRedirect(
@ -100,7 +105,7 @@ class PricingView(TemplateView):
'templates': VirtualMachineTemplateSerializer(templates, 'templates': VirtualMachineTemplateSerializer(templates,
many=True).data, many=True).data,
} }
except: except Exception:
messages.error(request, messages.error(request,
'We have a temporary problem to connect to our backend. \ 'We have a temporary problem to connect to our backend. \
Please try again in a few minutes' Please try again in a few minutes'
@ -280,11 +285,6 @@ class IndexView(CreateView):
opennebula_vm_template_id=template_id).first() opennebula_vm_template_id=template_id).first()
template_data = VMTemplateSerializer(template).data template_data = VMTemplateSerializer(template).data
name = request.POST.get('name')
email = request.POST.get('email')
name_field = forms.CharField()
email_field = forms.EmailField()
try: try:
cores = cores_field.clean(cores) cores = cores_field.clean(cores)
except ValidationError as err: except ValidationError as err:
@ -312,39 +312,14 @@ class IndexView(CreateView):
return HttpResponseRedirect( return HttpResponseRedirect(
reverse('datacenterlight:index') + "#order_form") reverse('datacenterlight:index') + "#order_form")
try:
name = name_field.clean(name)
except ValidationError as err:
msg = '{} {}.'.format(name, _('is not a proper name'))
messages.add_message(self.request, messages.ERROR, msg,
extra_tags='name')
return HttpResponseRedirect(
reverse('datacenterlight:index') + "#order_form")
try:
email = email_field.clean(email)
except ValidationError as err:
msg = '{} {}.'.format(email, _('is not a proper email'))
messages.add_message(self.request, messages.ERROR, msg,
extra_tags='email')
return HttpResponseRedirect(
reverse('datacenterlight:index') + "#order_form")
specs = { specs = {
'cpu': cores, 'cpu': cores,
'memory': memory, 'memory': memory,
'disk_size': storage, 'disk_size': storage,
'price': price 'price': price
} }
this_user = {
'name': name,
'email': email
}
request.session['specs'] = specs request.session['specs'] = specs
request.session['template'] = template_data request.session['template'] = template_data
request.session['user'] = this_user
return HttpResponseRedirect(reverse('datacenterlight:payment')) return HttpResponseRedirect(reverse('datacenterlight:payment'))
def get_success_url(self): def get_success_url(self):
@ -407,20 +382,19 @@ class WhyDataCenterLightView(IndexView):
class PaymentOrderView(FormView): class PaymentOrderView(FormView):
template_name = 'datacenterlight/landing_payment.html' template_name = 'datacenterlight/landing_payment.html'
form_class = BillingAddressForm
def get_form_class(self):
if self.request.user.is_authenticated():
return BillingAddressForm
else:
return BillingAddressFormSignup
def get_form_kwargs(self): def get_form_kwargs(self):
form_kwargs = super(PaymentOrderView, self).get_form_kwargs() form_kwargs = super(PaymentOrderView, self).get_form_kwargs()
billing_address_data = self.request.session.get('billing_address_data') # if user is signed in, get billing address
if billing_address_data: if self.request.user.is_authenticated():
form_kwargs.update({ form_kwargs.update({
'initial': { 'instance': self.request.user.billing_addresses.first()
'cardholder_name': billing_address_data['cardholder_name'],
'street_address': billing_address_data['street_address'],
'city': billing_address_data['city'],
'postal_code': billing_address_data['postal_code'],
'country': billing_address_data['country'],
}
}) })
return form_kwargs return form_kwargs
@ -428,46 +402,75 @@ class PaymentOrderView(FormView):
context = super(PaymentOrderView, self).get_context_data(**kwargs) context = super(PaymentOrderView, self).get_context_data(**kwargs)
context.update({ context.update({
'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'stripe_key': settings.STRIPE_API_PUBLIC_KEY,
'site_url': reverse('datacenterlight:index') 'site_url': reverse('datacenterlight:index'),
'login_form': HostingUserLoginForm()
}) })
return context return context
@cache_control(no_cache=True, must_revalidate=True, no_store=True) @cache_control(no_cache=True, must_revalidate=True, no_store=True)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if 'specs' not in request.session or 'user' not in request.session: # user is no longer added to session on the index page
if 'specs' not in request.session:
return HttpResponseRedirect(reverse('datacenterlight:index')) return HttpResponseRedirect(reverse('datacenterlight:index'))
return self.render_to_response(self.get_context_data()) return self.render_to_response(self.get_context_data())
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.get_form() form = self.get_form()
if form.is_valid(): if form.is_valid():
# Get billing address data
billing_address_data = form.cleaned_data
token = form.cleaned_data.get('token') token = form.cleaned_data.get('token')
user = request.session.get('user') if request.user.is_authenticated():
try: this_user = {
CustomUser.objects.get(email=user.get('email')) 'email': request.user.email,
except CustomUser.DoesNotExist: 'name': request.user.name
password = CustomUser.get_random_password() }
# Register the user, and do not send emails custom_user = request.user
CustomUser.register(user.get('name'), else:
password, this_user = {
user.get('email'), 'email': form.cleaned_data.get('email'),
app='dcl', 'name': form.cleaned_data.get('name')
base_url=None, send_email=False) }
try:
custom_user = CustomUser.objects.get(
email=this_user.get('email'))
except CustomUser.DoesNotExist:
password = CustomUser.get_random_password()
# Register the user, and do not send emails
custom_user = CustomUser.register(
this_user.get('name'), password,
this_user.get('email'),
app='dcl', base_url=None, send_email=False
)
new_user = authenticate(
username=custom_user.email,
password=password)
login(request, new_user)
else:
# new user used the email of existing user, fail
messages.error(
self.request,
_('Another user exists with that email!'),
extra_tags='duplicate_email'
)
return HttpResponseRedirect(
reverse('datacenterlight:payment'))
billing_address_data = form.cleaned_data
billing_address_data.update({
'user': custom_user.id
})
billing_address_user_form = UserBillingAddressForm(
instance=custom_user.billing_addresses.first(),
data=billing_address_data)
billing_address_user_form.save()
request.session['user'] = this_user
# Get or create stripe customer # Get or create stripe customer
customer = StripeCustomer.get_or_create(email=user.get('email'), customer = StripeCustomer.get_or_create(
token=token) email=this_user.get('email'),
token=token)
if not customer: if not customer:
form.add_error("__all__", "Invalid credit card") form.add_error("__all__", "Invalid credit card")
return self.render_to_response( return self.render_to_response(
self.get_context_data(form=form)) self.get_context_data(form=form))
# Create Billing Address
billing_address = form.save()
request.session['billing_address_data'] = billing_address_data
request.session['billing_address'] = billing_address.id
request.session['token'] = token request.session['token'] = token
request.session['customer'] = customer.id request.session['customer'] = customer.id
return HttpResponseRedirect( return HttpResponseRedirect(
@ -513,8 +516,8 @@ class OrderConfirmationView(DetailView):
user = request.session.get('user') user = request.session.get('user')
stripe_customer_id = request.session.get('customer') stripe_customer_id = request.session.get('customer')
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
billing_address_data = request.session.get('billing_address_data') billing_address_data = {}
billing_address_id = request.session.get('billing_address') billing_address_id = request.user.billing_addresses.first().id
vm_template_id = template.get('id', 1) vm_template_id = template.get('id', 1)
# Make stripe charge to a customer # Make stripe charge to a customer

View file

@ -265,7 +265,7 @@ msgstr ""
"Link klickst</a>.<br/>\n" "Link klickst</a>.<br/>\n"
msgid "My VM page" msgid "My VM page"
msgstr "" msgstr "Meine VM page"
#, python-format #, python-format
msgid "" msgid ""
@ -286,10 +286,10 @@ msgstr ""
"%(base_url)s%(my_virtual_machines_url)s\n" "%(base_url)s%(my_virtual_machines_url)s\n"
msgid "Toggle navigation" msgid "Toggle navigation"
msgstr "Konfiguration" msgstr "Umschalten"
msgid "Dashboard" msgid "Dashboard"
msgstr "Mein Dashboard" msgstr "Dashboard"
msgid "Logout" msgid "Logout"
msgstr "Abmelden" msgstr "Abmelden"
@ -598,7 +598,7 @@ msgid "View Detail"
msgstr "Details anzeigen" msgstr "Details anzeigen"
msgid "login" msgid "login"
msgstr "Einloggen" msgstr "anmelden"
msgid "" msgid ""
"Thank you for signing up. We have sent an email to you. Please follow the " "Thank you for signing up. We have sent an email to you. Please follow the "

View file

@ -586,7 +586,7 @@ a.unlink:hover {
} }
.dcl-order-table-total .tbl-total { .dcl-order-table-total .tbl-total {
text-align: center; text-align: right;
color: #000; color: #000;
padding-left: 44px; padding-left: 44px;
} }
@ -614,8 +614,8 @@ a.unlink:hover {
font-weight: 300; font-weight: 300;
border: 1px solid #a1a1a1; border: 1px solid #a1a1a1;
border-radius: 3px; border-radius: 3px;
padding: 5px; padding: 8px 10px;
margin-bottom: 15px; margin-bottom: 20px;
} }
.card-warning-error { .card-warning-error {
border: 1px solid #EB4D5C; border: 1px solid #EB4D5C;
@ -656,7 +656,7 @@ a.unlink:hover {
.card-element { .card-element {
margin-bottom: 10px; margin-bottom: 10px;
padding: 0; /* padding: 0; */
} }
.card-element label{ .card-element label{
@ -674,12 +674,12 @@ a.unlink:hover {
#card-errors { #card-errors {
clear: both; clear: both;
padding: 0 0 10px; padding: 0 5px 10px;
color: #eb4d5c; color: #eb4d5c;
} }
.credit-card-goup{ .credit-card-goup{
padding: 0; padding: 0 5px;
} }
.order-confirm-date{ .order-confirm-date{
@ -854,6 +854,8 @@ a.list-group-item-danger:focus,
color: #eb4d5c; color: #eb4d5c;
} }
.has-error .form-control, .has-error .form-control,
.has-error .form-control:focus,
.has-error .form-control:active,
.has-error .input-group-addon { .has-error .input-group-addon {
color: #eb4d5c; color: #eb4d5c;
border-color: #eb4d5c; border-color: #eb4d5c;
@ -867,3 +869,11 @@ a.list-group-item-danger.active:focus {
.panel-danger > .panel-heading .badge { .panel-danger > .panel-heading .badge {
background-color: #eb4d5c; background-color: #eb4d5c;
} }
/* bootstrap input box-shadom disable */
.has-error .form-control:focus,
.has-error .form-control:active,
.has-success .form-control:focus,
.has-success .form-control:active {
box-shadow: inset 0 0 1px rgba(0,0,0,0.25);
}

View file

@ -22,7 +22,100 @@
} }
.summary-box .content { .summary-box .content {
padding-top: 15px; padding-top: 15px;
}
/* landing page payment new style */
.last-p {
margin-bottom: 0;
}
.dcl-payment-section {
max-width: 391px;
margin: 0 auto 30px;
padding: 0 10px 30px;
border-bottom: 1px solid #edebeb;
height: 100%;
}
.dcl-payment-section hr{
margin-top: 15px;
margin-bottom: 15px;
}
.dcl-payment-section .top-hr {
margin-left: -10px;
}
.dcl-payment-section h3 {
font-weight: 600;
}
.dcl-payment-section p {
padding: 0 5px;
font-weight: 400;
}
.dcl-payment-section .card-warning-content {
padding: 8px 10px;
font-weight: 300;
}
.dcl-payment-order strong{
font-size: 17px;
}
.dcl-payment-order p {
font-weight: 300;
}
.dcl-payment-section .form-group {
margin-bottom: 10px;
}
.dcl-payment-section .form-control {
box-shadow: none;
padding: 6px 12px;
height: 32px;
}
.dcl-payment-user {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.dcl-payment-user h4 {
font-weight: 600;
padding-left: 5px;
font-size: 17px;
}
@media (min-width: 768px) {
.dcl-payment-grid {
display: flex;
align-items: stretch;
flex-wrap: wrap;
}
.dcl-payment-box {
width: 50%;
position: relative;
padding: 0 30px;
}
.dcl-payment-box:nth-child(2) {
order: 1;
}
.dcl-payment-box:nth-child(4) {
order: 2;
}
.dcl-payment-section {
padding: 15px 10px;
margin-bottom: 0;
border-bottom-width: 5px;
}
.dcl-payment-box:nth-child(2n) .dcl-payment-section {
border-bottom: none;
}
.dcl-payment-box:nth-child(1):after,
.dcl-payment-box:nth-child(2):after {
content: ' ';
display: block;
background: #eee;
width: 1px;
position: absolute;
right: 0;
z-index: 2;
top: 20px;
bottom: 20px;
}
} }

View file

@ -113,6 +113,12 @@ class BillingAddressForm(forms.ModelForm):
} }
class BillingAddressFormSignup(BillingAddressForm):
name = forms.CharField(label=_('Name'))
email = forms.EmailField(label=_('Email Address'))
field_order = ['name', 'email']
class UserBillingAddressForm(forms.ModelForm): class UserBillingAddressForm(forms.ModelForm):
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(), user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
widget=forms.HiddenInput()) widget=forms.HiddenInput())