Skip to content

Commit

Permalink
list the invoices of an organization in index page
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Apr 4, 2017
1 parent 09efcda commit aae0f38
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions www/%username/invoices/index.spt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: utf8

from liberapay.utils import get_participant

[---]

participant = get_participant(state, restrict=False)

if participant.kind != 'organization':
raise response.error(404)

invoices = website.db.all("""
SELECT i.*
, ( SELECT ts
FROM invoice_events ie
WHERE ie.invoice = i.id
ORDER BY ts DESC
LIMIT 1
) AS mtime
FROM invoices i
WHERE i.addressee = %s
AND i.status NOT IN ('pre', 'canceled')
ORDER BY i.ctime DESC
LIMIT 100
""", (participant.id,))

title = _("Invoices - {username}", username=participant.username)

[---] text/html
% extends "templates/base.html"

% block content

% for i in invoices
<p>
<a href="{{ participant.path('invoices/%i' % i.id) }}">{{ i.description }}</a>
&mdash; {{ _(constants.INVOICE_STATUSES[i.status]) }} ({{ format_date(i.mtime, 'long') }})
</p>
% else
<p>{{ _("Nothing to show.") }}</p>
% endfor

% endblock

0 comments on commit aae0f38

Please sign in to comment.