Added translations and reformatted code
This commit is contained in:
parent
2276533185
commit
7d12eff9be
3 changed files with 83 additions and 55 deletions
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2017-09-02 10:50+0000\n"
|
"POT-Creation-Date: 2017-09-02 11:16+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -523,6 +523,15 @@ msgstr "Du kannst dich nun"
|
||||||
msgid "Sorry. Your request is invalid."
|
msgid "Sorry. Your request is invalid."
|
||||||
msgstr "Entschuldigung, deine Anfrage ist ungültig."
|
msgstr "Entschuldigung, deine Anfrage ist ungültig."
|
||||||
|
|
||||||
|
msgid "Password has been reset."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Password reset has not been successful."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "The reset password link is no longer valid."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Invalid credit card"
|
msgid "Invalid credit card"
|
||||||
msgstr "Ungültige Kreditkarte"
|
msgstr "Ungültige Kreditkarte"
|
||||||
|
|
||||||
|
|
113
hosting/views.py
113
hosting/views.py
|
@ -1,40 +1,41 @@
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.core.files.base import ContentFile
|
|
||||||
|
|
||||||
from oca.pool import WrongNameError, WrongIdError
|
|
||||||
from django.shortcuts import render
|
|
||||||
from django.http import Http404
|
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
||||||
from django.views.generic import View, CreateView, FormView, ListView, DetailView, \
|
|
||||||
DeleteView, TemplateView, UpdateView
|
|
||||||
from django.http import HttpResponseRedirect
|
|
||||||
from django.contrib import messages
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.shortcuts import redirect
|
from django.contrib import messages
|
||||||
from django.utils.http import urlsafe_base64_decode
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.auth.tokens import default_token_generator
|
from django.contrib.auth.tokens import default_token_generator
|
||||||
|
from django.core.files.base import ContentFile
|
||||||
from guardian.mixins import PermissionRequiredMixin
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
from stored_messages.settings import stored_messages_settings
|
from django.http import Http404
|
||||||
from stored_messages.models import Message
|
from django.http import HttpResponseRedirect
|
||||||
from stored_messages.api import mark_read
|
from django.shortcuts import redirect
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.utils.http import urlsafe_base64_decode
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.views.generic import View, CreateView, FormView, ListView, \
|
||||||
|
DetailView, \
|
||||||
|
DeleteView, TemplateView, UpdateView
|
||||||
|
from guardian.mixins import PermissionRequiredMixin
|
||||||
|
from oca.pool import WrongNameError, WrongIdError
|
||||||
|
from stored_messages.api import mark_read
|
||||||
|
from stored_messages.models import Message
|
||||||
|
from stored_messages.settings import stored_messages_settings
|
||||||
|
|
||||||
from membership.models import CustomUser, StripeCustomer
|
from membership.models import CustomUser, StripeCustomer
|
||||||
from utils.stripe_utils import StripeUtils
|
|
||||||
from utils.forms import BillingAddressForm, PasswordResetRequestForm, UserBillingAddressForm
|
|
||||||
from utils.views import PasswordResetViewMixin, PasswordResetConfirmViewMixin, LoginViewMixin
|
|
||||||
from utils.mailer import BaseEmail
|
|
||||||
from .models import HostingOrder, HostingBill, HostingPlan, UserHostingKey
|
|
||||||
from .forms import HostingUserSignupForm, HostingUserLoginForm, UserHostingKeyForm, generate_ssh_key_name
|
|
||||||
from .mixins import ProcessVMSelectionMixin
|
|
||||||
|
|
||||||
from opennebula_api.models import OpenNebulaManager
|
from opennebula_api.models import OpenNebulaManager
|
||||||
from opennebula_api.serializers import VirtualMachineSerializer, \
|
from opennebula_api.serializers import VirtualMachineSerializer, \
|
||||||
VirtualMachineTemplateSerializer
|
VirtualMachineTemplateSerializer
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from utils.forms import BillingAddressForm, PasswordResetRequestForm, \
|
||||||
|
UserBillingAddressForm
|
||||||
|
from utils.mailer import BaseEmail
|
||||||
|
from utils.stripe_utils import StripeUtils
|
||||||
|
from utils.views import PasswordResetViewMixin, PasswordResetConfirmViewMixin, \
|
||||||
|
LoginViewMixin
|
||||||
|
from .forms import HostingUserSignupForm, HostingUserLoginForm, \
|
||||||
|
UserHostingKeyForm, generate_ssh_key_name
|
||||||
|
from .mixins import ProcessVMSelectionMixin
|
||||||
|
from .models import HostingOrder, HostingBill, HostingPlan, UserHostingKey
|
||||||
|
|
||||||
CONNECTION_ERROR = "Your VMs cannot be displayed at the moment due to a backend \
|
CONNECTION_ERROR = "Your VMs cannot be displayed at the moment due to a backend \
|
||||||
connection error. please try again in a few minutes."
|
connection error. please try again in a few minutes."
|
||||||
|
@ -296,12 +297,13 @@ class PasswordResetConfirmView(PasswordResetConfirmViewMixin):
|
||||||
|
|
||||||
form = self.form_class(request.POST)
|
form = self.form_class(request.POST)
|
||||||
|
|
||||||
if user is not None and default_token_generator.check_token(user, token):
|
if user is not None and default_token_generator.check_token(user,
|
||||||
|
token):
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
new_password = form.cleaned_data['new_password2']
|
new_password = form.cleaned_data['new_password2']
|
||||||
user.set_password(new_password)
|
user.set_password(new_password)
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, 'Password has been reset.')
|
messages.success(request, _('Password has been reset.'))
|
||||||
|
|
||||||
# Change opennebula password
|
# Change opennebula password
|
||||||
opennebula_client.change_user_password(new_password)
|
opennebula_client.change_user_password(new_password)
|
||||||
|
@ -309,14 +311,15 @@ class PasswordResetConfirmView(PasswordResetConfirmViewMixin):
|
||||||
return self.form_valid(form)
|
return self.form_valid(form)
|
||||||
else:
|
else:
|
||||||
messages.error(
|
messages.error(
|
||||||
request, 'Password reset has not been successful.')
|
request, _('Password reset has not been successful.'))
|
||||||
form.add_error(None, 'Password reset has not been successful.')
|
form.add_error(None,
|
||||||
|
_('Password reset has not been successful.'))
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
messages.error(
|
error_msg = _('The reset password link is no longer valid.')
|
||||||
request, 'The reset password link is no longer valid.')
|
messages.error(request, _(error_msg))
|
||||||
form.add_error(None, 'The reset password link is no longer valid.')
|
form.add_error(None, error_msg)
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
|
|
||||||
|
@ -397,7 +400,8 @@ class SSHKeyListView(LoginRequiredMixin, ListView):
|
||||||
def render_to_response(self, context, **response_kwargs):
|
def render_to_response(self, context, **response_kwargs):
|
||||||
if not self.queryset:
|
if not self.queryset:
|
||||||
return HttpResponseRedirect(reverse('hosting:choice_ssh_keys'))
|
return HttpResponseRedirect(reverse('hosting:choice_ssh_keys'))
|
||||||
return super(SSHKeyListView, self).render_to_response(context, **response_kwargs)
|
return super(SSHKeyListView, self).render_to_response(context,
|
||||||
|
**response_kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SSHKeyChoiceView(LoginRequiredMixin, View):
|
class SSHKeyChoiceView(LoginRequiredMixin, View):
|
||||||
|
@ -571,8 +575,10 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
||||||
if not customer:
|
if not customer:
|
||||||
msg = _("Invalid credit card")
|
msg = _("Invalid credit card")
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
self.request, messages.ERROR, msg, extra_tags='make_charge_error')
|
self.request, messages.ERROR, msg,
|
||||||
return HttpResponseRedirect(reverse('hosting:payment') + '#payment_error')
|
extra_tags='make_charge_error')
|
||||||
|
return HttpResponseRedirect(
|
||||||
|
reverse('hosting:payment') + '#payment_error')
|
||||||
|
|
||||||
# Create Billing Address
|
# Create Billing Address
|
||||||
billing_address = form.save()
|
billing_address = form.save()
|
||||||
|
@ -586,8 +592,10 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
||||||
if not charge_response.get('response_object'):
|
if not charge_response.get('response_object'):
|
||||||
msg = charge_response.get('error')
|
msg = charge_response.get('error')
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
self.request, messages.ERROR, msg, extra_tags='make_charge_error')
|
self.request, messages.ERROR, msg,
|
||||||
return HttpResponseRedirect(reverse('hosting:payment') + '#payment_error')
|
extra_tags='make_charge_error')
|
||||||
|
return HttpResponseRedirect(
|
||||||
|
reverse('hosting:payment') + '#payment_error')
|
||||||
|
|
||||||
charge = charge_response.get('response_object')
|
charge = charge_response.get('response_object')
|
||||||
|
|
||||||
|
@ -595,7 +603,8 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.email,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
# Get user ssh key
|
# Get user ssh key
|
||||||
if not UserHostingKey.objects.filter(user=self.request.user).exists():
|
if not UserHostingKey.objects.filter(
|
||||||
|
user=self.request.user).exists():
|
||||||
context.update({
|
context.update({
|
||||||
'sshError': 'error',
|
'sshError': 'error',
|
||||||
'form': form
|
'form': form
|
||||||
|
@ -647,7 +656,8 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
||||||
context = {
|
context = {
|
||||||
'vm': vm,
|
'vm': vm,
|
||||||
'order': order,
|
'order': order,
|
||||||
'base_url': "{0}://{1}".format(request.scheme, request.get_host())
|
'base_url': "{0}://{1}".format(request.scheme,
|
||||||
|
request.get_host())
|
||||||
|
|
||||||
}
|
}
|
||||||
email_data = {
|
email_data = {
|
||||||
|
@ -661,13 +671,15 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
||||||
email.send()
|
email.send()
|
||||||
|
|
||||||
return HttpResponseRedirect(
|
return HttpResponseRedirect(
|
||||||
"{url}?{query_params}".format(url=reverse('hosting:orders', kwargs={'pk': order.id}),
|
"{url}?{query_params}".format(
|
||||||
|
url=reverse('hosting:orders', kwargs={'pk': order.id}),
|
||||||
query_params='page=payment'))
|
query_params='page=payment'))
|
||||||
else:
|
else:
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
|
|
||||||
class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailView):
|
class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin,
|
||||||
|
DetailView):
|
||||||
template_name = "hosting/order_detail.html"
|
template_name = "hosting/order_detail.html"
|
||||||
context_object_name = "order"
|
context_object_name = "order"
|
||||||
login_url = reverse_lazy('hosting:login')
|
login_url = reverse_lazy('hosting:login')
|
||||||
|
@ -775,7 +787,8 @@ class CreateVirtualMachinesView(LoginRequiredMixin, View):
|
||||||
configuration_options = HostingPlan.get_serialized_configs()
|
configuration_options = HostingPlan.get_serialized_configs()
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'templates': VirtualMachineTemplateSerializer(templates, many=True).data,
|
'templates': VirtualMachineTemplateSerializer(templates,
|
||||||
|
many=True).data,
|
||||||
'configuration_options': configuration_options,
|
'configuration_options': configuration_options,
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
|
@ -846,7 +859,8 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
serializer = VirtualMachineSerializer(vm)
|
serializer = VirtualMachineSerializer(vm)
|
||||||
context = {
|
context = {
|
||||||
'virtual_machine': serializer.data,
|
'virtual_machine': serializer.data,
|
||||||
'order': HostingOrder.objects.get(vm_id=serializer.data['vm_id'])
|
'order': HostingOrder.objects.get(
|
||||||
|
vm_id=serializer.data['vm_id'])
|
||||||
}
|
}
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -877,7 +891,8 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'vm': vm,
|
'vm': vm,
|
||||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host())
|
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||||
|
self.request.get_host())
|
||||||
}
|
}
|
||||||
email_data = {
|
email_data = {
|
||||||
'subject': 'Virtual machine plan canceled',
|
'subject': 'Virtual machine plan canceled',
|
||||||
|
@ -897,7 +912,8 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
return HttpResponseRedirect(self.get_success_url())
|
return HttpResponseRedirect(self.get_success_url())
|
||||||
|
|
||||||
|
|
||||||
class HostingBillListView(PermissionRequiredMixin, LoginRequiredMixin, ListView):
|
class HostingBillListView(PermissionRequiredMixin, LoginRequiredMixin,
|
||||||
|
ListView):
|
||||||
template_name = "hosting/bills.html"
|
template_name = "hosting/bills.html"
|
||||||
login_url = reverse_lazy('hosting:login')
|
login_url = reverse_lazy('hosting:login')
|
||||||
permission_required = ['view_hostingview']
|
permission_required = ['view_hostingview']
|
||||||
|
@ -907,7 +923,8 @@ class HostingBillListView(PermissionRequiredMixin, LoginRequiredMixin, ListView)
|
||||||
ordering = '-id'
|
ordering = '-id'
|
||||||
|
|
||||||
|
|
||||||
class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailView):
|
class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin,
|
||||||
|
DetailView):
|
||||||
template_name = "hosting/bill_detail.html"
|
template_name = "hosting/bill_detail.html"
|
||||||
login_url = reverse_lazy('hosting:login')
|
login_url = reverse_lazy('hosting:login')
|
||||||
permission_required = ['view_hostingview']
|
permission_required = ['view_hostingview']
|
||||||
|
|
|
@ -124,16 +124,18 @@ class PasswordResetConfirmViewMixin(FormView):
|
||||||
new_password = form.cleaned_data['new_password2']
|
new_password = form.cleaned_data['new_password2']
|
||||||
user.set_password(new_password)
|
user.set_password(new_password)
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, 'Password has been reset.')
|
messages.success(request, _('Password has been reset.'))
|
||||||
return self.form_valid(form)
|
return self.form_valid(form)
|
||||||
else:
|
else:
|
||||||
messages.error(request,
|
messages.error(request,
|
||||||
'Password reset has not been successful.')
|
_('Password reset has not been successful.'))
|
||||||
form.add_error(None, 'Password reset has not been successful.')
|
form.add_error(None,
|
||||||
|
_('Password reset has not been successful.'))
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
messages.error(request,
|
messages.error(request,
|
||||||
'The reset password link is no longer valid.')
|
_('The reset password link is no longer valid.'))
|
||||||
form.add_error(None, 'The reset password link is no longer valid.')
|
form.add_error(None,
|
||||||
|
_('The reset password link is no longer valid.'))
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
Loading…
Reference in a new issue