Merge pull request #544 from pcoder/task/3974/improve_invoice_number
Task/3974/improve invoice number
This commit is contained in:
commit
5572a3199b
1 changed files with 27 additions and 4 deletions
|
@ -670,13 +670,25 @@ class OrdersHostingDetailView(LoginRequiredMixin,
|
||||||
permission_required = ['view_hostingorder']
|
permission_required = ['view_hostingorder']
|
||||||
model = HostingOrder
|
model = HostingOrder
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self, queryset=None):
|
||||||
return HostingOrder.objects.get(
|
order_id = self.kwargs.get('pk')
|
||||||
pk=self.kwargs.get('pk')) if self.kwargs.get('pk') else None
|
try:
|
||||||
|
hosting_order_obj = HostingOrder.objects.get(pk=order_id)
|
||||||
|
logger.debug("Found HostingOrder for id {order_id}".format(
|
||||||
|
order_id=order_id
|
||||||
|
))
|
||||||
|
except HostingOrder.DoesNotExist:
|
||||||
|
logger.debug("HostingOrder not found for id {order_id}".format(
|
||||||
|
order_id=order_id
|
||||||
|
))
|
||||||
|
hosting_order_obj = None
|
||||||
|
return hosting_order_obj
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# Get context
|
# Get context
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super(
|
||||||
|
OrdersHostingDetailView, self
|
||||||
|
).get_context_data(**kwargs)
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
stripe_api_cus_id = self.request.session.get('customer')
|
stripe_api_cus_id = self.request.session.get('customer')
|
||||||
|
@ -690,6 +702,17 @@ class OrdersHostingDetailView(LoginRequiredMixin,
|
||||||
context['page_header_text'] = _('Confirm Order')
|
context['page_header_text'] = _('Confirm Order')
|
||||||
else:
|
else:
|
||||||
context['page_header_text'] = _('Invoice')
|
context['page_header_text'] = _('Invoice')
|
||||||
|
if not self.request.user.has_perm(
|
||||||
|
self.permission_required[0], obj
|
||||||
|
):
|
||||||
|
logger.debug(
|
||||||
|
"User {user} does not have permission on HostingOrder "
|
||||||
|
"{order_id}. Raising 404 error now.".format(
|
||||||
|
user=self.request.user.email,
|
||||||
|
order_id=obj.id if obj else 'None'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
raise Http404
|
||||||
|
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
# invoice for previous order
|
# invoice for previous order
|
||||||
|
|
Loading…
Reference in a new issue