invoice list fetching fix
This commit is contained in:
parent
64afac2271
commit
6c475c25bc
|
@ -58,14 +58,16 @@ class Regie(models.Model):
|
|||
return Template(self.invoice_list_url).render(context)
|
||||
|
||||
def get_invoice_list(self, request, **kwargs):
|
||||
if not self.get_list_url:
|
||||
if not self.invoice_list_url:
|
||||
return []
|
||||
context = RequestContext(request, kwargs)
|
||||
data_source = Data('tipi', {'limit': None, 'refresh': None},
|
||||
data_source = Data(self.slug, {'limit': None, 'refresh': None},
|
||||
{'url': self.get_invoice_list_url(context),
|
||||
'content_type': 'json',
|
||||
'content_type': 'application/json',
|
||||
'parser_type': 'json',
|
||||
'slug': 'invoice'}, context)
|
||||
'auth_mech': 'oauth2',
|
||||
'redirects': True,
|
||||
'slug': 'invoice_list'}, context)
|
||||
content = data_source.update_content()
|
||||
return content.get('data', {}).get('invoices', [])
|
||||
|
||||
|
@ -78,9 +80,9 @@ class Regie(models.Model):
|
|||
'invoice_hash': invoice_hash}
|
||||
if request:
|
||||
context = RequestContext(request, context)
|
||||
data_source = Data('tipi', {'limit': None, 'refresh': None},
|
||||
data_source = Data(self.slug, {'limit': None, 'refresh': None},
|
||||
{'url': self.get_invoice_url(context),
|
||||
'content_type': 'json',
|
||||
'content_type': 'application/json',
|
||||
'parser_type': 'json',
|
||||
'slug': 'invoice'}, context)
|
||||
content = data_source.update_content()
|
||||
|
@ -90,7 +92,7 @@ class Regie(models.Model):
|
|||
args=(self.slug, invoice_id, invoice_hash))
|
||||
# is this invoice in the list of invoices ? (typically, list
|
||||
# of user's invoices). If yes, add a "download_url" value
|
||||
if self.get_list_url and request and request.user.is_authenticated():
|
||||
if self.invoice_list_url and request and request.user.is_authenticated():
|
||||
invoice['in_list'] = False
|
||||
ctx_invoices = self.get_invoice_list(request)
|
||||
for i in ctx_invoices:
|
||||
|
|
Reference in New Issue