merge master
This commit is contained in:
commit
c60d45c292
24 changed files with 561 additions and 314 deletions
|
|
@ -126,56 +126,42 @@ msgstr ""
|
|||
msgid "Thank you!"
|
||||
msgstr "Vielen Dank!"
|
||||
|
||||
msgid "Account Activation"
|
||||
msgstr "Account Aktivierung"
|
||||
msgid "Data Center Light Account Activation"
|
||||
msgstr "Data Center Light Account Aktivierung"
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
"You can activate your Data Center Light account by <a href=\"%(base_url)s"
|
||||
"%(activation_link)s\">clicking here</a>.<br/>\n"
|
||||
"You can activate your Data Center Light account by clicking <a href="
|
||||
"\"%(base_url)s%(activation_link)s\" style=\"text-decoration: none; color: "
|
||||
"#4382c8; font-weight: 400;\">here</a>."
|
||||
msgstr ""
|
||||
"Klicke <a href=\"%(base_url)s%(activation_link)s\"style=\"text-decoration: "
|
||||
"none; color: #4382c8; font-weight: 400;\">here</a> um deinen Data Center "
|
||||
"Light Account zu aktivieren."
|
||||
|
||||
msgid ""
|
||||
"You can also copy and paste the following link into the address bar of your "
|
||||
"browser<br/>\n"
|
||||
"to activate your Data Center Light account.<br/>\n"
|
||||
"%(base_url)s%(activation_link)s\n"
|
||||
msgstr ""
|
||||
"\n"
|
||||
"<a href=\"%(base_url)s%(activation_link)s\">Klicke hier</a> um deinen Data "
|
||||
"Center Light Account zu aktivieren oder kopiere den folgenden Link in die "
|
||||
"Adressleiste deines Browsers.<br/>\n"
|
||||
"%(base_url)s%(activation_link)s\n"
|
||||
"browser to activate your Data Center Light account."
|
||||
msgstr "Kopiere den folgenden Link in die Adressleiste deines Browsers."
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Your account details are as follows:<br/><br/>\n"
|
||||
"Username : Your email address<br/>\n"
|
||||
"Password : %(account_details)s<br/><br/>\n"
|
||||
"You can reset your password here:\n"
|
||||
"%(base_url)s%(reset_password_url)s\n"
|
||||
msgstr ""
|
||||
"You can copy and paste the following link into the address bar of your "
|
||||
"browser to activate your Data Center Light account."
|
||||
msgstr "Kopiere den folgenden Link in die Adressleiste deines Browsers."
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"You can activate your Data Center Light account by clicking here.\n"
|
||||
"You can also copy and paste the following link into the address bar of your "
|
||||
"browser\n"
|
||||
"to activate your Data Center Light account.\n"
|
||||
"%(base_url)s%(activation_link)s\n"
|
||||
msgstr ""
|
||||
"Klicke hier, um deinen Data Center Light Account zu aktivieren oder kopiere "
|
||||
"den folgenden Link in die Adressleiste deines Browsers.\n"
|
||||
"%(base_url)s%(activation_link)s\n"
|
||||
msgid "Welcome to Data Center Light!"
|
||||
msgstr "Willkommen beim Data Center Light!"
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Your account details are as follows:\n"
|
||||
"\n"
|
||||
"Username : Your email address\n"
|
||||
"Password : %(account_details)s\n"
|
||||
"\n"
|
||||
"You can reset your password here:\n"
|
||||
"%(base_url)s%(reset_password_url)s\n"
|
||||
msgstr ""
|
||||
"Thanks for joining us! We provide the most affordable virtual machines from "
|
||||
"the heart of Switzerland."
|
||||
msgstr "Bei uns findest Du die günstiges VMs aus der Schweiz."
|
||||
|
||||
msgid "Try now, order a VM. VM price starts from only 15CHF per month."
|
||||
msgstr "Unser Angebot beginnt bei 15 CHF pro Monat. Probier's jetzt aus!"
|
||||
|
||||
msgid "ORDER VM"
|
||||
msgstr "VM BESTELLEN"
|
||||
|
||||
msgid "Home"
|
||||
msgstr "Home"
|
||||
|
|
@ -512,6 +498,15 @@ msgstr ""
|
|||
"Deine VM ist gleich bereit. Wir senden Dir eine Bestätigungsemail, sobald Du "
|
||||
"auf sie zugreifen kannst."
|
||||
|
||||
#~ msgid "Processing..."
|
||||
#~ msgstr "Abarbeitung..."
|
||||
|
||||
#~ msgid "Hold tight, we are processing your request"
|
||||
#~ msgstr "Bitte warten - wir verbeiten Deine Anfrage gerade"
|
||||
|
||||
#~ msgid "Some problem encountered. Please try again later."
|
||||
#~ msgstr "Ein Problem ist aufgetreten. Bitte versuche es später noch einmal."
|
||||
|
||||
#~ msgid "Submit"
|
||||
#~ msgstr "Absenden"
|
||||
|
||||
|
|
@ -530,15 +525,6 @@ msgstr ""
|
|||
#~ msgid "Order summary"
|
||||
#~ msgstr "Bestellungsübersicht"
|
||||
|
||||
#~ msgid "Processing..."
|
||||
#~ msgstr "Abarbeitung..."
|
||||
|
||||
#~ msgid "Hold tight, we are processing your request"
|
||||
#~ msgstr "Bitte warten - wir verbeiten Deine Anfrage gerade"
|
||||
|
||||
#~ msgid "Some problem encountered. Please try again later."
|
||||
#~ msgstr "Ein Problem ist aufgetreten. Bitte versuche es später noch einmal."
|
||||
|
||||
#~ msgid "We are cutting down the costs significantly!"
|
||||
#~ msgstr "Wir sorgen dafür, dass die Kosten für Dich signifikant abnehmen"
|
||||
|
||||
|
|
|
|||
BIN
datacenterlight/static/datacenterlight/img/logo_black.png
Normal file
BIN
datacenterlight/static/datacenterlight/img/logo_black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
|
|
@ -5,6 +5,7 @@ from celery.utils.log import get_task_logger
|
|||
from celery import current_task
|
||||
from django.conf import settings
|
||||
from django.core.mail import EmailMessage
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils import translation
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
|
@ -131,9 +132,9 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
'storage': specs.get('disk_size'),
|
||||
'price': specs.get('price'),
|
||||
'template': template.get('name'),
|
||||
'vm.name': vm['name'],
|
||||
'vm.id': vm['vm_id'],
|
||||
'order.id': order.id
|
||||
'vm_name': vm.get('name'),
|
||||
'vm_id': vm['vm_id'],
|
||||
'order_id': order.id
|
||||
}
|
||||
email_data = {
|
||||
'subject': settings.DCL_TEXT + " Order from %s" % context['email'],
|
||||
|
|
@ -155,13 +156,14 @@ def create_vm_task(self, vm_template_id, user, specs, template,
|
|||
translation.activate(lang)
|
||||
# Send notification to the user as soon as VM has been booked
|
||||
context = {
|
||||
'vm': vm,
|
||||
'order': order,
|
||||
'base_url': "{0}://{1}".format(user.get('request_scheme'),
|
||||
user.get('request_host')),
|
||||
'order_url': reverse('hosting:orders',
|
||||
kwargs={'pk': order.id}),
|
||||
'page_header': _(
|
||||
'Your New VM %(vm_name)s at Data Center Light') % {
|
||||
'vm_name': vm.get('name')}
|
||||
'vm_name': vm.get('name')},
|
||||
'vm_name': vm.get('name')
|
||||
}
|
||||
email_data = {
|
||||
'subject': context.get('page_header'),
|
||||
|
|
|
|||
|
|
@ -1,24 +1,46 @@
|
|||
{% extends "datacenterlight/emails/base_email_datacenterlight.html" %}
|
||||
{% load static from staticfiles %}
|
||||
{% load i18n %}
|
||||
{% block email_head %}
|
||||
{{dcl_text}} {% trans 'Account Activation' %}
|
||||
{% endblock %}
|
||||
{% block email_body %}
|
||||
{% blocktrans %}
|
||||
You can activate your Data Center Light account by <a href="{{base_url}}{{activation_link}}">clicking here</a>.<br/>
|
||||
You can also copy and paste the following link into the address bar of your browser<br/>
|
||||
to activate your Data Center Light account.<br/>
|
||||
{{base_url}}{{activation_link}}
|
||||
{% endblocktrans %}
|
||||
{% if account_details %}
|
||||
{% url 'hosting:reset_password' as reset_password_url %}
|
||||
<br/><br/>
|
||||
{% blocktrans %}Your account details are as follows:<br/><br/>
|
||||
Username : Your email address<br/>
|
||||
Password : {{account_details}}<br/><br/>
|
||||
You can reset your password here:
|
||||
{{base_url}}{{reset_password_url}}
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% load static i18n %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% trans "Data Center Light Account Activation" %}</title>
|
||||
<link rel="shortcut icon" href="{{ base_url }}{% static 'datacenterlight/img/favicon.ico' %}" type="image/x-icon">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,400">
|
||||
</head>
|
||||
|
||||
<body style="margin: 0; padding: 20px 0;">
|
||||
<table style="width: 100%; border-spacing: 0; border-collapse: collapse; max-width: 560px;">
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ base_url }}{% static 'datacenterlight/img/logo_black.png' %}" style="width: 200px; height: 50px;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 15px;">
|
||||
<h1 style="font-family: Lato, Arial, sans-serif; font-size: 25px; font-weight: 400; margin: 0;">{% trans "Data Center Light Account Activation" %}</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 25px; font-size: 16px;">
|
||||
<p style="line-height: 1.75; font-family: Lato, Arial, sans-serif; font-weight: 300; margin-bottom: 10px; margin-top: 0;">
|
||||
{% blocktrans %}You can activate your Data Center Light account by clicking <a href="{{base_url}}{{activation_link}}" style="text-decoration: none; color: #4382c8; font-weight: 400;">here</a>.{% endblocktrans %}
|
||||
</p>
|
||||
<p style="line-height: 1.75; font-family: Lato, Arial, sans-serif; font-weight: 300; margin-bottom: 10px; margin-top: 0;">
|
||||
{% blocktrans %}You can also copy and paste the following link into the address bar of your browser to activate your Data Center Light account.{% endblocktrans %}
|
||||
</p>
|
||||
<p style="color: #4382c8; line-height: 1.4; font-family: Lato, Arial, sans-serif; font-weight: 300; margin: 0;">
|
||||
{{base_url}}{{activation_link}}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 40px; padding-bottom: 25px;">
|
||||
<h3 style="font-family: Lato, Arial, sans-serif; margin: 0; font-weight: 400; font-size: 15px;">{% trans "Your Data Center Light Team" %}</h3>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
{% extends "datacenterlight/emails/base_email_datacenterlight.txt" %}
|
||||
{% load i18n %}
|
||||
{% block email_head %}{{dcl_text}} {% trans 'Account Activation' %}{% endblock %}
|
||||
{% block email_body %}
|
||||
{% blocktrans %}You can activate your Data Center Light account by clicking here.
|
||||
You can also copy and paste the following link into the address bar of your browser
|
||||
to activate your Data Center Light account.
|
||||
|
||||
{% trans "Data Center Light Account Activation" %}
|
||||
|
||||
{% blocktrans %}You can copy and paste the following link into the address bar of your browser to activate your Data Center Light account.{% endblocktrans %}
|
||||
|
||||
{{base_url}}{{activation_link}}
|
||||
{% endblocktrans %}
|
||||
{% if account_details %}
|
||||
{% url 'hosting:reset_password' as reset_password_url %}
|
||||
{% blocktrans %}Your account details are as follows:
|
||||
|
||||
Username : Your email address
|
||||
Password : {{account_details}}
|
||||
|
||||
You can reset your password here:
|
||||
{{base_url}}{{reset_password_url}}
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% trans "Your Data Center Light Team" %}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
{% load static i18n %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% trans "Welcome to Data Center Light!" %}</title>
|
||||
<link rel="shortcut icon" href="{{ base_url }}{% static 'datacenterlight/img/favicon.ico' %}" type="image/x-icon">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,400">
|
||||
</head>
|
||||
|
||||
<body style="margin: 0; padding: 20px 0;">
|
||||
<table style="width: 100%; border-spacing: 0; border-collapse: collapse; max-width: 560px;">
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ base_url }}{% static 'datacenterlight/img/logo_black.png' %}" style="width: 200px; height: 50px;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 15px;">
|
||||
<h1 style="font-family: Lato, Arial, sans-serif; font-size: 25px; font-weight: 400; margin: 0;">{% trans "Welcome to Data Center Light!" %}</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 25px; font-size: 16px;">
|
||||
<p style="line-height: 1.75; font-family: Lato, Arial, sans-serif; font-weight: 300; margin: 0;">
|
||||
{% blocktrans %}Thanks for joining us! We provide the most affordable virtual machines from the heart of Switzerland.{% endblocktrans %}
|
||||
</p>
|
||||
<p style="line-height: 1.75; font-family: Lato, Arial, sans-serif; font-weight: 300; margin: 0;">
|
||||
{% blocktrans %}Try now, order a VM. VM price starts from only 15CHF per month.{% endblocktrans %}
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 30px;">
|
||||
<a class="btn" href="{{ base_url }}{% url 'hosting:create_virtual_machine' %}" style="font-family: Lato, Arial, sans-serif; text-decoration: none; background-color: #1596da; color: #fff; padding-top: 10px; padding-bottom: 10px; padding-left: 30px; padding-right: 30px; letter-spacing: 0.5px; border-radius: 3px; display: inline-block;">{% trans "ORDER VM" %}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-top: 40px; padding-bottom: 25px;">
|
||||
<h3 style="font-family: Lato, Arial, sans-serif; margin: 0; font-weight: 400; font-size: 15px;">{% trans "Your Data Center Light Team" %}</h3>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% trans "Welcome to Data Center Light!" %}
|
||||
|
||||
{% blocktrans %}Thanks for joining us! We provide the most affordable virtual machines from the heart of Switzerland.{% endblocktrans %}
|
||||
{% blocktrans %}Try now, order a VM. VM price starts from only 15CHF per month.{% endblocktrans %}
|
||||
|
||||
{{ base_url }}{% url 'hosting:create_virtual_machine' %}
|
||||
|
||||
{% trans "Your Data Center Light Team" %}
|
||||
|
|
@ -25,14 +25,15 @@
|
|||
<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>
|
||||
<form role="form" id="login-form" method="post" action="" novalidate>
|
||||
{% for field in login_form %}
|
||||
{% csrf_token %}
|
||||
{% bootstrap_field field show_label=False type='fields'%}
|
||||
{% endfor %}
|
||||
<p class="text-danger">{{login_form.non_field_errors|striptags}}</p>
|
||||
<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>
|
||||
<button type="submit" class="btn btn-wide btn-vm-contact" name="login_form">{% trans "LOGIN" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
<p>
|
||||
|
|
@ -58,7 +59,7 @@
|
|||
{% endfor %}
|
||||
<form role="form" id="billing-form" method="post" action="" novalidate>
|
||||
{% csrf_token %}
|
||||
{% for field in form %}
|
||||
{% for field in billing_address_form %}
|
||||
{% bootstrap_field field show_label=False type='fields'%}
|
||||
{% endfor %}
|
||||
</form>
|
||||
|
|
@ -153,22 +154,12 @@
|
|||
{% endif %}
|
||||
<div id='payment_error'>
|
||||
{% for message in messages %}
|
||||
{% if 'failed_payment' in message.tags or 'make_charge_error' in message.tags %}
|
||||
{% if 'failed_payment' in message.tags or 'make_charge_error' in message.tags or '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">
|
||||
{% trans "You are not making any payment yet. After placing your order, you will be taken to the Submit Payment Page." %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for error in form.non_field_errors %}
|
||||
<p class="card-warning-content card-warning-error">
|
||||
{{ error|escape }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<button class="btn btn-vm-contact btn-wide" type="submit">{%trans "SUBMIT" %}</button>
|
||||
|
|
|
|||
|
|
@ -345,26 +345,45 @@ class PaymentOrderView(FormView):
|
|||
else:
|
||||
return BillingAddressFormSignup
|
||||
|
||||
def get_form_kwargs(self):
|
||||
form_kwargs = super(PaymentOrderView, self).get_form_kwargs()
|
||||
# if user is signed in, get billing address
|
||||
if self.request.user.is_authenticated():
|
||||
form_kwargs.update({
|
||||
'instance': self.request.user.billing_addresses.first()
|
||||
})
|
||||
if 'billing_address_data' in self.request.session:
|
||||
billing_address_data = self.request.session['billing_address_data']
|
||||
form_kwargs.update({
|
||||
'initial': billing_address_data
|
||||
})
|
||||
return form_kwargs
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(PaymentOrderView, self).get_context_data(**kwargs)
|
||||
if 'billing_address_data' in self.request.session:
|
||||
billing_address_data = self.request.session['billing_address_data']
|
||||
else:
|
||||
billing_address_data = {}
|
||||
|
||||
if self.request.user.is_authenticated():
|
||||
if billing_address_data:
|
||||
billing_address_form = BillingAddressForm(
|
||||
initial=billing_address_data
|
||||
)
|
||||
else:
|
||||
billing_address_form = BillingAddressForm(
|
||||
instance=self.request.user.billing_addresses.first()
|
||||
)
|
||||
# Get user last order
|
||||
last_hosting_order = HostingOrder.objects.filter(
|
||||
customer__user=self.request.user
|
||||
).last()
|
||||
|
||||
# If user has already an hosting order, get the credit card
|
||||
# data from it
|
||||
if last_hosting_order:
|
||||
credit_card_data = last_hosting_order.get_cc_data()
|
||||
if credit_card_data:
|
||||
context['credit_card_data'] = credit_card_data
|
||||
else:
|
||||
context['credit_card_data'] = None
|
||||
else:
|
||||
billing_address_form = BillingAddressFormSignup(
|
||||
initial=billing_address_data
|
||||
)
|
||||
|
||||
context.update({
|
||||
'stripe_key': settings.STRIPE_API_PUBLIC_KEY,
|
||||
'site_url': reverse('datacenterlight:index'),
|
||||
'login_form': HostingUserLoginForm()
|
||||
'login_form': HostingUserLoginForm(prefix='login_form'),
|
||||
'billing_address_form': billing_address_form
|
||||
})
|
||||
return context
|
||||
|
||||
|
|
@ -376,9 +395,32 @@ class PaymentOrderView(FormView):
|
|||
return self.render_to_response(self.get_context_data())
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = self.get_form()
|
||||
if form.is_valid():
|
||||
token = form.cleaned_data.get('token')
|
||||
if 'login_form' in request.POST:
|
||||
login_form = HostingUserLoginForm(data=request.POST,
|
||||
prefix='login_form')
|
||||
if login_form.is_valid():
|
||||
email = login_form.cleaned_data.get('email')
|
||||
password = login_form.cleaned_data.get('password')
|
||||
auth_user = authenticate(email=email, password=password)
|
||||
if auth_user:
|
||||
login(self.request, auth_user)
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:payment')
|
||||
)
|
||||
else:
|
||||
context = self.get_context_data()
|
||||
context['login_form'] = login_form
|
||||
return self.render_to_response(context)
|
||||
if request.user.is_authenticated():
|
||||
address_form = BillingAddressForm(
|
||||
data=request.POST,
|
||||
)
|
||||
else:
|
||||
address_form = BillingAddressFormSignup(
|
||||
data=request.POST,
|
||||
)
|
||||
if address_form.is_valid():
|
||||
token = address_form.cleaned_data.get('token')
|
||||
if request.user.is_authenticated():
|
||||
this_user = {
|
||||
'email': request.user.email,
|
||||
|
|
@ -388,8 +430,8 @@ class PaymentOrderView(FormView):
|
|||
email=this_user.get('email'),
|
||||
token=token)
|
||||
else:
|
||||
user_email = form.cleaned_data.get('email')
|
||||
user_name = form.cleaned_data.get('name')
|
||||
user_email = address_form.cleaned_data.get('email')
|
||||
user_name = address_form.cleaned_data.get('name')
|
||||
this_user = {
|
||||
'email': user_email,
|
||||
'name': user_name
|
||||
|
|
@ -422,13 +464,18 @@ class PaymentOrderView(FormView):
|
|||
token=token,
|
||||
customer_name=user_name)
|
||||
|
||||
request.session['billing_address_data'] = form.cleaned_data
|
||||
request.session['billing_address_data'] = address_form.cleaned_data
|
||||
request.session['user'] = this_user
|
||||
# Get or create stripe customer
|
||||
if not customer:
|
||||
form.add_error("__all__", "Invalid credit card")
|
||||
address_form.add_error(
|
||||
"__all__", "Invalid credit card"
|
||||
)
|
||||
return self.render_to_response(
|
||||
self.get_context_data(form=form))
|
||||
self.get_context_data(
|
||||
billing_address_form=address_form
|
||||
)
|
||||
)
|
||||
request.session['token'] = token
|
||||
if type(customer) is StripeCustomer:
|
||||
request.session['customer'] = customer.stripe_id
|
||||
|
|
@ -437,7 +484,9 @@ class PaymentOrderView(FormView):
|
|||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:order_confirmation'))
|
||||
else:
|
||||
return self.form_invalid(form)
|
||||
context = self.get_context_data()
|
||||
context['billing_address_form'] = address_form
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class OrderConfirmationView(DetailView):
|
||||
|
|
@ -548,9 +597,13 @@ class OrderConfirmationView(DetailView):
|
|||
try:
|
||||
custom_user = CustomUser.objects.get(
|
||||
email=user.get('email'))
|
||||
customer = StripeCustomer.objects.filter(
|
||||
stripe_customer = StripeCustomer.objects.filter(
|
||||
user_id=custom_user.id).first()
|
||||
stripe_customer_id = customer.id
|
||||
if stripe_customer is None:
|
||||
stripe_customer = StripeCustomer.objects.create(
|
||||
user=custom_user, stripe_id=stripe_api_cus_id
|
||||
)
|
||||
stripe_customer_id = stripe_customer.id
|
||||
except CustomUser.DoesNotExist:
|
||||
logger.debug(
|
||||
"Customer {} does not exist.".format(user.get('email')))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue