From b756e1b411ca53d7a7ea2f72f8cce64b2f40cc67 Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Mon, 5 Jan 2026 14:06:51 +0100 Subject: [PATCH] Resources page added --- AGENTS.md | 2 ++ argocd/deployment.yaml | 2 +- boxes/templates/boxes/resources_list.html | 39 +++++++++++++++++++++++ boxes/views.py | 32 +++++++++++++++++++ labhelper/templates/base.html | 1 + labhelper/urls.py | 2 ++ 6 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 boxes/templates/boxes/resources_list.html diff --git a/AGENTS.md b/AGENTS.md index c5eac09..438f931 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -216,6 +216,7 @@ labhelper/ │ │ ├── box_management.html # Box/BoxType CRUD management │ │ ├── edit_thing.html # Edit thing page (name, description, picture, tags, files, links) │ │ ├── index.html # Home page with boxes and tags +│ │ ├── resources_list.html # List all links and files from things │ │ ├── search.html # Search page with AJAX │ │ └── thing_detail.html # Read-only thing details view │ ├── templatetags/ @@ -391,6 +392,7 @@ The project uses a base template system at `labhelper/templates/base.html`. All | `add_things` | `/box//add/` | `add_things` | Add multiple things to a box | | `search` | `/search/` | `search` | Search page | | `search_api` | `/search/api/` | `search_api` | AJAX search endpoint | +| `resources_list` | `/resources/` | `resources_list` | List all links and files from things (sorted by thing name) | | `LoginView` | `/login/` | `login` | Django auth login | | `LogoutView` | `/logout/` | `logout` | Django auth logout | | `admin.site` | `/admin/` | - | Django admin | diff --git a/argocd/deployment.yaml b/argocd/deployment.yaml index 5b0d0b1..5ee8fdb 100644 --- a/argocd/deployment.yaml +++ b/argocd/deployment.yaml @@ -27,7 +27,7 @@ spec: mountPath: /data containers: - name: web - image: git.baumann.gr/adebaumann/labhelper:0.052 + image: git.baumann.gr/adebaumann/labhelper:0.053 imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/boxes/templates/boxes/resources_list.html b/boxes/templates/boxes/resources_list.html new file mode 100644 index 0000000..a939bbd --- /dev/null +++ b/boxes/templates/boxes/resources_list.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + +{% load static %} + +{% block title %}Resources - LabHelper{% endblock %} + +{% block page_header %} + +{% endblock %} + +{% block content %} +
+

All Resources

+ {% if resources %} +
    + {% for resource in resources %} +
  • + {% if resource.type == 'link' %} + + {% else %} + + {% endif %} + {{ resource.thing_name }}: + {% if resource.type == 'link' %} + {{ resource.title }} + {% else %} + {{ resource.title }} + {% endif %} +
  • + {% endfor %} +
+ {% else %} +

No resources found.

+ {% endif %} +
+{% endblock %} diff --git a/boxes/views.py b/boxes/views.py index f239dbd..7565e60 100644 --- a/boxes/views.py +++ b/boxes/views.py @@ -370,3 +370,35 @@ def delete_box(request, box_id): return redirect('box_management') box.delete() return redirect('box_management') + + +@login_required +def resources_list(request): + """List all links and files from things that have them.""" + things_with_files = Thing.objects.filter(files__isnull=False).prefetch_related('files').distinct() + things_with_links = Thing.objects.filter(links__isnull=False).prefetch_related('links').distinct() + + all_things = (things_with_files | things_with_links).distinct().order_by('name') + + resources = [] + for thing in all_things.prefetch_related('files', 'links'): + for file in thing.files.all(): + resources.append({ + 'type': 'file', + 'thing_name': thing.name, + 'thing_id': thing.id, + 'title': file.title, + 'url': file.file.url, + }) + for link in thing.links.all(): + resources.append({ + 'type': 'link', + 'thing_name': thing.name, + 'thing_id': thing.id, + 'title': link.title, + 'url': link.url, + }) + + return render(request, 'boxes/resources_list.html', { + 'resources': resources, + }) diff --git a/labhelper/templates/base.html b/labhelper/templates/base.html index 375f187..faae6d6 100644 --- a/labhelper/templates/base.html +++ b/labhelper/templates/base.html @@ -312,6 +312,7 @@