move card components to module specific directories

This commit is contained in:
Thomas Peetz
2025-05-25 22:12:23 +02:00
parent 456162da44
commit 87b1c24783
12 changed files with 66 additions and 25 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
{% for artist in artists %}
<div class="col-lg-4 col-md-3 col-sm-10 mr-auto">
{% with obj=artist %}
{% include "components/artist_cards.html" %}
{% include "comic/artist_cards.html" %}
{% endwith %}
{% if loop.index %3 %}
@@ -18,7 +18,7 @@
{% for publisher in publishers %}
<div class="col-lg-4 col-md-3 col-sm-10 mr-auto">
{% with obj=publisher %}
{% include "components/publisher_cards.html" %}
{% include "comic/publisher_cards.html" %}
{% endwith %}
{% if loop.index %3 %}
</div>
@@ -41,5 +41,12 @@
</tbody>
</table>
</div>
<div class="row">
<div>
<a href="/media/actors" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Back to list</a>
<a href="/media/actor/edit/{{actor.id}}" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Edit</a>
<a href="/media/actor/delete/{{actor.id}}" class="btn btn-outline-danger btn-sm active" role="button" aria-pressed="true">Delete</a>
</div>
</div>
</div>
{% endblock %}
+1 -1
View File
@@ -18,7 +18,7 @@
{% for actor in actors %}
<div class="col-lg-4 col-md-3 col-sm-10 mr-auto">
{% with obj=actor %}
{% include "components/actor_cards.html" %}
{% include "media/actor_cards.html" %}
{% endwith %}
{% if loop.index %3 %}
@@ -61,5 +61,12 @@
</tbody>
</table>
</div>
<div class="row">
<div>
<a href="/media/files" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Back to list</a>
<a href="/media/file/edit/{{mediafile.id}}" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Edit</a>
<a href="/media/file/delete/{{mediafile.id}}" class="btn btn-outline-danger btn-sm active" role="button" aria-pressed="true">Delete</a>
</div>
</div>
</div>
{% endblock %}
+14 -4
View File
@@ -9,21 +9,31 @@
{% include "components/alerts.html" %}
{% endwith %}
<div class="container">
<div class="row">
<form class="d-flex" action="/media/files/">
<input class="form-control me-2" name="query" id="autocomplete" type="search" placeholder="Search" aria-label="Search">
Review<input type="checkbox" name="review" aria-label="Review">
Download<input type="checkbox" name="download" aria-label="Download">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
<div class="row">
<table class="table table-hover">
<thead><tr>
<th scope="col">Titel</th>
<th scope="col">URL</th>
<th scope="col">Cloudlink</th>
<th scope="col">Review</th>
<th scope="col">Download</th>
</tr></thead>
<tbody>
{% for mediafile in mediafiles %}
<tr>
<th scope="row"><a href="/media/files/{{mediafile.id}}">{{mediafile.title}}</a></th>
<td>{{mediafile.url}}</td>
<td>{{mediafile.cloud_link}}</td>
<td>{% with check=mediafile.review %}{% include "components/check.html" %}{% endwith %}</td>
<td>{% with check=mediafile.should_download %}{% include "components/check.html" %}{% endwith %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
+4 -4
View File
@@ -12,15 +12,15 @@
<table class="table table-hover">
<thead><tr>
<th scope="col">Titel</th>
<th scope="col">URL</th>
<th scope="col">Cloudlink</th>
<th scope="col">Review</th>
<th scope="col">Download</th>
</tr></thead>
<tbody>
{% for mediavideo in mediavideos %}
<tr>
<th scope="row"><a href="/media/videos/{{mediavideo.id}}">{{mediavideo.title}}</a></th>
<td>{{mediavideo.url}}</td>
<td>{{mediavideo.cloud_link}}</td>
<td>{% with check=mediavideo.review %}{% include "components/check.html" %}{% endwith %}</td>
<td>{% with check=mediavideo.should_download %}{% include "components/check.html" %}{% endwith %}</td>
</tr>
{% endfor %}
</tbody>
+19 -2
View File
@@ -3,6 +3,7 @@ from typing import AnyStr
from fastapi import APIRouter, Request
from fastapi.security.utils import get_authorization_scheme_param
from fastapi.templating import Jinja2Templates
from sqlalchemy import or_
from src.apis.utils import SessionDep
from src.apis.version1.admin import get_current_user_from_token
@@ -14,13 +15,29 @@ router = APIRouter(include_in_schema=False, prefix="/media")
@router.get("/files")
def get_mediafiles(db: SessionDep, request: Request, msg: str = None):
params = request.query_params
query = params.get("query")
filter = {}
review = params.get('review') == "on"
if review:
filter['review'] = True
download = params.get("download") == "on"
if download:
filter['should_download'] = True
if query is not None and len(query) > 0:
filter['url'] = query
if len(filter) > 0:
if "url" in filter:
mediafiles = db.query(MediaFile).filter(or_(MediaFile.title.ilike(f'%{query}%'), MediaFile.url.ilike(f"%{query}%")))
else:
mediafiles = db.query(MediaFile).filter_by(**filter).all()
else:
mediafiles = db.query(MediaFile).all()
try:
token = request.cookies.get("access_token")
scheme, param = get_authorization_scheme_param(token) # scheme will hold "Bearer" and param will hold actual token value
current_user: Profile = get_current_user_from_token(token=param, db=db)
return templates.TemplateResponse("media/files.html",
{"request": request, "msg": msg, "mediafiles": mediafiles})
return templates.TemplateResponse("media/files.html", {"request": request, "msg": msg, "mediafiles": mediafiles})
except Exception as e:
print(e)
msg = "Nicht berechtigt!!"