Merge branch 'master' into 8393/show-SCA

This commit is contained in:
PCoder 2020-12-02 18:49:31 +05:30
commit e522ac0f61
4 changed files with 30 additions and 21 deletions

View File

@ -1,3 +1,6 @@
2.13: 2020-12-02
* 8654: Fix 500 error on invoices list for the user contact+devuanhosting.com@virus.media (MR!742)
* 8593: Escape user's ssh key in xml-rpc call to create VM (MR!741)
2.12.1: 2020-07-21 2.12.1: 2020-07-21
* 8307: Introduce "Exclude vat calculations" for Generic Products (MR!740) * 8307: Introduce "Exclude vat calculations" for Generic Products (MR!740)
* Change DE VAT rate to 16% from 19% (MR!739) * Change DE VAT rate to 16% from 19% (MR!739)

View File

@ -72,25 +72,29 @@ def get_line_item_from_hosting_order_charge(hosting_order_id):
:param hosting_order_id: the HostingOrder id :param hosting_order_id: the HostingOrder id
:return: :return:
""" """
hosting_order = HostingOrder.objects.get(id = hosting_order_id) try:
if hosting_order.stripe_charge_id: hosting_order = HostingOrder.objects.get(id = hosting_order_id)
return mark_safe(""" if hosting_order.stripe_charge_id:
<td class="xs-td-inline">{product_name}</td> return mark_safe("""
<td class="xs-td-inline">{created_at}</td> <td class="xs-td-inline">{product_name}</td>
<td class="xs-td-inline">{total}</td> <td class="xs-td-inline">{created_at}</td>
<td class="text-right last-td"> <td class="xs-td-inline">{total}</td>
<a class="btn btn-order-detail" href="{receipt_url}" target="_blank">{see_invoice_text}</a> <td class="text-right last-td">
</td> <a class="btn btn-order-detail" href="{receipt_url}" target="_blank">{see_invoice_text}</a>
""".format( </td>
product_name=hosting_order.generic_product.product_name.capitalize(), """.format(
created_at=hosting_order.created_at.strftime('%Y-%m-%d'), product_name=hosting_order.generic_product.product_name.capitalize(),
total='%.2f' % (hosting_order.price), created_at=hosting_order.created_at.strftime('%Y-%m-%d'),
receipt_url=reverse('hosting:orders', total='%.2f' % (hosting_order.price),
kwargs={'pk': hosting_order.id}), receipt_url=reverse('hosting:orders',
kwargs={'pk': hosting_order.id}),
see_invoice_text=_("See Invoice") see_invoice_text=_("See Invoice")
)) ))
else: else:
return ""
except Exception as ex:
logger.error("Error %s" % str(ex))
return "" return ""
@ -110,7 +114,7 @@ def get_line_item_from_stripe_invoice(invoice):
plan_name = "" plan_name = ""
for line_data in invoice["lines"]["data"]: for line_data in invoice["lines"]["data"]:
if is_first: if is_first:
plan_name = line_data.plan.name plan_name = line_data.plan.name if line_data.plan is not None else ""
start_date = line_data.period.start start_date = line_data.period.start
end_date = line_data.period.end end_date = line_data.period.end
is_first = False is_first = False

View File

@ -2,6 +2,7 @@ import datetime
import logging import logging
import subprocess import subprocess
import tempfile import tempfile
import xml
from django import forms from django import forms
from django.conf import settings from django.conf import settings
@ -207,7 +208,7 @@ class UserHostingKeyForm(forms.ModelForm):
logger.debug( logger.debug(
"Not a correct ssh format {error}".format(error=str(cpe))) "Not a correct ssh format {error}".format(error=str(cpe)))
raise forms.ValidationError(KEY_ERROR_MESSAGE) raise forms.ValidationError(KEY_ERROR_MESSAGE)
return openssh_pubkey_str return xml.sax.saxutils.escape(openssh_pubkey_str)
def clean_name(self): def clean_name(self):
INVALID_NAME_MESSAGE = _("Comma not accepted in the name of the key") INVALID_NAME_MESSAGE = _("Comma not accepted in the name of the key")

View File

@ -1,6 +1,7 @@
import logging import logging
import uuid import uuid
from datetime import datetime from datetime import datetime
from urllib.parse import quote
from time import sleep from time import sleep
import stripe import stripe
@ -1313,7 +1314,7 @@ class InvoiceListView(LoginRequiredMixin, TemplateView):
if ('user_email' in self.request.GET if ('user_email' in self.request.GET
and self.request.user.email == settings.ADMIN_EMAIL): and self.request.user.email == settings.ADMIN_EMAIL):
user_email = self.request.GET['user_email'] user_email = self.request.GET['user_email']
context['user_email'] = user_email context['user_email'] = '%s' % quote(user_email)
logger.debug( logger.debug(
"user_email = {}".format(user_email) "user_email = {}".format(user_email)
) )