mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-07 13:00:22 -05:00
4ef035dc78
Add admin PDF Layout Editor with local GrapesJS (no CDN) Routes: GET/POST /admin/pdf-layout (save, server-side default seeding) POST /admin/pdf-layout/reset (clear custom template) GET /admin/pdf-layout/default (serve default body HTML/CSS) POST /admin/pdf-layout/preview (render preview with sample context) Invoice PDF generator: support custom HTML/CSS and i18n; add default template and CSS Preview: sanitize Jinja, add helpers (format_date, format_money), sample item Base layout: include head_extra and scripts_extra Editor UI: removed quick blocks, preview, and insert variables; keep load/save/reset Vendor GrapesJS under app/static/vendor/grapesjs and load locally README: document the new feature and usage
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""add pdf template fields to settings
|
|
|
|
Revision ID: 012
|
|
Revises: 011
|
|
Create Date: 2025-09-12 00:00:00
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '012'
|
|
down_revision = '011'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
bind = op.get_bind()
|
|
inspector = sa.inspect(bind)
|
|
if 'settings' not in inspector.get_table_names():
|
|
return
|
|
columns = {c['name'] for c in inspector.get_columns('settings')}
|
|
if 'invoice_pdf_template_html' not in columns:
|
|
op.add_column('settings', sa.Column('invoice_pdf_template_html', sa.Text(), nullable=True))
|
|
if 'invoice_pdf_template_css' not in columns:
|
|
op.add_column('settings', sa.Column('invoice_pdf_template_css', sa.Text(), nullable=True))
|
|
|
|
|
|
def downgrade() -> None:
|
|
bind = op.get_bind()
|
|
inspector = sa.inspect(bind)
|
|
if 'settings' not in inspector.get_table_names():
|
|
return
|
|
columns = {c['name'] for c in inspector.get_columns('settings')}
|
|
if 'invoice_pdf_template_css' in columns:
|
|
try:
|
|
op.drop_column('settings', 'invoice_pdf_template_css')
|
|
except Exception:
|
|
pass
|
|
if 'invoice_pdf_template_html' in columns:
|
|
try:
|
|
op.drop_column('settings', 'invoice_pdf_template_html')
|
|
except Exception:
|
|
pass
|
|
|
|
|