Server: CRM-Domain mit REST-API, Autorisierung und CLI
Neues crm-Paket mit Datenmodell, Geschäftslogik und REST-Endpunkten
für die Entität Kunde (/xhr/kunde/{list,get,create,update,delete}).
authorisation_required-Decorator: app-spezifische Rollenprüfung via
has_permission(appid, ...). SysAdmin systemweit, AppAdmin implizit in
seiner Anwendung, User (Mitarbeiter) als Basis-Rolle, Zusatz-Rollen
wie KundenManager additiv.
Flask CLI: init-db (Schema + Musterdaten + App-Rollen) und reset-db
(Bestätigung, behält SysAdmin).
config.ini: Neuer appid-Eintrag (KBPlusCRM), getrennt vom technischen
PROJEKTNAME. checkdb: appid aus config, Migration _db_V01_02 für
bestehende DBs.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
65f81a0ee8
commit
13eaaec9c1
12 files changed
+627
-8
No files matched your search
@@ -3,6 +3,7 @@ from auth import model
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.exc import OperationalError
|
||||
from datetime import datetime
|
||||
from flask import current_app
|
||||
from db import dbauth
|
||||
|
||||
session = dbauth.session
|
||||
@@ -48,8 +49,11 @@ def _db_V01_01():
|
||||
|
||||
application = model.Application()
|
||||
application.id = 1
|
||||
application.appid = "Project01"
|
||||
application.name = "Project01 (Name ändern)"
|
||||
# appid und name aus der Konfiguration übernehmen (config.ini [APP] appid).
|
||||
# Die appid ist der lesbare Anwendungsname, der zur Autorisierung verwendet
|
||||
# wird; nicht identisch mit PROJEKTNAME (technischer Bezeichner).
|
||||
application.appid = current_app.config["APPID"]
|
||||
application.name = current_app.config["APPID"]
|
||||
session.add(application)
|
||||
|
||||
userapp = model.Userapp()
|
||||
@@ -61,6 +65,23 @@ def _db_V01_01():
|
||||
_updatesysteminfo('01.01')
|
||||
session.commit()
|
||||
|
||||
def _db_V01_02():
|
||||
"""
|
||||
Migriert bestehende Application-Datensätze, deren appid noch den alten
|
||||
Platzhalter 'Project01' enthält, auf die appid aus der aktuellen Konfiguration
|
||||
(config.ini [APP] appid). Wird nach reset-db nicht benötigt (da _db_V01_01
|
||||
direkt den korrekten Wert setzt), greift aber bei Upgrades bestehender DBs.
|
||||
"""
|
||||
appid = current_app.config["APPID"]
|
||||
application: model.Application = model.Application.query.filter(
|
||||
model.Application.appid == "Project01"
|
||||
).first()
|
||||
if application is not None:
|
||||
application.appid = appid
|
||||
application.name = appid
|
||||
_updatesysteminfo('01.02')
|
||||
session.commit()
|
||||
|
||||
def _updatesysteminfo(versionnr):
|
||||
s: model.Systeminfo = model.Systeminfo.query.get(1)
|
||||
s.version = versionnr
|
||||
|
||||
Reference in new issue
Block a user