Resources page added
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 16s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 3s
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 16s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 3s
This commit is contained in:
@@ -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/<str:box_id>/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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
39
boxes/templates/boxes/resources_list.html
Normal file
39
boxes/templates/boxes/resources_list.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Resources - LabHelper{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
<div class="page-header">
|
||||
<h1><i class="fas fa-folder-open"></i> Resources</h1>
|
||||
<p class="breadcrumb">All links and files from things</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="section">
|
||||
<h2><i class="fas fa-list"></i> All Resources</h2>
|
||||
{% if resources %}
|
||||
<ul style="list-style: none; padding: 0;">
|
||||
{% for resource in resources %}
|
||||
<li style="padding: 8px 0; border-bottom: 1px solid #eee;">
|
||||
{% if resource.type == 'link' %}
|
||||
<i class="fas fa-link" style="color: #667eea;"></i>
|
||||
{% else %}
|
||||
<i class="fas fa-file" style="color: #667eea;"></i>
|
||||
{% endif %}
|
||||
<strong>{{ resource.thing_name }}</strong>:
|
||||
{% if resource.type == 'link' %}
|
||||
<a href="{{ resource.url }}" target="_blank" rel="noopener noreferrer">{{ resource.title }}</a>
|
||||
{% else %}
|
||||
<a href="{{ resource.url }}">{{ resource.title }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p style="color: #888;">No resources found.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -312,6 +312,7 @@
|
||||
<div class="navbar-nav" id="navbar-nav">
|
||||
<a href="/"><i class="fas fa-home"></i> Home</a>
|
||||
<a href="/box-management/"><i class="fas fa-boxes"></i> Box Management</a>
|
||||
<a href="/resources/"><i class="fas fa-folder-open"></i> Resources</a>
|
||||
<a href="/search/"><i class="fas fa-search"></i> Search</a>
|
||||
<a href="/admin/"><i class="fas fa-cog"></i> Admin</a>
|
||||
{% if user.is_authenticated %}
|
||||
|
||||
@@ -32,6 +32,7 @@ from boxes.views import (
|
||||
edit_box_type,
|
||||
edit_thing,
|
||||
index,
|
||||
resources_list,
|
||||
search,
|
||||
search_api,
|
||||
thing_detail,
|
||||
@@ -54,6 +55,7 @@ urlpatterns = [
|
||||
path('box/<str:box_id>/add/', add_things, name='add_things'),
|
||||
path('search/', search, name='search'),
|
||||
path('search/api/', search_api, name='search_api'),
|
||||
path('resources/', resources_list, name='resources_list'),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user