bugfix-vm-detail-no-invoice #16
2 changed files with 10 additions and 3 deletions
|
@ -46,7 +46,7 @@
|
||||||
<div class="vm-vmid">
|
<div class="vm-vmid">
|
||||||
<div class="vm-item-subtitle">{% trans "Current Pricing" %}</div>
|
<div class="vm-item-subtitle">{% trans "Current Pricing" %}</div>
|
||||||
<div class="vm-item-lg">{{order.price|floatformat:2|intcomma}} CHF/{% if order.generic_product %}{% trans order.generic_product.product_subscription_interval %}{% else %}{% trans "Month" %}{% endif %}</div>
|
<div class="vm-item-lg">{{order.price|floatformat:2|intcomma}} CHF/{% if order.generic_product %}{% trans order.generic_product.product_subscription_interval %}{% else %}{% trans "Month" %}{% endif %}</div>
|
||||||
<a class="btn btn-vm-invoice" href="{{inv_url}}" target="_blank">{% trans "See Invoice" %}</a>
|
{% if inv_url %}<a class="btn btn-vm-invoice" href="{{inv_url}}" target="_blank">{% trans "See Invoice" %}</a>{%else%}{% trans "No invoice as of now" %}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="vm-detail-item">
|
<div class="vm-detail-item">
|
||||||
|
|
|
@ -1694,7 +1694,11 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
login_url = reverse_lazy('hosting:login')
|
login_url = reverse_lazy('hosting:login')
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
owner = self.request.user
|
username = self.request.GET.get('username')
|
||||||
|
if self.request.user.is_admin and username:
|
||||||
|
owner = CustomUser.objects.get(username=username)
|
||||||
|
else:
|
||||||
|
owner = self.request.user
|
||||||
vm = None
|
vm = None
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.username,
|
email=owner.username,
|
||||||
|
@ -1750,7 +1754,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
subscription=hosting_order.subscription_id,
|
subscription=hosting_order.subscription_id,
|
||||||
count=1
|
count=1
|
||||||
)
|
)
|
||||||
inv_url = stripe_obj.data[0].hosted_invoice_url
|
if stripe_obj.data:
|
||||||
|
inv_url = stripe_obj.data[0].hosted_invoice_url
|
||||||
|
else:
|
||||||
|
inv_url = ''
|
||||||
elif hosting_order.stripe_charge_id:
|
elif hosting_order.stripe_charge_id:
|
||||||
stripe_obj = stripe.Charge.retrieve(
|
stripe_obj = stripe.Charge.retrieve(
|
||||||
hosting_order.stripe_charge_id
|
hosting_order.stripe_charge_id
|
||||||
|
|
Loading…
Reference in a new issue