Feature/improve localization (#1147)

* use locale to set language header

* rewrite i18n provider and drop dependency

* rename file

* rename CrudMixin to HttpRepo

* refactor: code-cleanup

* add crowdin source

* remove unused translations

* grab translations from dev branch

* add translation support for foods, units, and labels

* remove rich import
This commit is contained in:
Hayden
2022-04-10 14:07:35 -08:00
committed by GitHub
parent db095656e1
commit 7866f0f46e
71 changed files with 4736 additions and 3642 deletions

View File

@@ -11,29 +11,26 @@ class OperationChecks:
user: PrivateUser
ForbiddenException = HTTPException(status.HTTP_403_FORBIDDEN)
UnauthorizedException = HTTPException(status.HTTP_401_UNAUTHORIZED)
def __init__(self, user: PrivateUser) -> None:
self.user = user
def _raise_unauthorized(self) -> None:
raise HTTPException(status.HTTP_401_UNAUTHORIZED)
def _raise_forbidden(self) -> None:
raise HTTPException(status.HTTP_403_FORBIDDEN)
# =========================================
# User Permission Checks
def can_manage(self) -> bool:
if not self.user.can_manage:
self._raise_forbidden()
raise self.ForbiddenException
return True
def can_invite(self) -> bool:
if not self.user.can_invite:
self._raise_forbidden()
raise self.ForbiddenException
return True
def can_organize(self) -> bool:
if not self.user.can_organize:
self._raise_forbidden()
raise self.ForbiddenException
return True