"""Represents lines of individual booking."""
# pylint: disable=too-few-public-methods
- def __init__(self, id_: int, idx_start: int, dat_lines: list[DatLine]
- ) -> None:
+ def __init__(self, id_: int, dat_lines: list[DatLine]) -> None:
self.id_ = id_
- self.idx_start = idx_start
- self.idx_end = self.idx_start + len(dat_lines)
- for dat_line in dat_lines:
+ self.dat_lines = dat_lines
+ for dat_line in self.dat_lines:
dat_line.booking_line = BookingLine(self.id_, dat_line.code)
def do_GET(self) -> None:
# pylint: disable=invalid-name,missing-function-docstring
if self.pagename == 'booking':
- b = self.server.bookings[int(self.path_toks[2])]
- dat_lines = self.server.dat_lines[b.idx_start:b.idx_end]
- self.send_rendered(Path('index.tmpl'), {'dat_lines': dat_lines})
+ self.send_rendered(
+ Path('booking.tmpl'),
+ {'dat_lines':
+ self.server.bookings[int(self.path_toks[2])].dat_lines})
elif self.pagename == 'raw':
self.send_rendered(Path('raw.tmpl'),
{'dat_lines': self.server.dat_lines})
DatLine(line)
for line in path_dat.read_text(encoding='utf8').splitlines()]
self.bookings: list[Booking] = []
- last_booking_start = -1
booking_lines: list[DatLine] = []
- for idx, dat_line in enumerate(self.dat_lines + [DatLine('')]):
+ for dat_line in self.dat_lines + [DatLine('')]:
if dat_line.code:
- if not booking_lines:
- last_booking_start = idx
booking_lines += [dat_line]
elif booking_lines:
- self.bookings += [Booking(len(self.bookings),
- last_booking_start, booking_lines)]
- booking_lines.clear()
+ self.bookings += [Booking(len(self.bookings), booking_lines)]
+ booking_lines = []
@property
def dat_lines_sans_empty(self) -> list[DatLine]:
--- /dev/null
+{% extends '_base.tmpl' %}
+
+{% block css %}
+td.amt { text-align: right }
+td.amt, td.curr { font-family: monospace; font-size: 1.3em; }
+td.curr { text-align: center; }
+{% endblock %}
+
+{% block content %}
+<table>
+{% for l in dat_lines %}
+ <tr class="{{l.type}}">
+ {% if l.type == "value" %}
+ <td class="amt">{{l.booking_line.amt}}</td><td class="curr">{{l.booking_line.curr|truncate(4,true,"…")}}</td><td>{{l.booking_line.acc}}</td>
+ {% elif l.type == "intro" %}
+ <td class="code" colspan=3><a href="/booking/{{l.booking_id}}">{{l.code}}</a></td>
+ {% else %}
+ <td colspan=3>{{l.code}}</td>
+ {% endif %}
+ <td>{{l.comment}}</td>
+ </tr>
+{% endfor %}
+</table>
+{% endblock %}
+