Coverage for gws-app/gws/base/project/action.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Project information action.""" 

2 

3from typing import Optional 

4 

5import gws 

6import gws.base.action 

7import gws.base.auth.user 

8import gws.lib.intl 

9 

10 

11@gws.ext.config.action('project') 

12class Config(gws.base.action.Config): 

13 """Returns the project configuration to the client.""" 

14 

15 pass 

16 

17 

18@gws.ext.props.action('project') 

19class Props(gws.base.action.Props): 

20 pass 

21 

22 

23class InfoResponse(gws.Response): 

24 """Response of the ``projectInfo`` command.""" 

25 

26 project: gws.ext.props.project 

27 """Project properties for the current user.""" 

28 locale: gws.Locale 

29 """Locale for the request.""" 

30 user: Optional[gws.base.auth.user.Props] 

31 """Current user, or ``None`` for a guest.""" 

32 

33 

34@gws.ext.object.action('project') 

35class Object(gws.base.action.Object): 

36 """Project action, provides the project configuration to the client.""" 

37 

38 @gws.ext.command.api('projectInfo') 

39 def info(self, req: gws.WebRequester, p: gws.Request) -> InfoResponse: 

40 """Return the project properties, the locale and the current user.""" 

41 

42 project = req.user.require_project(p.projectUid) 

43 

44 return InfoResponse( 

45 project=gws.props_of(project, req.user), 

46 locale=gws.lib.intl.locale(p.localeUid, project.localeUids), 

47 user=None if req.user.isGuest else gws.props_of(req.user, req.user), 

48 )