aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/privileges.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn_auth/auth/authorisation/privileges.py')
-rw-r--r--gn_auth/auth/authorisation/privileges.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/gn_auth/auth/authorisation/privileges.py b/gn_auth/auth/authorisation/privileges.py
index bba6258..99f41fc 100644
--- a/gn_auth/auth/authorisation/privileges.py
+++ b/gn_auth/auth/authorisation/privileges.py
@@ -1,20 +1,17 @@
"""Handle privileges"""
-from typing import Any, Iterable, NamedTuple
+from dataclasses import dataclass
+from typing import Any, Iterable
from ..db import sqlite3 as db
from ..authentication.users import User
-class Privilege(NamedTuple):
+
+@dataclass(frozen=True)
+class Privilege:
"""Class representing a privilege: creates immutable objects."""
privilege_id: str
privilege_description: str
- def dictify(self) -> dict[str, Any]:
- """Return a dict representation of `Privilege` objects."""
- return {
- "privilege_id": self.privilege_id,
- "privilege_description": self.privilege_description
- }
def user_privileges(conn: db.DbConnection, user: User) -> Iterable[Privilege]:
"""Fetch the user's privileges from the database."""