billing: Show the billing page only to admins and billing users.

This commit is contained in:
Vishnu Ks
2018-07-11 20:06:52 +05:30
committed by Rishi Gupta
parent 377fac2864
commit 895c7703a6
3 changed files with 57 additions and 22 deletions

View File

@@ -199,10 +199,10 @@ def billing_home(request: HttpRequest) -> HttpResponse:
if customer is None:
return HttpResponseRedirect(reverse('zilencer.views.initial_upgrade'))
# TODO
# if not user.is_realm_admin and not user == customer.billing_user:
# context['error_message'] = _("You must be an administrator to view this page.")
# return render(request, 'zilencer/billing.html', context=context)
if not user.is_realm_admin and not user == customer.billing_user:
context = {'admin_access': False} # type: Dict[str, Any]
return render(request, 'zilencer/billing.html', context=context)
context = {'admin_access': True}
stripe_customer = get_stripe_customer(customer.stripe_customer_id)
@@ -230,7 +230,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
if source is not None:
payment_method = "Card ending in %(last4)s" % {'last4': source.last4}
context = {
context.update({
'plan_name': plan_name,
'seat_count': seat_count,
'renewal_date': renewal_date,
@@ -238,6 +238,6 @@ def billing_home(request: HttpRequest) -> HttpResponse:
'payment_method': payment_method,
'prorated_charges': '{:,.2f}'.format(prorated_charges),
'prorated_credits': '{:,.2f}'.format(prorated_credits),
} # type: Dict[str, Any]
})
return render(request, 'zilencer/billing.html', context=context)