diff options
| author | Frederick Muriuki Muriithi | 2026-04-02 16:16:47 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-02 16:16:47 -0500 |
| commit | 5e4f320440f4cb49ebc61b286a1baebc5f66740f (patch) | |
| tree | 3c1462ad95645c36052cd2d8cd0a3f54e86a7473 /gn_auth | |
| parent | 4503ed2e603899c27a89e167728649c57675e9b7 (diff) | |
| download | gn-auth-5e4f320440f4cb49ebc61b286a1baebc5f66740f.tar.gz | |
Add the creator of the resource and the time the resource was created.
Diffstat (limited to 'gn_auth')
| -rw-r--r-- | gn_auth/auth/authorisation/resources/models.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py index b8eaacb..c3d0f7e 100644 --- a/gn_auth/auth/authorisation/resources/models.py +++ b/gn_auth/auth/authorisation/resources/models.py @@ -1,4 +1,5 @@ """Handle the management of resources.""" +from datetime import datetime from dataclasses import asdict from uuid import UUID, uuid4 from functools import reduce, partial @@ -46,17 +47,20 @@ def create_resource(# pylint: disable=[too-many-arguments, too-many-positional-a resource_category: ResourceCategory, user: User, group: Group, - public: bool + public: bool, + created_at: datetime = datetime.now() ) -> Resource: """Create a resource item.""" def __create_resource__(cursor: db.DbCursor) -> Resource: resource = Resource(uuid4(), resource_name, resource_category, public) cursor.execute( - "INSERT INTO resources VALUES (?, ?, ?, ?)", + "INSERT INTO resources VALUES (?, ?, ?, ?, ?, ?)", (str(resource.resource_id), resource_name, str(resource.resource_category.resource_category_id), - 1 if resource.public else 0)) + 1 if resource.public else 0, + str(user.user_id), + created_at.timestamp())) # TODO: @fredmanglis,@rookie101 # 1. Move the actions below into a (the?) hooks system # 2. Do more checks: A resource can have varying hooks depending on type |
