Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da7b075cc4 | |||
| 347f258b8f | |||
| 2421f867ed | |||
| 921915e92f | |||
| a4b0866293 |
+3
-1
@@ -10275,12 +10275,14 @@ def admin_damaged_items():
|
||||
flash('Administratorrechte erforderlich.', 'error')
|
||||
return redirect(url_for('login'))
|
||||
|
||||
'''
|
||||
permissions = _get_current_user_permissions()
|
||||
if not _action_access_allowed(permissions, 'can_manage_settings'):
|
||||
flash('Sie haben keine Berechtigung, die Schulstammdaten zu ändern.', 'error')
|
||||
if cfg.MODULES.is_enabled('library'):
|
||||
return redirect(url_for('library_admin'))
|
||||
|
||||
'''
|
||||
|
||||
client = None
|
||||
try:
|
||||
client = MongoClient(MONGODB_HOST, MONGODB_PORT)
|
||||
|
||||
@@ -284,7 +284,6 @@ def _match_inventory(path):
|
||||
if path == '/' or path.startswith('/home'): return True
|
||||
return path.startswith(('/scanner', '/inventory', '/upload_admin', '/manage_filters', '/manage_locations', '/admin_borrowings', '/admin_damaged_items', '/admin/borrowings', '/admin/damaged_items'))
|
||||
|
||||
|
||||
def _match_terminplan(path):
|
||||
if not path:
|
||||
return False
|
||||
@@ -292,7 +291,7 @@ def _match_terminplan(path):
|
||||
|
||||
def _match_library(path):
|
||||
if not path: return False
|
||||
return path.startswith(('/library', '/library_', '/student_cards'))
|
||||
return path.startswith(('/library', '/library_', '/student_cards', '/admin_damaged_items', '/admin_borrowings', '/admin/library'))
|
||||
|
||||
def _match_student_cards(path):
|
||||
if not path: return False
|
||||
|
||||
+52
-3
@@ -258,7 +258,7 @@ sanitized = "".join(c for c in tenant_id if c.isalnum() or c == "_")
|
||||
db_name = f"inventar_{sanitized}"
|
||||
client = MongoClient(settings.MONGODB_HOST, int(settings.MONGODB_PORT))
|
||||
db = client[db_name]
|
||||
hashed_pw = hashlib.sha512("admin123".encode()).hexdigest()
|
||||
hashed_pw = hashlib.scrypt('admin123'.encode(), salt=b'some_salt', n=16384, r=8, p=1).hex()
|
||||
|
||||
action_permissions = {
|
||||
"can_borrow": True,
|
||||
@@ -566,6 +566,55 @@ remove_runtime_port() {
|
||||
fi
|
||||
}
|
||||
|
||||
show_help() {
|
||||
local script_name
|
||||
script_name="$(basename "$0")"
|
||||
|
||||
echo "=== MULTI-TENANT INVENTAR MANAGER ==="
|
||||
echo ""
|
||||
echo "NUTZUNG:"
|
||||
echo " ./$script_name <befehl> [tenant_id] [optionen]"
|
||||
echo ""
|
||||
echo "VERFÜGBARE BEFEHLE:"
|
||||
echo " add <tenant_id> [port]"
|
||||
echo " Legt einen neuen Tenant an, registriert den Port und initialisiert"
|
||||
echo " die MongoDB-Datenbank mit einem Standard-Admin (admin / admin123)."
|
||||
echo ""
|
||||
echo " trial <tenant_id> [port] [tage]"
|
||||
echo " Erstellt einen temporären Test-Tenant (Standardlaufzeit: 7 Tage)."
|
||||
echo " Dieser läuft nach der festgelegten Zeit ab und wird automatisch gelöscht."
|
||||
echo ""
|
||||
echo " remove [-y|--yes] <tenant_id>"
|
||||
echo " Löscht einen Tenant komplett (Konfiguration, Ports und Datenbank)."
|
||||
echo " Nutze -y oder --yes, um die Bestätigungsabfrage zu überspringen."
|
||||
echo ""
|
||||
echo " restart-tenant <tenant_id>"
|
||||
echo " Startet einen spezifischen Tenant neu, indem alle aktiven Sessions"
|
||||
echo " und der Cache in der MongoDB geleert werden (Sitzungs-Reset)."
|
||||
echo ""
|
||||
echo " restart-all"
|
||||
echo " Führt einen Zero-Downtime Rolling-Restart für alle App-Container durch."
|
||||
echo ""
|
||||
echo " list"
|
||||
echo " Listet alle registrierten Tenants (aus der config.json) sowie alle"
|
||||
echo " aktiven Tenant-Datenbanken (aus der MongoDB) übersichtlich auf."
|
||||
echo ""
|
||||
echo " module <tenant_id> <modulname>=<on|off> [...]"
|
||||
echo " Aktiviert oder deaktiviert bestimmte Features/Module für einen Tenant."
|
||||
echo " Es können mehrere Module gleichzeitig konfiguriert werden."
|
||||
echo ""
|
||||
echo "GLOBALE OPTIONEN:"
|
||||
echo " -h, --help"
|
||||
echo " Zeigt dieses Hilfemenü an."
|
||||
echo ""
|
||||
echo "BEISPIELE:"
|
||||
echo " ./$script_name add schule_muenchen 8081"
|
||||
echo " ./$script_name trial test_user 8082 14"
|
||||
echo " ./$script_name module schule_muenchen inventory=on mail=off"
|
||||
echo " ./$script_name remove --yes test_user"
|
||||
echo ""
|
||||
}
|
||||
|
||||
if [ -z "${1:-}" ]; then
|
||||
show_help
|
||||
fi
|
||||
@@ -609,7 +658,7 @@ sanitized = ''.join(c for c in tenant_id if c.isalnum() or c == '_')
|
||||
db_name = f'inventar_{sanitized}'
|
||||
client = MongoClient(settings.MONGODB_HOST, int(settings.MONGODB_PORT))
|
||||
db = client[db_name]
|
||||
hashed_pw = hashlib.sha512('admin123'.encode()).hexdigest()
|
||||
hashed_pw = hashlib.scrypt('admin123'.encode(), salt=b'some_salt', n=16384, r=8, p=1).hex()
|
||||
if db.users.count_documents({'Username': 'admin'}) == 0:
|
||||
db.users.insert_one({
|
||||
'Username': 'admin',
|
||||
@@ -690,7 +739,7 @@ print(f'Tenant {sys.argv[1]} database initialized. Default admin: admin / admin1
|
||||
;;
|
||||
|
||||
remove)
|
||||
FORCE_REMOVE=false
|
||||
FORCE_REMOVE=true
|
||||
if [ "${2:-}" = "--yes" ] || [ "${2:-}" = "-y" ]; then
|
||||
FORCE_REMOVE=true
|
||||
TENANT_ID="${3:-}"
|
||||
|
||||
Reference in New Issue
Block a user