diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html index 24b2c6ad..6b41af95 100644 --- a/hosting/templates/hosting/virtual_machine_detail.html +++ b/hosting/templates/hosting/virtual_machine_detail.html @@ -46,7 +46,7 @@
{% trans "Current Pricing" %}
{{order.price|floatformat:2|intcomma}} CHF/{% if order.generic_product %}{% trans order.generic_product.product_subscription_interval %}{% else %}{% trans "Month" %}{% endif %}
- {% trans "See Invoice" %} + {% if inv_url %}{% trans "See Invoice" %}{%else%}{% trans "No invoice as of now" %}{% endif %}
diff --git a/hosting/views.py b/hosting/views.py index e2f6e13b..6b93fdb4 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1694,7 +1694,11 @@ class VirtualMachineView(LoginRequiredMixin, View): login_url = reverse_lazy('hosting:login') 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 manager = OpenNebulaManager( email=owner.username, @@ -1750,7 +1754,10 @@ class VirtualMachineView(LoginRequiredMixin, View): subscription=hosting_order.subscription_id, 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: stripe_obj = stripe.Charge.retrieve( hosting_order.stripe_charge_id