Coverage for gws-app/gws/plugin/model_value/current_user/__init__.py: 0%
14 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 23:09 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 23:09 +0200
1"""Current user.
3Formats properties of the current user and returns them as a string.
5If ``format`` is configured, it must be a Python format string with a reference
6to the ``user`` param, e.g. ``"{user.displayName}_{user.isGuest}"``.
8If no ``format`` is configured, user's ``loginName`` is returned.
10"""
12import gws
13import gws.base.model.value
15gws.ext.new.modelValue('currentUser')
18class Config(gws.base.model.value.Config):
19 """Current user value configuration."""
21 format: str = ''
22 """Format string."""
25class Object(gws.base.model.value.Object):
26 format: str
28 def configure(self):
29 self.format = self.cfg('format', default='')
31 def compute(self, field, feature, mc):
32 if self.format:
33 return self.format.format(user=mc.user)
34 return mc.user.loginName