Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 55% |
Changes | 0 |
1 | """ |
||
2 | byceps.blueprints.site.party_history.views |
||
3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
4 | |||
5 | :Copyright: 2006-2021 Jochen Kupperschmidt |
||
6 | :License: Revised BSD (see `LICENSE` file for details) |
||
7 | """ |
||
8 | |||
9 | 1 | from flask import abort, g |
|
10 | |||
11 | 1 | from ....services.party import service as party_service |
|
12 | 1 | from ....services.ticketing import attendance_service |
|
13 | 1 | from ....services.user import service as user_service |
|
14 | 1 | from ....util.framework.blueprint import create_blueprint |
|
15 | 1 | from ....util.framework.templating import templated |
|
16 | |||
17 | |||
18 | 1 | blueprint = create_blueprint('party_archive', __name__) |
|
19 | |||
20 | |||
21 | 1 | @blueprint.get('') |
|
22 | 1 | @templated |
|
23 | def index(): |
||
24 | """List archived parties.""" |
||
25 | parties = party_service.get_archived_parties_for_brand(g.brand_id) |
||
26 | parties = [p for p in parties if not p.canceled] |
||
27 | |||
28 | return { |
||
29 | 'parties': parties, |
||
30 | } |
||
31 | |||
32 | |||
33 | 1 | @blueprint.get('/<party_id>') |
|
34 | 1 | @templated |
|
35 | def view(party_id): |
||
36 | """Show archived party.""" |
||
37 | party = party_service.find_party(party_id) |
||
38 | if (party is None) or (party.brand_id != g.brand_id) or not party.archived: |
||
39 | abort(404) |
||
40 | |||
41 | attendee_ids = attendance_service.get_attendee_ids_for_party(party_id) |
||
42 | attendees = user_service.find_users(attendee_ids, include_avatars=True) |
||
43 | |||
44 | return { |
||
45 | 'party': party, |
||
46 | 'attendees': attendees, |
||
47 | } |
||
48 |