Initial Commit für das Grundgerüst der Anwendung, bestehend aus der Dev-Container Konfiguration, der Docker und docker-Compose Definitionen sowie der Verzeichnisse App_Server für die Backend-Programme sowie Client für die browserseitigen GUI-Komponenten
This commit is contained in:
1 parent
10549934ea
commit
1ba78992a6
63 files changed
+5410
No files matched your search
@@ -0,0 +1,38 @@
|
||||
|
||||
class ApplicationError(Exception):
|
||||
def __init__(self, *messages, htmlstatus=400):
|
||||
self.htmlstatus = htmlstatus
|
||||
Exception.__init__(self, *messages)
|
||||
|
||||
@property
|
||||
def error(self):
|
||||
error = {
|
||||
"status": self.htmlstatus,
|
||||
"messages": list(self.args)
|
||||
}
|
||||
return error
|
||||
|
||||
class AutorisationError(ApplicationError):
|
||||
def __init__(self, allowed_roles=[], user_roles=[]):
|
||||
self.allowed_roles = allowed_roles
|
||||
self.user_roles = user_roles
|
||||
|
||||
if user_roles is None:
|
||||
userrolestxt = "NoSysAdmin"
|
||||
else:
|
||||
userrolestxt = ", ".join([role.name for role in self.user_roles])
|
||||
|
||||
ApplicationError.__init__(self,
|
||||
"Sie haben nicht die passende Rolle für diese Funktion",
|
||||
"Ihre Rollen sind: " + userrolestxt,
|
||||
"Erforderliche Rollen sind: " + ", ".join(self.allowed_roles), htmlstatus=HtmlStatusCode.Unauthorized)
|
||||
|
||||
class HtmlStatusCode():
|
||||
Bad_Request = 400
|
||||
Unauthorized = 401
|
||||
Payment_Required = 402
|
||||
Forbidden = 403
|
||||
Not_Found = 404
|
||||
Method_Not_Allowed = 405
|
||||
|
||||
|
||||
Reference in new issue
Block a user