57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
from dataclasses import dataclass, field
|
|
from typing import List, Optional
|
|
|
|
|
|
@dataclass
|
|
class Account:
|
|
name: str
|
|
vorname: str
|
|
emailadresse: str
|
|
pleskhost: str
|
|
keriohost: str
|
|
nextcloudhost: str
|
|
kerioemailkennwort: str
|
|
pleskemailkennwort: str
|
|
nextcloudgruppe: str = ""
|
|
nextcloudspeicher: Optional[int] = None # GB; None = unlimitiert
|
|
nextcloudkennwort: str = ""
|
|
|
|
@property
|
|
def vollname(self) -> str:
|
|
return f"{self.vorname} {self.name}".strip()
|
|
|
|
@property
|
|
def nextcloud_username(self) -> str:
|
|
return derive_nc_username(self.vorname, self.name)
|
|
|
|
|
|
def derive_nc_username(vorname: str, name: str) -> str:
|
|
"""vorname.nachname, lowercase, Umlaute transliteriert, sichere Zeichen."""
|
|
s = f"{vorname.strip().lower()}.{name.strip().lower()}"
|
|
s = (s.replace("ä", "ae").replace("ö", "oe")
|
|
.replace("ü", "ue").replace("ß", "ss"))
|
|
out = []
|
|
for ch in s:
|
|
if ch.isalnum() or ch in "._-":
|
|
out.append(ch)
|
|
else:
|
|
out.append("-")
|
|
return "".join(out).strip("-.")
|
|
|
|
|
|
@dataclass
|
|
class StepResult:
|
|
service: str
|
|
status: str # "angelegt" | "übersprungen" | "Fehler"
|
|
detail: str = ""
|
|
|
|
|
|
@dataclass
|
|
class AccountResult:
|
|
account: Account
|
|
steps: List[StepResult] = field(default_factory=list)
|
|
|
|
@property
|
|
def has_errors(self) -> bool:
|
|
return any(s.status == "Fehler" for s in self.steps)
|