Externe Datei-Links + Power-User-Rolle + PAROL6-Demo
Block A — Externe Links:
- projekt_datei.extern_url: eine "Datei" kann Upload (BLOB) ODER Link sein
- Link-Route /cockpit/projekt/<id>/link, Werkstatt-UI mit Link-Feld
- Katalog + Detail rendern Links als "Oeffnen ↗", Uploads als Download
- Upload-Limit 30 -> 60 MB (grosse Bambu-3MF); darueber: externer Link
Block B — Power-User-Rolle:
- profil.rolle ('schueler'|'power'); Login setzt Session-Rolle
- Decorator power_oder_admin; ist_power-Helper
- Login-Kacheln: Power mit 🔧 statt Tier; Admin-Profilanlage mit Rollen-Dropdown
(Tier nur bei schueler Pflicht, Power kriegt Platzhalter-Slug 'power')
- Cockpit: kein Check-In fuer Power, stattdessen "Power-Werkzeuge"-Karte
- Power-Projekt-Regeln: mehrere parallel erlaubt, Abschluss direkt 'freigegeben'
- Rechte power_oder_admin: Drucker-Verwaltung, Software-Katalog,
Slot-fuer-SuS, inline-edit (beschraenkt auf drucker+software_seite)
- Bleibt admin-only: SuS-Profile, Projekt-Freigaben, Admin-Dashboard
- Power-relevante Admin-Templates: Zurueck-Link rollenabhaengig (Cockpit statt Dashboard)
Block C — PAROL6-Demo:
- scripts/seed_demo_parol6.py: Power-Profil 'Herb' + PAROL6-Roboterarm-Projekt
- GitHub-Repo als Link, Bauanleitung-PDF als BLOB, Cover aus 3MF-Render
- abgeschlossen+freigegeben -> im Katalog, als Vorlage waehlbar
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -39,8 +39,8 @@ bp = Blueprint("profil", __name__)
|
||||
def login():
|
||||
conn = get_db()
|
||||
profile = conn.execute(
|
||||
"SELECT id, vorname, tier FROM profil WHERE aktiv = 1 "
|
||||
"ORDER BY vorname COLLATE NOCASE, tier"
|
||||
"SELECT id, vorname, tier, rolle FROM profil WHERE aktiv = 1 "
|
||||
"ORDER BY rolle DESC, vorname COLLATE NOCASE, tier"
|
||||
).fetchall()
|
||||
conn.close()
|
||||
return render_template("login.html", profile=profile)
|
||||
@@ -50,7 +50,7 @@ def login():
|
||||
def login_pin(profil_id):
|
||||
conn = get_db()
|
||||
profil = conn.execute(
|
||||
"SELECT id, vorname, tier, pin_hash, aktiv FROM profil WHERE id = ?",
|
||||
"SELECT id, vorname, tier, pin_hash, aktiv, rolle FROM profil WHERE id = ?",
|
||||
(profil_id,)
|
||||
).fetchone()
|
||||
conn.close()
|
||||
@@ -77,6 +77,7 @@ def login_pin(profil_id):
|
||||
session["profil_id"] = profil["id"]
|
||||
session["vorname"] = profil["vorname"]
|
||||
session["tier"] = profil["tier"]
|
||||
session["rolle"] = profil["rolle"] or "schueler"
|
||||
return redirect(url_for("profil.cockpit"))
|
||||
else:
|
||||
fehlversuch_loggen(profil_id)
|
||||
@@ -681,8 +682,9 @@ def projekt_werkstatt_speichern(projekt_id):
|
||||
return redirect(url_for("profil.projekt_detail", projekt_id=projekt_id))
|
||||
|
||||
|
||||
# Max-Upload-Groesse (30 MB) — Bambu-3MF-Files sind selten groesser
|
||||
MAX_UPLOAD_BYTES = 30 * 1024 * 1024
|
||||
# Max-Upload-Groesse (60 MB) — Bambu-3MF mit mehreren Platten + Thumbnails
|
||||
# werden schnell gross. Wer noch groesser braucht, nutzt einen externen Link.
|
||||
MAX_UPLOAD_BYTES = 60 * 1024 * 1024
|
||||
|
||||
# Mapping Mime -> art (siehe Schema: art TEXT 'cover_foto'|'stl'|'3mf'|'foto'|'sonstiges')
|
||||
def _datei_art_aus_dateiname(dateiname: str, mime: str) -> str:
|
||||
@@ -741,6 +743,41 @@ def projekt_datei_upload(projekt_id):
|
||||
return jsonify(ok=True, id=neue_id, art=art, groesse=len(blob))
|
||||
|
||||
|
||||
@bp.route("/cockpit/projekt/<int:projekt_id>/link", methods=["POST"])
|
||||
@login_required
|
||||
def projekt_link_hinzufuegen(projekt_id):
|
||||
"""Externen Link als 'Datei' hinzufuegen (GitHub, MakerWorld, gehostete 3MF, ...)."""
|
||||
p = _eigenes_projekt_holen(projekt_id)
|
||||
if not p:
|
||||
flash("Projekt nicht gefunden.", "error")
|
||||
return redirect(url_for("profil.cockpit"))
|
||||
if p["status_lebenszyklus"] != "in_arbeit":
|
||||
flash("Abgeschlossene Projekte koennen keine Links mehr aufnehmen.", "error")
|
||||
return redirect(url_for("profil.projekt_detail", projekt_id=projekt_id))
|
||||
|
||||
name = (request.form.get("dateiname") or "").strip()
|
||||
url = (request.form.get("extern_url") or "").strip()
|
||||
if not url:
|
||||
flash("Bitte eine URL angeben.", "error")
|
||||
return redirect(url_for("profil.projekt_detail", projekt_id=projekt_id))
|
||||
if not (url.startswith("http://") or url.startswith("https://")):
|
||||
flash("Der Link muss mit http:// oder https:// beginnen.", "error")
|
||||
return redirect(url_for("profil.projekt_detail", projekt_id=projekt_id))
|
||||
if not name:
|
||||
name = url # Fallback: URL als Anzeigename
|
||||
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
"INSERT INTO projekt_datei (projekt_id, dateiname, extern_url, art, hochgeladen_von) "
|
||||
"VALUES (?, ?, ?, 'link', ?)",
|
||||
(projekt_id, name, url, session["profil_id"])
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
flash("Link hinzugefuegt.", "success")
|
||||
return redirect(url_for("profil.projekt_detail", projekt_id=projekt_id))
|
||||
|
||||
|
||||
@bp.route("/cockpit/projekt/<int:projekt_id>/datei/<int:datei_id>/loeschen", methods=["POST"])
|
||||
@login_required
|
||||
def projekt_datei_loeschen(projekt_id, datei_id):
|
||||
@@ -845,7 +882,11 @@ def projekt_abschluss(projekt_id):
|
||||
if ausfuehrung and ausfuehrung not in EVAL_QUALITAET:
|
||||
ausfuehrung = None
|
||||
|
||||
neuer_freigabe_status = freigabe_nach_eval(gesamt)
|
||||
# Power-User-Projekte (Demos) gehen direkt in den Katalog, kein Lehrer-Review.
|
||||
if session.get("rolle") == "power":
|
||||
neuer_freigabe_status = "freigegeben"
|
||||
else:
|
||||
neuer_freigabe_status = freigabe_nach_eval(gesamt)
|
||||
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user