merged master
This commit is contained in:
commit
7b71ba1749
39 changed files with 1484 additions and 1704 deletions
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-10-03 23:48+0530\n"
|
||||
"POT-Creation-Date: 2017-10-10 21:35+0530\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ button, input, optgroup, select, textarea {
|
|||
display: block;
|
||||
} */
|
||||
.intro-header {
|
||||
height: 100vh;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
background: url(../img/configure.jpg) no-repeat center center;
|
||||
|
|
@ -715,9 +715,10 @@ button, input, optgroup, select, textarea {
|
|||
font-size: 65px;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
/* color: #eee;
|
||||
/* color: #eee;
|
||||
padding-bottom: 25px;
|
||||
text-align: right; */
|
||||
/* color: #fff; */
|
||||
}
|
||||
|
||||
.contact-form .form-group {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<!-- Custom Fonts -->
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="{% static 'datacenterlight/font-awesome/css/font-awesome.min.css' %}" rel="stylesheet" type="text/css">
|
||||
<link href="//fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
|
||||
<link rel="shortcut icon" href="{% static 'datacenterlight/img/favicon.ico' %}" type="image/x-icon" />
|
||||
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
<!-- Custom CSS -->
|
||||
<link href="{% static 'datacenterlight/css/landing-page.css' %}" rel="stylesheet">
|
||||
{% block css_extra %}
|
||||
{% endblock css_extra %}
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
|
|
@ -42,7 +44,9 @@
|
|||
|
||||
<body>
|
||||
<!-- Navigation -->
|
||||
{% include "datacenterlight/includes/_navbar.html" %}
|
||||
{% block navbar %}
|
||||
{% include "datacenterlight/includes/_navbar.html" %}
|
||||
{% endblock navbar %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ from .views import (
|
|||
WhyDataCenterLightView, ContactUsView
|
||||
)
|
||||
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
|
|
@ -23,4 +25,8 @@ urlpatterns = [
|
|||
url(r'^order-success/?$', SuccessView.as_view(), name='order_success'),
|
||||
url(r'^beta_access?$', BetaAccessView.as_view(), name='beta_access'),
|
||||
url(r'^contact/?$', ContactUsView.as_view(), name='contact_us'),
|
||||
|
||||
url(r'glasfaser/?$',
|
||||
TemplateView.as_view(template_name='ungleich_page/glasfaser.html'),
|
||||
name='glasfaser'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -49,13 +49,17 @@ class ContactUsView(FormView):
|
|||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
from_emails = {
|
||||
'glasfaser': 'glasfaser@ungleich.ch'
|
||||
}
|
||||
from_page = self.request.POST.get('from_page')
|
||||
email_data = {
|
||||
'subject': "{dcl_text} Message from {sender}".format(
|
||||
dcl_text=settings.DCL_TEXT,
|
||||
sender=form.cleaned_data.get('email')
|
||||
),
|
||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||
'to': ['info@ungleich.ch'],
|
||||
'to': [from_emails.get(from_page, 'info@ungleich.ch')],
|
||||
'body': "\n".join(
|
||||
["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
|
||||
'reply_to': [form.cleaned_data.get('email')],
|
||||
|
|
@ -341,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
|
||||
|
||||
|
|
@ -372,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,
|
||||
|
|
@ -384,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
|
||||
|
|
@ -418,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
|
||||
|
|
@ -433,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):
|
||||
|
|
@ -544,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