about summary refs log tree commit diff
path: root/gn3/auth/authorisation/privileges.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/auth/authorisation/privileges.py')
-rw-r--r--gn3/auth/authorisation/privileges.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/gn3/auth/authorisation/privileges.py b/gn3/auth/authorisation/privileges.py
index 6cfd1d8..ae4ed88 100644
--- a/gn3/auth/authorisation/privileges.py
+++ b/gn3/auth/authorisation/privileges.py
@@ -1,5 +1,5 @@
 """Handle privileges"""
-from typing import Iterable, NamedTuple
+from typing import Any, Iterable, NamedTuple
 
 from gn3.auth import db
 from gn3.auth.authentication.users import User
@@ -9,6 +9,13 @@ class Privilege(NamedTuple):
     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."""
     with db.cursor(conn) as cursor: