mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-22 10:15:13 -05:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user