Führe Hauptnutzer und Mitarbeiter ein, damit der Betreiber Kunden und Hauptnutzer ihre Teams verwalten.
Eine Einladung erzeugt jetzt ein Mitarbeiter-Konto mit dem Eigentümer des Raums als Förderer. Mitarbeiter arbeiten nur in den eingeladenen Räumen nach ihrer Rolle, legen keine Räume und im persönlichen Raum nichts an und starten ihre Sitzung im Team-Raum. Einladen darf nur der Eigentümer als Hauptnutzer; nur ein Hauptnutzer kann Raum-Eigentümer sein. Hauptnutzer sehen unter Mein Team die Personen in ihren Räumen und verwalten ihre Mitarbeiter (deaktivieren, Einmal-Passwort, aus Räumen entfernen). Der Betreiber sieht die Team-Übersicht mit CSV-Export und macht einen Mitarbeiter zum Hauptnutzer. Eine zentrale Prüfstelle für Grenzen (access/limits.py) wird beim Anlegen von Räumen und beim Aufnehmen und Einladen von Mitgliedern aufgerufen; Tarife folgen später. Die lokale Suite läuft mit 143 Tests grün, der Frontend-Build und 24 Node-Tests ebenfalls. Die Oberfläche wurde noch nicht im Browser bedient. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e47f50d513
commit
6d7b7c5f85
26 files changed
+966
-43
No files matched your search
@@ -0,0 +1,26 @@
|
||||
"""The one place where subscription limits will be checked.
|
||||
|
||||
Today there are no limits. The checks are called where a limit will matter, so that a plan
|
||||
can be added without touching the callers.
|
||||
|
||||
Target model (see the entitlements blueprint): the quota subject is the owner of a room, a main
|
||||
user, like the club at Shinkan. A plan, set by the operator, may later cap the number of active
|
||||
employees per main user and per room. The count comes from the database, never from the client.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
def ensure_can_create_room(conn, owner_id: UUID) -> None:
|
||||
"""Called before a main user creates a room."""
|
||||
del conn, owner_id
|
||||
|
||||
|
||||
def ensure_can_add_member(conn, owner_id: UUID, room_id: UUID) -> None:
|
||||
"""Called before a person becomes an active member of a room or is invited to it.
|
||||
|
||||
``owner_id`` is the owner of the room, the future quota subject.
|
||||
"""
|
||||
del conn, owner_id, room_id
|
||||
@@ -19,6 +19,17 @@ ROOM_ROLE_LABELS = {
|
||||
}
|
||||
|
||||
|
||||
def account_kind(conn, account_id: UUID) -> str | None:
|
||||
row = conn.execute("SELECT account_kind FROM auth_accounts WHERE id = %s AND status = 'active'", (account_id,)).fetchone()
|
||||
return row["account_kind"] if row else None
|
||||
|
||||
|
||||
def require_main_user(conn, account_id: UUID) -> None:
|
||||
"""Employees work in the rooms they were invited to. They create no rooms of their own."""
|
||||
if account_kind(conn, account_id) != "main":
|
||||
raise forbidden("Als Mitarbeiter arbeitest du in den Räumen, in die du eingeladen wurdest.")
|
||||
|
||||
|
||||
def is_operator(conn, account_id: UUID) -> bool:
|
||||
row = conn.execute(
|
||||
"SELECT is_superadmin FROM auth_accounts WHERE id = %s AND status = 'active'",
|
||||
@@ -58,6 +69,7 @@ def require_room_write(conn, account_id: UUID, room: dict) -> None:
|
||||
if room["kind"] == "personal":
|
||||
if room["id"] != account_id:
|
||||
raise forbidden("Der persönliche Datenraum gehört zu einem anderen Konto.")
|
||||
require_main_user(conn, account_id)
|
||||
return
|
||||
role = room_role(conn, account_id, room["id"])
|
||||
if role in {"member", "manager"}:
|
||||
|
||||
Reference in new issue
Block a user