- Python/Flask Backend - SQLAlchemy Models (notes, tasks, templates, users) - Gunicorn + Nginx Deploy-Konfiguration - Static Assets (CSS/JS) - Jinja2 Templates
78 lines
2.7 KiB
Python
Executable File
78 lines
2.7 KiB
Python
Executable File
from flask import Flask
|
|
from .models import db, login_manager, User, DocumentationTemplate, DocumentationEntry, TaskItem
|
|
from .routes import main_bp
|
|
from pathlib import Path
|
|
from datetime import date
|
|
|
|
|
|
def create_app():
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
Path(app.instance_path).mkdir(parents=True, exist_ok=True)
|
|
|
|
app.config['SECRET_KEY'] = 'change-me-in-production'
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = f"sqlite:///{Path(app.instance_path) / 'notesmanager.db'}"
|
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
|
|
db.init_app(app)
|
|
login_manager.init_app(app)
|
|
login_manager.login_view = 'main.login'
|
|
|
|
app.register_blueprint(main_bp)
|
|
|
|
with app.app_context():
|
|
db.create_all()
|
|
seed_data()
|
|
|
|
return app
|
|
|
|
|
|
def seed_data():
|
|
if DocumentationTemplate.query.count() == 0:
|
|
templates = [
|
|
DocumentationTemplate(
|
|
name='Tagesabschluss',
|
|
description='Standardvorlage für den täglichen Abschluss.',
|
|
content=(
|
|
'## Tagesziel\n- \n\n'
|
|
'## Erledigte Arbeiten\n- \n\n'
|
|
'## Offene Punkte\n- \n\n'
|
|
'## Besonderheiten / Störungen\n- \n\n'
|
|
'## Übergabe\n- '
|
|
)
|
|
),
|
|
DocumentationTemplate(
|
|
name='Wartung / Änderung',
|
|
description='Vorlage für technische Änderungen oder Wartungen.',
|
|
content=(
|
|
'## Betroffenes System\n- \n\n'
|
|
'## Anlass\n- \n\n'
|
|
'## Durchgeführte Schritte\n1. \n2. \n\n'
|
|
'## Ergebnis\n- \n\n'
|
|
'## Rollback / Risiko\n- '
|
|
)
|
|
)
|
|
]
|
|
db.session.add_all(templates)
|
|
|
|
if TaskItem.query.count() == 0:
|
|
demo_tasks = [
|
|
TaskItem(title='Backup-Prüfung dokumentieren', description='Kontrolle des letzten Backup-Laufs eintragen.', due_date=date.today(), status='offen', priority='hoch'),
|
|
TaskItem(title='Tagesbericht erstellen', description='Wichtige Arbeiten des Tages zusammenfassen.', due_date=date.today(), status='in_bearbeitung', priority='mittel')
|
|
]
|
|
db.session.add_all(demo_tasks)
|
|
|
|
if DocumentationEntry.query.count() == 0:
|
|
db.session.add(DocumentationEntry(
|
|
title='Beispiel: Morgenroutine',
|
|
work_date=date.today(),
|
|
category='Betrieb',
|
|
system_name='Allgemein',
|
|
priority='mittel',
|
|
status='erledigt',
|
|
content='Server geprüft, Tickets gesichtet und Tagesprioritäten festgelegt.',
|
|
tags='betrieb,morgenroutine',
|
|
created_by='Administrator'
|
|
))
|
|
|
|
db.session.commit()
|