4 Commits
Author SHA1 Message Date
tris 375d08488d Inline icon 2026-07-14 09:01:22 +10:00
tris f5349beaae Merge branch 'master' of gitea.tfconsulting.com.au:projects/polyphonic 2026-07-14 08:31:40 +10:00
tris 450eda5c26 Added sort columns 2026-07-14 08:31:32 +10:00
tris abb66f7b40 Updated dockerfiles 2026-07-13 08:50:57 +10:00
4 changed files with 34 additions and 18 deletions
+5 -3
View File
@@ -1,8 +1,10 @@
FROM alpine:latest
ARG VERSION=0.8.4
ENV TARGET=/opt/polyphonic
ENV RELEASE=polyphonic-0.8.4-py3-none-any.whl
#ENV RELEASE=git+https://gitea.tfconsulting.com.au/projects/polyphonic.git
#ENV RELEASE=polyphonic-${VERSION}-py3-none-any.whl
ENV RELEASE=git+https://gitea.tfconsulting.com.au/projects/polyphonic.git@${VERSION}
RUN apk add --no-cache python3 py3-pip git ghostscript sqlite
@@ -11,7 +13,7 @@ WORKDIR /root
RUN python3 -m venv ${TARGET}
ENV PATH="${TARGET}/bin:$PATH"
COPY dist/${RELEASE} .
#COPY dist/${RELEASE} .
RUN pip3 install ${RELEASE} --no-cache-dir
RUN pip3 install gunicorn whitenoise
+2 -1
View File
@@ -1,7 +1,7 @@
services:
polyphonic:
image: "polyphonic:0.8.4"
build: "."
build: .
ports:
- "8001:8000"
volumes:
@@ -12,3 +12,4 @@ services:
DJANGO_SETTINGS_MODULE: local_settings
PYTHONPATH: /opt/polyphonic
WORK_DIR: /var/polyphonic
VERSION: 0.8.4
@@ -30,7 +30,7 @@
<div class="has-text-centered">
<a href="?">_</a>
{% for letter in letters %}
<a href="?start={{ letter }}">{{ letter }}</a>&nbsp;
<a href="?start={{ letter }}&sort={{ sort }}">{{ letter }}</a>&nbsp;
{% endfor %}
</div>
{% endif %}
@@ -38,10 +38,10 @@
<table class="table is-striped is-fullwidth">
<thead>
<tr>
<th>Work</th>
<th>Composer</th>
<th class="is-hidden-mobile">Edition</th>
{% if not collection %}<th class="is-hidden-touch">Collection</th>{% endif %}
<th>Work <span class="icon-text"><a href="?start={{ start }}&sort=name">{{ "list_arrow"|icon }}</a></span></th>
<th>Composer <span class="icon-text"><a href="?start={{ start }}&sort=composer">{{ "list_arrow"|icon }}</a></span></th>
<th class="is-hidden-mobile">Edition</th>
{% if not collection %}<th class="is-hidden-touch">Collection</th>{% endif %}
</tr>
</thead>
<tbody>
+22 -9
View File
@@ -199,13 +199,8 @@ class WorkListView(CollectionMixin, TemplateView):
data["meta"] = qs.meta
# data["page_range"] = data["page_obj"]["paginator"]
else:
qs = self.get_queryset()
start = self.request.GET.get("start")
if start:
start = start.upper()
qs = qs.filter(name__gte=start, name__lt=start + "~")
data["start"] = start
qs, ctx = self.get_filtered_queryset()
data.update(ctx)
data["letters"] = string.ascii_uppercase
@@ -222,9 +217,27 @@ class WorkListView(CollectionMixin, TemplateView):
def get_collections(self):
raise NotImplementedError
def get_queryset(self):
def get_filtered_queryset(self):
works = self.get_works()
return works.order_by("name", "composer", "edition", "pk").distinct()
ctx = {}
sort = self.request.GET.get("sort", "name").lower()
order = ["name", "composer", "edition"]
if sort not in order:
raise KeyError(f"Cannot sort by {sort}")
order.remove(sort)
order = [sort] + order + ["pk"]
ctx["sort"] = sort
start = self.request.GET.get("start")
if start:
start = start.upper()
filters = {f"{sort}__gte": start, f"{sort}__lt": start + "~"}
works = works.filter(**filters)
ctx["start"] = start
return works.order_by(*order).distinct(), ctx
def get_results(self, query, page):
try: