Skip to content

Commit

Permalink
doc: add User permissions docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Apr 7, 2024
1 parent c0a28c1 commit ebf790a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions canaille/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from flask import current_app

from canaille.backends.models import Model
from canaille.core.configuration import Permission


class User(Model):
Expand Down Expand Up @@ -273,7 +274,10 @@ def __getattr__(self, name):

return super().__getattr__(name)

def can(self, *permissions):
def can(self, *permissions: Permission):
"""Wether or not the user has the
:class:`~canaille.core.configuration.Permission` according to the
:class:`configuration <canaille.core.configuration.ACLSettings>`."""
if self._permissions is None:
self.load_permissions()

Expand Down Expand Up @@ -305,13 +309,21 @@ def reload(self):

@property
def readable_fields(self):
if self._writable_fields is None:
"""The fields the user can read according to the :class:`configuration
<canaille.core.configuration.ACLSettings>` configuration.
This does not include the :attr:`writable
<canaille.core.models.User.writable_fields>` fields.
"""
if self.readable_fields is None:
self.load_permissions()

return self._readable_fields

@property
def writable_fields(self):
"""The fields the user can write according to the :class:`configuration
<canaille.core.configuration.ACLSettings>`."""
if self._writable_fields is None:
self.load_permissions()

Expand Down

0 comments on commit ebf790a

Please sign in to comment.