Coverage for gws-app/gws/plugin/model_value/current_user/__init__.py: 0%

14 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-17 01:37 +0200

1"""Current user. 

2 

3Formats properties of the current user and returns them as a string. 

4 

5If ``format`` is configured, it must be a Python format string with a reference 

6to the ``user`` param, e.g. ``"{user.displayName}_{user.isGuest}"``. 

7 

8If no ``format`` is configured, user's ``loginName`` is returned. 

9 

10""" 

11 

12import gws 

13import gws.base.model.value 

14 

15gws.ext.new.modelValue('currentUser') 

16 

17 

18class Config(gws.base.model.value.Config): 

19 format: str = '' 

20 """format string""" 

21 

22 

23class Object(gws.base.model.value.Object): 

24 format: str 

25 

26 def configure(self): 

27 self.format = self.cfg('format', default='') 

28 

29 def compute(self, field, feature, mc): 

30 if self.format: 

31 return self.format.format(user=mc.user) 

32 return mc.user.loginName