Merge branch 'master' into feature/6561/invoices-webhook
This commit is contained in:
commit
8300babead
23 changed files with 434 additions and 252 deletions
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-26 20:44+0000\n"
|
||||
"POT-Creation-Date: 2019-07-03 11:18+0000\n"
|
||||
"PO-Revision-Date: 2018-03-30 23:22+0000\n"
|
||||
"Last-Translator: b'Anonymous User <coder.purple+25@gmail.com>'\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -26,6 +26,22 @@ msgstr ""
|
|||
msgid "Your New VM %(vm_name)s at Data Center Light"
|
||||
msgstr "Deine neue VM %(vm_name)s bei Data Center Light"
|
||||
|
||||
msgid "Your VM is almost ready!"
|
||||
msgstr "Deine VM ist fast fertig!"
|
||||
|
||||
msgid ""
|
||||
"You need to specify your public SSH key to access your VM. You can either "
|
||||
"add your existing key, or generate a new key pair by clicking the generate "
|
||||
"button below. After choosing your public SSH key option you’ll be directed "
|
||||
"to the order confirmation page."
|
||||
msgstr ""
|
||||
"Du musst deinen öffentlichen SSH-Schlüssel angeben, um auf deine VM "
|
||||
"zugreifen zu können. Du kannst entweder deinen vorhandenen Schlüssel "
|
||||
"hinzufügen oder ein neues Schlüsselpaar generieren, indem du auf die "
|
||||
"Schaltfläche \"Generieren\" unten klickst. Nachdem du deine öffentliche SSH-"
|
||||
"Schlüsseloption ausgewählt hast, wirst du zur Bestellbestätigungsseite "
|
||||
"weitergeleitet. "
|
||||
|
||||
msgid "All Rights Reserved"
|
||||
msgstr "Alle Rechte vorbehalten"
|
||||
|
||||
|
|
@ -134,6 +150,10 @@ msgstr "Unser Angebot beginnt bei 15 CHF pro Monat. Probier's jetzt aus!"
|
|||
msgid "ORDER VM"
|
||||
msgstr "VM BESTELLEN"
|
||||
|
||||
#, python-format
|
||||
msgid "Please enter a value in range %(min_ram)s - 200."
|
||||
msgstr "Bitte gib einen Wert von %(min_ram)s bis 200 ein."
|
||||
|
||||
msgid "VM hosting"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -152,9 +172,6 @@ msgstr "Standort: Schweiz"
|
|||
msgid "Please enter a value in range 1 - 48."
|
||||
msgstr "Bitte gib einen Wert von 1 bis 48 ein."
|
||||
|
||||
msgid "Please enter a value in range 1 - 200."
|
||||
msgstr "Bitte gib einen Wert von 1 bis 200 ein."
|
||||
|
||||
msgid "Please enter a value in range 10 - 2000."
|
||||
msgstr "Bitte gib einen Wert von 10 bis 2000 ein."
|
||||
|
||||
|
|
@ -413,6 +430,10 @@ msgstr "Zwischensumme"
|
|||
msgid "VAT"
|
||||
msgstr "Mehrwertsteuer"
|
||||
|
||||
#, fuzzy, python-format
|
||||
#| msgid ""
|
||||
#| "By clicking \"Place order\" this plan will charge your credit card "
|
||||
#| "account with %(total_price)s CHF/month"
|
||||
msgid ""
|
||||
"By clicking \"Place order\" this plan will charge your credit card account "
|
||||
"with %(total_price)s CHF/month"
|
||||
|
|
@ -420,6 +441,10 @@ msgstr ""
|
|||
"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit "
|
||||
"%(vm_total_price)s CHF pro Monat belastet"
|
||||
|
||||
#, fuzzy, python-format
|
||||
#| msgid ""
|
||||
#| "By clicking \"Place order\" this payment will charge your credit card "
|
||||
#| "account with a one time amount of %(total_price)s CHF"
|
||||
msgid ""
|
||||
"By clicking \"Place order\" this payment will charge your credit card "
|
||||
"account with a one time amount of %(total_price)s CHF"
|
||||
|
|
@ -535,6 +560,9 @@ msgstr "Tagen sagen mehr als Worte – Teste jetzt unsere VM!"
|
|||
msgid "Invalid number of cores"
|
||||
msgstr "Ungültige Anzahle CPU-Kerne"
|
||||
|
||||
msgid "Invalid calculator properties"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invalid RAM size"
|
||||
msgstr "Ungültige RAM-Grösse"
|
||||
|
||||
|
|
|
|||
|
|
@ -186,3 +186,8 @@ footer .dcl-link-separator::before {
|
|||
background: transparent !important;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.existing-keys-title {
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ 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 _
|
||||
from time import sleep
|
||||
|
||||
from dynamicweb.celery import app
|
||||
from hosting.models import HostingOrder
|
||||
|
|
@ -16,7 +15,7 @@ from membership.models import CustomUser
|
|||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineSerializer
|
||||
from utils.hosting_utils import (
|
||||
get_all_public_keys, get_or_create_vm_detail, ping_ok
|
||||
get_all_public_keys, get_or_create_vm_detail
|
||||
)
|
||||
from utils.mailer import BaseEmail
|
||||
from utils.stripe_utils import StripeUtils
|
||||
|
|
@ -79,10 +78,14 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id):
|
|||
# Create OpenNebulaManager
|
||||
manager = OpenNebulaManager(email=on_user, password=on_pass)
|
||||
|
||||
custom_user = CustomUser.objects.get(email=user.get('email'))
|
||||
pub_keys = get_all_public_keys(custom_user)
|
||||
if manager.email != settings.OPENNEBULA_USERNAME:
|
||||
manager.save_key_in_opennebula_user('\n'.join(pub_keys))
|
||||
vm_id = manager.create_vm(
|
||||
template_id=vm_template_id,
|
||||
specs=specs,
|
||||
ssh_key=settings.ONEADMIN_USER_SSH_PUBLIC_KEY,
|
||||
ssh_key='\n'.join(pub_keys),
|
||||
vm_name=vm_name
|
||||
)
|
||||
|
||||
|
|
@ -188,65 +191,9 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id):
|
|||
email = BaseEmail(**email_data)
|
||||
email.send()
|
||||
|
||||
# try to see if we have the IPv6 of the new vm and that if the ssh
|
||||
# keys can be configured
|
||||
vm_ipv6 = manager.get_ipv6(vm_id)
|
||||
logger.debug("New VM ID is {vm_id}".format(vm_id=vm_id))
|
||||
if vm_ipv6 is not None:
|
||||
custom_user = CustomUser.objects.get(email=user.get('email'))
|
||||
if vm_id > 0:
|
||||
get_or_create_vm_detail(custom_user, manager, vm_id)
|
||||
if custom_user is not None:
|
||||
public_keys = get_all_public_keys(custom_user)
|
||||
keys = [{'value': key, 'state': True} for key in
|
||||
public_keys]
|
||||
if len(keys) > 0:
|
||||
logger.debug(
|
||||
"Calling configure on {host} for "
|
||||
"{num_keys} keys".format(
|
||||
host=vm_ipv6, num_keys=len(keys)
|
||||
)
|
||||
)
|
||||
# Let's wait until the IP responds to ping before we
|
||||
# run the cdist configure on the host
|
||||
did_manage_public_key = False
|
||||
for i in range(0, 15):
|
||||
if ping_ok(vm_ipv6):
|
||||
logger.debug(
|
||||
"{} is pingable. Doing a "
|
||||
"manage_public_key".format(vm_ipv6)
|
||||
)
|
||||
sleep(10)
|
||||
manager.manage_public_key(
|
||||
keys, hosts=[vm_ipv6]
|
||||
)
|
||||
did_manage_public_key = True
|
||||
break
|
||||
else:
|
||||
logger.debug(
|
||||
"Can't ping {}. Wait 5 secs".format(
|
||||
vm_ipv6
|
||||
)
|
||||
)
|
||||
sleep(5)
|
||||
if not did_manage_public_key:
|
||||
emsg = ("Waited for over 75 seconds for {} to be "
|
||||
"pingable. But the VM was not reachable. "
|
||||
"So, gave up manage_public_key. Please do "
|
||||
"this manually".format(vm_ipv6))
|
||||
logger.error(emsg)
|
||||
email_data = {
|
||||
'subject': '{} CELERY TASK INCOMPLETE: {} not '
|
||||
'pingable for 75 seconds'.format(
|
||||
settings.DCL_TEXT, vm_ipv6
|
||||
),
|
||||
'from_email': current_task.request.hostname,
|
||||
'to': settings.DCL_ERROR_EMAILS_TO_LIST,
|
||||
'body': emsg
|
||||
}
|
||||
email = EmailMessage(**email_data)
|
||||
email.send()
|
||||
else:
|
||||
logger.debug("VM's ipv6 is None. Hence not created VMDetail")
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
try:
|
||||
|
|
|
|||
10
datacenterlight/templates/datacenterlight/add_ssh_key.html
Normal file
10
datacenterlight/templates/datacenterlight/add_ssh_key.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
{% load staticfiles bootstrap3 i18n custom_tags humanize %}
|
||||
|
||||
{% block content %}
|
||||
{% block userkey_form %}
|
||||
{% with form_title=_("Your VM is almost ready!") form_sub_title=_("You need to specify your public SSH key to access your VM. You can either add your existing key, or generate a new key pair by clicking the generate button below. After choosing your public SSH key option you’ll be directed to the order confirmation page.") %}
|
||||
{% include 'hosting/user_key.html' with title=form_title sub_title=form_sub_title %}
|
||||
{% endwith %}
|
||||
{% endblock userkey_form %}
|
||||
{%endblock%}
|
||||
|
|
@ -131,6 +131,7 @@
|
|||
<h5 class="billing-head">{% trans "Credit Card" %}</h5>
|
||||
<h5 class="membership-lead">{% trans "Last" %} 4: ***** {{card.last4}}</h5>
|
||||
<h5 class="membership-lead">{% trans "Type" %}: {{card.brand}}</h5>
|
||||
<h5 class="membership-lead">{% trans "Expiry" %}: {{card.exp_month}}/{{card.exp_year}}</h5>
|
||||
</div>
|
||||
<div class="col-xs-6 text-right align-bottom">
|
||||
<a class="btn choice-btn choice-btn-faded" href="#" data-id_card="{{card.id}}">{% trans "SELECT" %}</a>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
<h4>{% trans "Payment method" %}:</h4>
|
||||
<p>
|
||||
{{cc_brand|default:_('Credit Card')}} {% trans "ending in" %} ****{{cc_last4}}<br>
|
||||
{% trans "Expiry" %} {{cc_exp_year}}/{{cc_exp_month}}<br/>
|
||||
{{request.user.email}}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from django.conf.urls import url
|
||||
from django.views.generic import TemplateView, RedirectView
|
||||
|
||||
from utils.views import AskSSHKeyView
|
||||
from .views import (
|
||||
IndexView, PaymentOrderView, OrderConfirmationView,
|
||||
WhyDataCenterLightView, ContactUsView
|
||||
)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^t/$', IndexView.as_view(), name='index_t'),
|
||||
|
|
@ -20,6 +20,8 @@ urlpatterns = [
|
|||
url(r'^payment/?$', PaymentOrderView.as_view(), name='payment'),
|
||||
url(r'^order-confirmation/?$', OrderConfirmationView.as_view(),
|
||||
name='order_confirmation'),
|
||||
url(r'^add-ssh-key/?$', AskSSHKeyView.as_view(),
|
||||
name='add_ssh_key'),
|
||||
url(r'^contact/?$', ContactUsView.as_view(), name='contact_us'),
|
||||
url(r'glasfaser/?$',
|
||||
TemplateView.as_view(template_name='ungleich_page/glasfaser.html'),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import logging
|
||||
|
||||
import pyotp
|
||||
import requests
|
||||
from django.contrib.sites.models import Site
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
|
||||
from datacenterlight.tasks import create_vm_task
|
||||
from hosting.models import HostingOrder, HostingBill, OrderDetail
|
||||
|
|
@ -99,7 +100,8 @@ def clear_all_session_vars(request):
|
|||
for session_var in ['specs', 'template', 'billing_address',
|
||||
'billing_address_data', 'card_id',
|
||||
'token', 'customer', 'generic_payment_type',
|
||||
'generic_payment_details', 'product_id']:
|
||||
'generic_payment_details', 'product_id',
|
||||
'order_confirm_url', 'new_user_hosting_key_id']:
|
||||
if session_var in request.session:
|
||||
del request.session[session_var]
|
||||
|
||||
|
|
|
|||
|
|
@ -13,18 +13,20 @@ from django.views.decorators.cache import cache_control
|
|||
from django.views.generic import FormView, CreateView, DetailView
|
||||
|
||||
from hosting.forms import (
|
||||
HostingUserLoginForm, GenericPaymentForm, ProductPaymentForm
|
||||
HostingUserLoginForm, GenericPaymentForm, ProductPaymentForm,
|
||||
UserHostingKeyForm
|
||||
)
|
||||
from hosting.models import (
|
||||
HostingBill, HostingOrder, UserCardDetail, GenericProduct
|
||||
HostingBill, HostingOrder, UserCardDetail, GenericProduct, UserHostingKey
|
||||
)
|
||||
from membership.models import CustomUser, StripeCustomer
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VMTemplateSerializer
|
||||
from utils.forms import (
|
||||
BillingAddressForm, BillingAddressFormSignup, UserBillingAddressForm,
|
||||
BillingAddress
|
||||
)
|
||||
from utils.hosting_utils import get_vm_price_with_vat
|
||||
from utils.hosting_utils import get_vm_price_with_vat, get_all_public_keys
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from utils.tasks import send_plain_email_task
|
||||
from .cms_models import DCLCalculatorPluginModel
|
||||
|
|
@ -521,20 +523,34 @@ class PaymentOrderView(FormView):
|
|||
request.session['customer'] = customer.stripe_id
|
||||
else:
|
||||
request.session['customer'] = customer
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:order_confirmation'))
|
||||
|
||||
# For generic payment we take the user directly to confirmation
|
||||
if ('generic_payment_type' in request.session and
|
||||
self.request.session['generic_payment_type'] == 'generic'):
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:order_confirmation'))
|
||||
else:
|
||||
self.request.session['order_confirm_url'] = reverse('datacenterlight:order_confirmation')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:add_ssh_key'))
|
||||
else:
|
||||
context = self.get_context_data()
|
||||
context['billing_address_form'] = address_form
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class OrderConfirmationView(DetailView):
|
||||
class OrderConfirmationView(DetailView, FormView):
|
||||
form_class = UserHostingKeyForm
|
||||
template_name = "datacenterlight/order_detail.html"
|
||||
payment_template_name = 'datacenterlight/landing_payment.html'
|
||||
context_object_name = "order"
|
||||
model = HostingOrder
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(OrderConfirmationView, self).get_form_kwargs()
|
||||
kwargs.update({'request': self.request})
|
||||
return kwargs
|
||||
|
||||
@cache_control(no_cache=True, must_revalidate=True, no_store=True)
|
||||
def get(self, request, *args, **kwargs):
|
||||
context = {}
|
||||
|
|
@ -552,11 +568,15 @@ class OrderConfirmationView(DetailView):
|
|||
card_details_response = card_details['response_object']
|
||||
context['cc_last4'] = card_details_response['last4']
|
||||
context['cc_brand'] = card_details_response['brand']
|
||||
context['cc_exp_year'] = card_details_response['exp_year']
|
||||
context['cc_exp_month'] = '{:02d}'.format(card_details_response['exp_month'])
|
||||
else:
|
||||
card_id = self.request.session.get('card_id')
|
||||
card_detail = UserCardDetail.objects.get(id=card_id)
|
||||
context['cc_last4'] = card_detail.last4
|
||||
context['cc_brand'] = card_detail.brand
|
||||
context['cc_exp_year'] = card_detail.exp_year
|
||||
context['cc_exp_month'] ='{:02d}'.format(card_detail.exp_month)
|
||||
|
||||
if ('generic_payment_type' in request.session and
|
||||
self.request.session['generic_payment_type'] == 'generic'):
|
||||
|
|
@ -567,6 +587,8 @@ class OrderConfirmationView(DetailView):
|
|||
else:
|
||||
context.update({
|
||||
'vm': request.session.get('specs'),
|
||||
'form': UserHostingKeyForm(request=self.request),
|
||||
'keys': get_all_public_keys(self.request.user)
|
||||
})
|
||||
context.update({
|
||||
'site_url': reverse('datacenterlight:index'),
|
||||
|
|
@ -830,6 +852,18 @@ class OrderConfirmationView(DetailView):
|
|||
new_user = authenticate(username=custom_user.email,
|
||||
password=password)
|
||||
login(request, new_user)
|
||||
if 'new_user_hosting_key_id' in self.request.session:
|
||||
user_hosting_key = UserHostingKey.objects.get(id=self.request.session['new_user_hosting_key_id'])
|
||||
user_hosting_key.user = new_user
|
||||
user_hosting_key.save()
|
||||
|
||||
owner = new_user
|
||||
manager = OpenNebulaManager(
|
||||
email=owner.email,
|
||||
password=owner.password
|
||||
)
|
||||
keys_to_save = get_all_public_keys(new_user)
|
||||
manager.save_key_in_opennebula_user('\n'.join(keys_to_save))
|
||||
else:
|
||||
# We assume that if the user is here, his/her StripeCustomer
|
||||
# object already exists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue