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
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Project information action."""
3from typing import Optional
5import gws
6import gws.base.action
7import gws.base.auth.user
8import gws.lib.intl
11@gws.ext.config.action('project')
12class Config(gws.base.action.Config):
13 """Returns the project configuration to the client."""
15 pass
18@gws.ext.props.action('project')
19class Props(gws.base.action.Props):
20 pass
23class InfoResponse(gws.Response):
24 """Response of the ``projectInfo`` command."""
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."""
34@gws.ext.object.action('project')
35class Object(gws.base.action.Object):
36 """Project action, provides the project configuration to the client."""
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."""
42 project = req.user.require_project(p.projectUid)
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 )