Merge branch 'master' into feature/6561/invoices-webhook
This commit is contained in:
commit
8300babead
23 changed files with 417 additions and 235 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import datetime
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
import tempfile
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import authenticate
|
||||
|
|
@ -187,7 +187,8 @@ class UserHostingKeyForm(forms.ModelForm):
|
|||
alerts the user of it.
|
||||
:return:
|
||||
"""
|
||||
if 'generate' in self.request.POST:
|
||||
if ('generate' in self.request.POST
|
||||
or not self.fields['public_key'].required):
|
||||
return self.data.get('public_key')
|
||||
KEY_ERROR_MESSAGE = _("Please input a proper SSH key")
|
||||
openssh_pubkey_str = self.data.get('public_key').strip()
|
||||
|
|
@ -214,10 +215,14 @@ class UserHostingKeyForm(forms.ModelForm):
|
|||
return openssh_pubkey_str
|
||||
|
||||
def clean_name(self):
|
||||
INVALID_NAME_MESSAGE = _("Comma not accepted in the name of the key")
|
||||
if "," in self.data.get('name'):
|
||||
logger.debug(INVALID_NAME_MESSAGE)
|
||||
raise forms.ValidationError(INVALID_NAME_MESSAGE)
|
||||
return self.data.get('name')
|
||||
|
||||
def clean_user(self):
|
||||
return self.request.user
|
||||
return self.request.user if self.request.user.is_authenticated() else None
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = self.cleaned_data
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-09-08 08:45+0000\n"
|
||||
"POT-Creation-Date: 2019-07-09 15:21+0000\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"
|
||||
|
|
@ -27,6 +27,30 @@ msgstr "Dein Account wurde noch nicht aktiviert."
|
|||
msgid "User does not exist"
|
||||
msgstr "Der Benutzer existiert nicht"
|
||||
|
||||
msgid "Choose a product"
|
||||
msgstr ""
|
||||
|
||||
msgid "Amount in CHF"
|
||||
msgstr "Betrag"
|
||||
|
||||
msgid "Recurring monthly"
|
||||
msgstr ""
|
||||
|
||||
msgid "Amount field does not match"
|
||||
msgstr ""
|
||||
|
||||
msgid "Recurring field does not match"
|
||||
msgstr ""
|
||||
|
||||
msgid "Product name"
|
||||
msgstr "Produkt"
|
||||
|
||||
msgid "Monthly subscription"
|
||||
msgstr ""
|
||||
|
||||
msgid "One time payment"
|
||||
msgstr ""
|
||||
|
||||
msgid "Confirm Password"
|
||||
msgstr "Passwort Bestätigung"
|
||||
|
||||
|
|
@ -52,6 +76,9 @@ msgstr "Bitte verwende einen gültigen SSH-Key"
|
|||
msgid "This key exists already with the name \"%(name)s\""
|
||||
msgstr "Der SSH-Key mit dem Name \"%(name)s\" existiert bereits"
|
||||
|
||||
msgid "Comma not accepted in the name of the key"
|
||||
msgstr ""
|
||||
|
||||
msgid "All Rights Reserved"
|
||||
msgstr "Alle Rechte vorbehalten"
|
||||
|
||||
|
|
@ -209,7 +236,8 @@ msgstr "Du hast eine neue virtuelle Maschine bestellt!"
|
|||
|
||||
#, python-format
|
||||
msgid "Your order of <strong>%(vm_name)s</strong> has been charged."
|
||||
msgstr "Deine Bestellung von <strong>%(vm_name)s</strong> wurde entgegengenommen."
|
||||
msgstr ""
|
||||
"Deine Bestellung von <strong>%(vm_name)s</strong> wurde entgegengenommen."
|
||||
|
||||
msgid "You can view your VM detail by clicking the button below."
|
||||
msgstr "Um die Rechnung zu sehen, klicke auf den Button unten."
|
||||
|
|
@ -305,6 +333,100 @@ msgstr "Dashboard"
|
|||
msgid "Logout"
|
||||
msgstr "Abmelden"
|
||||
|
||||
#, python-format
|
||||
msgid "%(page_header_text)s"
|
||||
msgstr ""
|
||||
|
||||
msgid "Invoice #"
|
||||
msgstr "Rechnung"
|
||||
|
||||
msgid "Date"
|
||||
msgstr "Datum"
|
||||
|
||||
msgid "Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "Terminated"
|
||||
msgstr "Beendet"
|
||||
|
||||
msgid "Approved"
|
||||
msgstr "Akzeptiert"
|
||||
|
||||
msgid "Declined"
|
||||
msgstr "Abgelehnt"
|
||||
|
||||
msgid "Billed to"
|
||||
msgstr "Rechnungsadresse"
|
||||
|
||||
msgid "Payment method"
|
||||
msgstr "Bezahlmethode"
|
||||
|
||||
msgid "ending in"
|
||||
msgstr "endend in"
|
||||
|
||||
msgid "Invoice summary"
|
||||
msgstr ""
|
||||
|
||||
msgid "Product"
|
||||
msgstr "Produkt"
|
||||
|
||||
msgid "Period"
|
||||
msgstr "Periode"
|
||||
|
||||
msgid "Cores"
|
||||
msgstr "Prozessorkerne"
|
||||
|
||||
msgid "Memory"
|
||||
msgstr "Arbeitsspeicher"
|
||||
|
||||
msgid "Disk space"
|
||||
msgstr "Festplattenkapazität"
|
||||
|
||||
msgid "Subtotal"
|
||||
msgstr "Zwischensumme"
|
||||
|
||||
msgid "VAT"
|
||||
msgstr "Mehrwertsteuer"
|
||||
|
||||
msgid "Discount"
|
||||
msgstr "Rabatt"
|
||||
|
||||
msgid "Total"
|
||||
msgstr "Gesamt"
|
||||
|
||||
msgid "Amount"
|
||||
msgstr "Betrag"
|
||||
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
msgid "Recurring"
|
||||
msgstr ""
|
||||
|
||||
msgid "of every month"
|
||||
msgstr ""
|
||||
|
||||
msgid "BACK TO LIST"
|
||||
msgstr "ZURÜCK ZUR LISTE"
|
||||
|
||||
msgid "Some problem encountered. Please try again later."
|
||||
msgstr "Ein Problem ist aufgetreten. Bitte versuche es später noch einmal."
|
||||
|
||||
msgid "VM ID"
|
||||
msgstr ""
|
||||
|
||||
msgid "IP Address"
|
||||
msgstr ""
|
||||
|
||||
msgid "See Invoice"
|
||||
msgstr "Siehe Rechnung"
|
||||
|
||||
msgid "Page"
|
||||
msgstr ""
|
||||
|
||||
msgid "of"
|
||||
msgstr ""
|
||||
|
||||
msgid "Log in"
|
||||
msgstr "Anmelden"
|
||||
|
||||
|
|
@ -338,67 +460,15 @@ msgstr "Als gelesen markieren"
|
|||
msgid "All notifications"
|
||||
msgstr "Alle Benachrichtigungen"
|
||||
|
||||
#, python-format
|
||||
msgid "%(page_header_text)s"
|
||||
msgstr ""
|
||||
|
||||
msgid "Date"
|
||||
msgstr "Datum"
|
||||
|
||||
msgid "Status"
|
||||
msgstr ""
|
||||
|
||||
msgid "Terminated"
|
||||
msgstr "Beendet"
|
||||
|
||||
msgid "Approved"
|
||||
msgstr "Akzeptiert"
|
||||
|
||||
msgid "Declined"
|
||||
msgstr "Abgelehnt"
|
||||
|
||||
msgid "Billed to"
|
||||
msgstr "Rechnungsadresse"
|
||||
|
||||
msgid "Payment method"
|
||||
msgstr "Bezahlmethode"
|
||||
|
||||
msgid "ending in"
|
||||
msgstr "endend in"
|
||||
|
||||
msgid "Credit Card"
|
||||
msgstr "Kreditkarte"
|
||||
|
||||
msgid "Expiry"
|
||||
msgstr "Gültig bis"
|
||||
|
||||
msgid "Order summary"
|
||||
msgstr "Bestellungsübersicht"
|
||||
|
||||
msgid "Product"
|
||||
msgstr "Produkt"
|
||||
|
||||
msgid "Period"
|
||||
msgstr "Periode"
|
||||
|
||||
msgid "Cores"
|
||||
msgstr "Prozessorkerne"
|
||||
|
||||
msgid "Memory"
|
||||
msgstr "Arbeitsspeicher"
|
||||
|
||||
msgid "Disk space"
|
||||
msgstr "Festplattenkapazität"
|
||||
|
||||
msgid "Subtotal"
|
||||
msgstr "Zwischensumme"
|
||||
|
||||
msgid "VAT"
|
||||
msgstr "Mehrwertsteuer"
|
||||
|
||||
msgid "Discount"
|
||||
msgstr "Rabatt"
|
||||
|
||||
msgid "Total"
|
||||
msgstr "Gesamt"
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"By clicking \"Place order\" this plan will charge your credit card account "
|
||||
|
|
@ -410,9 +480,6 @@ msgstr ""
|
|||
msgid "Place order"
|
||||
msgstr "Bestellen"
|
||||
|
||||
msgid "BACK TO LIST"
|
||||
msgstr "ZURÜCK ZUR LISTE"
|
||||
|
||||
msgid "Processing..."
|
||||
msgstr "Abarbeitung..."
|
||||
|
||||
|
|
@ -425,24 +492,9 @@ msgstr ""
|
|||
msgid "Close"
|
||||
msgstr "Schliessen"
|
||||
|
||||
msgid "Some problem encountered. Please try again later."
|
||||
msgstr "Ein Problem ist aufgetreten. Bitte versuche es später noch einmal."
|
||||
|
||||
msgid "Order Nr."
|
||||
msgstr "Bestellung Nr."
|
||||
|
||||
msgid "Amount"
|
||||
msgstr "Betrag"
|
||||
|
||||
msgid "See Invoice"
|
||||
msgstr "Siehe Rechnung"
|
||||
|
||||
msgid "Page"
|
||||
msgstr ""
|
||||
|
||||
msgid "of"
|
||||
msgstr ""
|
||||
|
||||
msgid "Your Order"
|
||||
msgstr "Deine Bestellung"
|
||||
|
||||
|
|
@ -539,9 +591,6 @@ msgstr ""
|
|||
"Wir nutzen <a href=\"https://stripe.com\" target=\"_blank\">Stripe</a> für "
|
||||
"die Bezahlung und speichern keine Informationen in unserer Datenbank."
|
||||
|
||||
msgid "Add your public SSH key"
|
||||
msgstr "Füge deinen öffentlichen SSH-Key hinzu"
|
||||
|
||||
msgid "Use your created key to access to the VM"
|
||||
msgstr "Benutze deinen erstellten SSH-Key um auf deine VM zugreifen zu können"
|
||||
|
||||
|
|
@ -783,6 +832,9 @@ msgstr ""
|
|||
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"
|
||||
|
||||
|
|
@ -821,6 +873,9 @@ msgstr ""
|
|||
"Es gab einen Fehler bei der Bearbeitung Deine Anfrage. Bitte versuche es "
|
||||
"noch einmal."
|
||||
|
||||
#~ msgid "Add your public SSH key"
|
||||
#~ msgstr "Füge deinen öffentlichen SSH-Key hinzu"
|
||||
|
||||
#~ msgid "Do you want to cancel your Virtual Machine"
|
||||
#~ msgstr "Bist Du sicher, dass Du Deine virtuelle Maschine beenden willst"
|
||||
|
||||
|
|
@ -830,9 +885,6 @@ msgstr ""
|
|||
#~ msgid "My VM page"
|
||||
#~ msgstr "Meine VM page"
|
||||
|
||||
#~ msgid "Invoice Date"
|
||||
#~ msgstr "Rechnung Datum"
|
||||
|
||||
#~ msgid "VM %(VM_ID)s terminated successfully"
|
||||
#~ msgstr "VM %(VM_ID)s erfolgreich beendet"
|
||||
|
||||
|
|
|
|||
22
hosting/migrations/0055_auto_20190701_1614.py
Normal file
22
hosting/migrations/0055_auto_20190701_1614.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2019-07-01 16:14
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hosting', '0054_auto_20190508_2141'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='userhostingkey',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
||||
|
|
@ -187,7 +187,7 @@ class HostingOrder(AssignPermissionsMixin, models.Model):
|
|||
|
||||
|
||||
class UserHostingKey(models.Model):
|
||||
user = models.ForeignKey(CustomUser)
|
||||
user = models.ForeignKey(CustomUser, blank=True, null=True)
|
||||
public_key = models.TextField()
|
||||
private_key = models.FileField(upload_to='private_keys', blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
|
@ -613,6 +613,8 @@ class UserCardDetail(AssignPermissionsMixin, models.Model):
|
|||
for card in user_card_details:
|
||||
cards_list.append({
|
||||
'last4': card.last4, 'brand': card.brand, 'id': card.id,
|
||||
'exp_year': card.exp_year,
|
||||
'exp_month': '{:02d}'.format(card.exp_month),
|
||||
'preferred': card.preferred
|
||||
})
|
||||
return cards_list
|
||||
|
|
|
|||
|
|
@ -109,8 +109,11 @@ $(document).ready(function() {
|
|||
modal_btn = $('#createvm-modal-done-btn');
|
||||
$('#createvm-modal-title').text(data.msg_title);
|
||||
$('#createvm-modal-body').html(data.msg_body);
|
||||
modal_btn.attr('href', data.redirect)
|
||||
.removeClass('hide');
|
||||
if (data.redirect) {
|
||||
modal_btn.attr('href', data.redirect).removeClass('hide');
|
||||
} else {
|
||||
modal_btn.attr('href', "");
|
||||
}
|
||||
if (data.status === true) {
|
||||
fa_icon.attr('class', 'checkmark');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@
|
|||
{{user.email}}
|
||||
{% else %}
|
||||
{{cc_brand|default:_('Credit Card')}} {% trans "ending in" %} ****{{cc_last4}}<br>
|
||||
{% trans "Expiry" %} {{cc_exp_year}}/{{cc_exp_month}}<br/>
|
||||
{% if request.user.is_authenticated %}
|
||||
{{request.user.email}}
|
||||
{% else %}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,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 class="credit-card-details-opt">
|
||||
<div class="row">
|
||||
{% if card_list_len > 1 %}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
<form method="POST" action="" novalidate class="form-ssh">
|
||||
{% csrf_token %}
|
||||
<div class="page-header">
|
||||
<h1 class="h1-thin"><i class="fa fa-key" aria-hidden="true"></i> {% trans "Add your public SSH key" %}</h1>
|
||||
<h1 class="h1-thin"><i class="fa fa-key" aria-hidden="true"></i> {% if title %}{% trans title %}{% else %} {% endif %}</h1>
|
||||
{% if sub_title %}<span>{% trans sub_title %}</span>{% else %}{% endif %}
|
||||
</div>
|
||||
{% if messages %}
|
||||
<div class="alert alert-warning">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from django.conf.urls import url
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
from utils.views import SSHKeyCreateView, AskSSHKeyView
|
||||
from .views import (
|
||||
DjangoHostingView, RailsHostingView, PaymentVMView, NodeJSHostingView,
|
||||
LoginView, SignupView, SignupValidateView, SignupValidatedView, IndexView,
|
||||
|
|
@ -7,12 +9,11 @@ from .views import (
|
|||
VirtualMachinesPlanListView, VirtualMachineView, OrdersHostingDeleteView,
|
||||
MarkAsReadNotificationView, PasswordResetView, PasswordResetConfirmView,
|
||||
HostingPricingView, CreateVirtualMachinesView, HostingBillListView,
|
||||
HostingBillDetailView, SSHKeyDeleteView, SSHKeyCreateView, SSHKeyListView,
|
||||
HostingBillDetailView, SSHKeyDeleteView, SSHKeyListView,
|
||||
SSHKeyChoiceView, DashboardView, SettingsView, ResendActivationEmailView,
|
||||
InvoiceListView, InvoiceDetailView, CheckUserVM
|
||||
)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'index/?$', IndexView.as_view(), name='index'),
|
||||
url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'),
|
||||
|
|
@ -27,6 +28,8 @@ urlpatterns = [
|
|||
url(r'invoices/?$', InvoiceListView.as_view(), name='invoices'),
|
||||
url(r'order-confirmation/?$', OrdersHostingDetailView.as_view(),
|
||||
name='order-confirmation'),
|
||||
url(r'^add-ssh-key/?$', AskSSHKeyView.as_view(),
|
||||
name='add_ssh_key'),
|
||||
url(r'orders/(?P<pk>\d+)/?$', OrdersHostingDetailView.as_view(),
|
||||
name='orders'),
|
||||
url(r'invoice/(?P<invoice_id>[-\w]+)/?$', InvoiceDetailView.as_view(),
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ from utils.forms import (
|
|||
BillingAddressForm, PasswordResetRequestForm, UserBillingAddressForm,
|
||||
ResendActivationEmailForm
|
||||
)
|
||||
from utils.hosting_utils import get_all_public_keys
|
||||
from utils.hosting_utils import get_vm_price_with_vat, HostingUtils
|
||||
from utils.mailer import BaseEmail
|
||||
from utils.stripe_utils import StripeUtils
|
||||
|
|
@ -466,7 +467,9 @@ class SSHKeyDeleteView(LoginRequiredMixin, DeleteView):
|
|||
pk = self.kwargs.get('pk')
|
||||
# Get user ssh key
|
||||
public_key = UserHostingKey.objects.get(pk=pk).public_key
|
||||
manager.manage_public_key([{'value': public_key, 'state': False}])
|
||||
keys = UserHostingKey.objects.filter(user=self.request.user)
|
||||
keys_to_save = [k.public_key for k in keys if k.public_key != public_key]
|
||||
manager.save_key_in_opennebula_user('\n'.join(keys_to_save), update_type=0)
|
||||
|
||||
return super(SSHKeyDeleteView, self).delete(request, *args, **kwargs)
|
||||
|
||||
|
|
@ -515,74 +518,11 @@ class SSHKeyChoiceView(LoginRequiredMixin, View):
|
|||
email=owner.email,
|
||||
password=owner.password
|
||||
)
|
||||
public_key_str = public_key.decode()
|
||||
manager.manage_public_key([{'value': public_key_str, 'state': True}])
|
||||
keys = get_all_public_keys(request.user)
|
||||
manager.save_key_in_opennebula_user('\n'.join(keys))
|
||||
return redirect(reverse_lazy('hosting:ssh_keys'), foo='bar')
|
||||
|
||||
|
||||
@method_decorator(decorators, name='dispatch')
|
||||
class SSHKeyCreateView(LoginRequiredMixin, FormView):
|
||||
form_class = UserHostingKeyForm
|
||||
model = UserHostingKey
|
||||
template_name = 'hosting/user_key.html'
|
||||
login_url = reverse_lazy('hosting:login')
|
||||
context_object_name = "virtual_machine"
|
||||
success_url = reverse_lazy('hosting:ssh_keys')
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(SSHKeyCreateView, self).get_form_kwargs()
|
||||
kwargs.update({'request': self.request})
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
if settings.DCL_SSH_KEY_NAME_PREFIX in form.instance.name:
|
||||
content = ContentFile(form.cleaned_data.get('private_key'))
|
||||
filename = form.cleaned_data.get(
|
||||
'name') + '_' + str(uuid.uuid4())[:8] + '_private.pem'
|
||||
form.instance.private_key.save(filename, content)
|
||||
context = self.get_context_data()
|
||||
|
||||
next_url = self.request.session.get(
|
||||
'next',
|
||||
reverse('hosting:create_virtual_machine')
|
||||
)
|
||||
|
||||
if 'next' in self.request.session:
|
||||
context.update({
|
||||
'next_url': next_url
|
||||
})
|
||||
del (self.request.session['next'])
|
||||
|
||||
if form.cleaned_data.get('private_key'):
|
||||
context.update({
|
||||
'private_key': form.cleaned_data.get('private_key'),
|
||||
'key_name': form.cleaned_data.get('name'),
|
||||
'form': UserHostingKeyForm(request=self.request),
|
||||
})
|
||||
|
||||
owner = self.request.user
|
||||
manager = OpenNebulaManager(
|
||||
email=owner.email,
|
||||
password=owner.password
|
||||
)
|
||||
public_key = form.cleaned_data['public_key']
|
||||
if type(public_key) is bytes:
|
||||
public_key = public_key.decode()
|
||||
manager.manage_public_key([{'value': public_key, 'state': True}])
|
||||
return HttpResponseRedirect(self.success_url)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = self.get_form()
|
||||
required = 'add_ssh' in self.request.POST
|
||||
form.fields['name'].required = required
|
||||
form.fields['public_key'].required = required
|
||||
if form.is_valid():
|
||||
return self.form_valid(form)
|
||||
else:
|
||||
return self.form_invalid(form)
|
||||
|
||||
|
||||
@method_decorator(decorators, name='dispatch')
|
||||
class SettingsView(LoginRequiredMixin, FormView):
|
||||
template_name = "hosting/settings.html"
|
||||
|
|
@ -829,21 +769,27 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
|||
reverse('hosting:payment') + '#payment_error')
|
||||
request.session['token'] = token
|
||||
request.session['billing_address_data'] = billing_address_data
|
||||
return HttpResponseRedirect("{url}?{query_params}".format(
|
||||
url=reverse('hosting:order-confirmation'),
|
||||
query_params='page=payment')
|
||||
)
|
||||
self.request.session['order_confirm_url'] = "{url}?{query_params}".format(
|
||||
url=reverse('hosting:order-confirmation'),
|
||||
query_params='page=payment')
|
||||
return HttpResponseRedirect(reverse('hosting:add_ssh_key'))
|
||||
else:
|
||||
return self.form_invalid(form)
|
||||
|
||||
|
||||
class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
|
||||
class OrdersHostingDetailView(LoginRequiredMixin, DetailView, FormView):
|
||||
form_class = UserHostingKeyForm
|
||||
template_name = "hosting/order_detail.html"
|
||||
context_object_name = "order"
|
||||
login_url = reverse_lazy('hosting:login')
|
||||
permission_required = ['view_hostingorder']
|
||||
model = HostingOrder
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(OrdersHostingDetailView, self).get_form_kwargs()
|
||||
kwargs.update({'request': self.request})
|
||||
return kwargs
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
order_id = self.kwargs.get('pk')
|
||||
try:
|
||||
|
|
@ -868,6 +814,8 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView):
|
|||
|
||||
if self.request.GET.get('page') == 'payment':
|
||||
context['page_header_text'] = _('Confirm Order')
|
||||
context['form'] = UserHostingKeyForm(request=self.request)
|
||||
context['keys'] = get_all_public_keys(self.request.user)
|
||||
else:
|
||||
context['page_header_text'] = _('Invoice')
|
||||
if not self.request.user.has_perm(
|
||||
|
|
@ -958,11 +906,15 @@ class OrdersHostingDetailView(LoginRequiredMixin, 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'] = 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)
|
||||
context['site_url'] = reverse('hosting:create_virtual_machine')
|
||||
context['vm'] = self.request.session.get('specs')
|
||||
return context
|
||||
|
|
@ -1587,6 +1539,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
|||
'order': HostingOrder.objects.get(
|
||||
vm_id=serializer.data['vm_id']
|
||||
),
|
||||
'keys': UserHostingKey.objects.filter(user=request.user),
|
||||
'has_invoices': False
|
||||
}
|
||||
try:
|
||||
|
|
@ -1665,7 +1618,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
|||
"manager.delete_vm returned False. Hence, error making "
|
||||
"xml-rpc call to delete vm failed."
|
||||
)
|
||||
response['text'] = ugettext('Error terminating VM') + vm.id
|
||||
response['text'] = str(_('Error terminating VM')) + str(vm.id)
|
||||
else:
|
||||
for t in range(15):
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue