Preparation for first deployment-test

This commit is contained in:
2025-09-03 19:47:16 +00:00
parent 4e74f72c9f
commit e30723da0a
14 changed files with 3612 additions and 245 deletions

View File

@@ -0,0 +1,38 @@
"""Change uploaded_at to TIMESTAMP in EventMedia
Revision ID: 216402147826
Revises: b22d339ed2af
Create Date: 2025-09-01 10:22:55.285710
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision: str = '216402147826'
down_revision: Union[str, None] = 'b22d339ed2af'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('event_media', 'uploaded_at',
existing_type=mysql.DATETIME(),
type_=sa.TIMESTAMP(),
nullable=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('event_media', 'uploaded_at',
existing_type=sa.TIMESTAMP(),
type_=mysql.DATETIME(),
nullable=True)
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""Add uploaded_at to EventMedia
Revision ID: b22d339ed2af
Revises: e6eaede720aa
Create Date: 2025-09-01 10:07:46.915640
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'b22d339ed2af'
down_revision: Union[str, None] = 'e6eaede720aa'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('event_media', sa.Column('uploaded_at', sa.DateTime(timezone=True), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('event_media', 'uploaded_at')
# ### end Alembic commands ###

View File

@@ -36,16 +36,54 @@ def filemanager_operations():
if action == 'read':
# List files and folders
items = []
session = Session()
for entry in os.scandir(full_path):
items.append({
item = {
'name': entry.name,
'isFile': entry.is_file(),
'size': entry.stat().st_size,
'dateModified': entry.stat().st_mtime,
'type': os.path.splitext(entry.name)[1][1:] if entry.is_file() else '',
'hasChild': entry.is_dir()
})
}
# Wenn Datei, versuche Upload-Datum aus DB zu holen
if entry.is_file():
media = session.query(EventMedia).filter_by(
url=entry.name).first()
if media and media.uploaded_at:
# FileManager erwartet UNIX-Timestamp (Sekunden)
item['dateModified'] = int(media.uploaded_at.timestamp())
else:
item['dateModified'] = entry.stat().st_mtime
else:
item['dateModified'] = entry.stat().st_mtime
items.append(item)
session.close()
return jsonify({'files': items, 'cwd': {'name': os.path.basename(full_path), 'path': path}})
elif action == 'details':
# Details für eine oder mehrere Dateien zurückgeben
names = request.form.getlist('names[]') or (request.json.get(
'names') if request.is_json and request.json else [])
path = get_param('path', '/')
details = []
session = Session()
for name in names:
file_path = os.path.join(MEDIA_ROOT, path.lstrip('/'), name)
media = session.query(EventMedia).filter_by(url=name).first()
if os.path.isfile(file_path):
detail = {
'name': name,
'size': os.path.getsize(file_path),
'dateModified': int(media.uploaded_at.timestamp()) if media and media.uploaded_at else int(os.path.getmtime(file_path)),
'type': os.path.splitext(name)[1][1:],
'hasChild': False,
'isFile': True,
'description': media.message_content if media else '',
# weitere Felder nach Bedarf
}
details.append(detail)
session.close()
return jsonify({'details': details})
elif action == 'delete':
for item in request.form.getlist('names[]'):
item_path = os.path.join(full_path, item)
@@ -88,10 +126,12 @@ def filemanager_upload():
media_type = MediaType(ext)
except ValueError:
media_type = MediaType.other
from datetime import datetime, timezone
media = EventMedia(
media_type=media_type,
url=file.filename,
file_path=os.path.relpath(file_path, MEDIA_ROOT)
file_path=os.path.relpath(file_path, MEDIA_ROOT),
uploaded_at=datetime.now(timezone.utc)
)
session.add(media)
session.commit()