Attempt to show IP address instead of invoice number
This commit is contained in:
		
					parent
					
						
							
								6d4af0c193
							
						
					
				
			
			
				commit
				
					
						73f7831744
					
				
			
		
					 2 changed files with 20 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -18,7 +18,7 @@
 | 
			
		|||
    <table class="table table-switch">
 | 
			
		||||
        <thead>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <th>{% trans "Invoice Nr." %}</th>
 | 
			
		||||
                <th>{% trans "IP Address" %}</th>
 | 
			
		||||
                <th>{% trans "Period" %}</th>
 | 
			
		||||
                <th>{% trans "Date" %}</th>
 | 
			
		||||
                <th>{% trans "Amount" %}</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@
 | 
			
		|||
        <tbody>
 | 
			
		||||
            {% for invoice in invoices %}
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td class="xs-td-inline" data-header="{% trans 'Invoice Nr.' %}">{{ invoice.invoice_number }}</td>
 | 
			
		||||
                    <td class="xs-td-inline" data-header="{% trans 'IP Address' %}">{{ ips|get_value_from_dict:invoice.invoice_number|join:"<br/>" }}</td>
 | 
			
		||||
                    <td class="xs-td-inline" data-header="{% trans 'Period' %}">{{ invoice.period_start | date:'Y-m-d' }} — {{ invoice.period_end | date:'Y-m-d' }}</td>
 | 
			
		||||
                    <td class="xs-td-bighalf locale_date" data-header="{% trans 'Date' %}">{{ invoice.paid_at | date:'Y-m-d h:i a' }}</td>
 | 
			
		||||
                    <td class="xs-td-smallhalf" data-header="{% trans 'Amount' %}">{{ invoice.total_in_chf|floatformat:2|intcomma }}</td>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1164,6 +1164,24 @@ class InvoiceListView(LoginRequiredMixin, ListView):
 | 
			
		|||
    model = MonthlyHostingBill
 | 
			
		||||
    ordering = '-created'
 | 
			
		||||
 | 
			
		||||
    def get_context_data(self, **kwargs):
 | 
			
		||||
        context = super(InvoiceListView, self).get_context_data(**kwargs)
 | 
			
		||||
        mabs = MonthlyHostingBill.objects.filter(
 | 
			
		||||
            customer__user=self.request.user
 | 
			
		||||
        )
 | 
			
		||||
        ips_dict = {}
 | 
			
		||||
        for mab in mabs:
 | 
			
		||||
            try:
 | 
			
		||||
                vm_detail = VMDetail.get(vm_id=mab.order.vm_id)
 | 
			
		||||
                ips_dict[mab.invoice_number] = [vm_detail.ipv6, vm_detail.ipv4]
 | 
			
		||||
            except VMDetail.DoesNotExist as dne:
 | 
			
		||||
                ips_dict[mab.invoice_number] = ['--']
 | 
			
		||||
                logger.debug("VMDetail for {} doesn't exist".format(
 | 
			
		||||
                    mab.order.vm_id
 | 
			
		||||
                ))
 | 
			
		||||
        context['ips'] = ips_dict
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
    def get_queryset(self):
 | 
			
		||||
        user = self.request.user
 | 
			
		||||
        self.queryset = MonthlyHostingBill.objects.filter(customer__user=user)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue