|
@@ -51,61 +51,73 @@ class UserController(Controller):
|
51
|
51
|
|
52
|
52
|
@hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
|
53
|
53
|
@require_same_user_or_profile(Group.TIM_ADMIN)
|
54
|
|
- @hapic.input_path(UserIdPathSchema())
|
|
54
|
+ @hapic.input_path(UserWorkspaceIdPathSchema())
|
55
|
55
|
@hapic.input_query(ActiveContentFilterQuerySchema())
|
56
|
56
|
@hapic.output_body(ContentDigestSchema(many=True))
|
57
|
57
|
def last_active_content(self, context, request: TracimRequest, hapic_data=None):
|
58
|
58
|
"""
|
59
|
59
|
Get last_active_content for user
|
60
|
60
|
"""
|
61
|
|
- raise NotImplemented()
|
62
|
|
-
|
63
|
|
-
|
64
|
|
-
|
65
|
|
-
|
66
|
|
-
|
67
|
|
-
|
68
|
|
-
|
69
|
|
-
|
70
|
|
-
|
71
|
|
-
|
72
|
|
-
|
73
|
|
-
|
74
|
|
-
|
75
|
|
-
|
76
|
|
-
|
77
|
|
-
|
78
|
|
-
|
79
|
|
-
|
80
|
|
-
|
81
|
|
-
|
82
|
|
-
|
83
|
|
-
|
84
|
|
-
|
85
|
|
-
|
86
|
|
-
|
87
|
|
-
|
88
|
|
-
|
89
|
|
-
|
90
|
|
-
|
|
61
|
+ app_config = request.registry.settings['CFG']
|
|
62
|
+ content_filter = hapic_data.query
|
|
63
|
+ api = ContentApi(
|
|
64
|
+ current_user=request.candidate_user,
|
|
65
|
+ session=request.dbsession,
|
|
66
|
+ config=app_config,
|
|
67
|
+ )
|
|
68
|
+ wapi = WorkspaceApi(
|
|
69
|
+ current_user=request.candidate_user,
|
|
70
|
+ session=request.dbsession,
|
|
71
|
+ config=app_config,
|
|
72
|
+ )
|
|
73
|
+ workspace = None
|
|
74
|
+ if hapic_data.path.workspace_id:
|
|
75
|
+ workspace = wapi.get_one(hapic_data.path.workspace_id)
|
|
76
|
+ last_actives = api.get_last_active(
|
|
77
|
+ workspace=workspace,
|
|
78
|
+ limit=content_filter.limit or None,
|
|
79
|
+ before_datetime=content_filter.before_datetime or None,
|
|
80
|
+ )
|
|
81
|
+ return [
|
|
82
|
+ api.get_content_in_context(content)
|
|
83
|
+ for content in last_actives
|
|
84
|
+ ]
|
91
|
85
|
|
92
|
86
|
@hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
|
93
|
87
|
@require_same_user_or_profile(Group.TIM_ADMIN)
|
94
|
|
- @hapic.input_path(UserWorkspaceAndContentIdPathSchema())
|
|
88
|
+ @hapic.input_path(UserWorkspaceIdPathSchema())
|
95
|
89
|
@hapic.input_query(ContentIdsQuerySchema())
|
96
|
90
|
@hapic.output_body(ReadStatusSchema(many=True)) # nopep8
|
97
|
91
|
def contents_read_status(self, context, request: TracimRequest, hapic_data=None):
|
98
|
92
|
"""
|
99
|
93
|
get user_read status of contents
|
100
|
94
|
"""
|
101
|
|
- raise NotImplemented()
|
102
|
|
-
|
103
|
|
-
|
104
|
|
-
|
105
|
|
-
|
106
|
|
-
|
107
|
|
-
|
108
|
|
-
|
|
95
|
+ app_config = request.registry.settings['CFG']
|
|
96
|
+ content_filter = hapic_data.query
|
|
97
|
+ api = ContentApi(
|
|
98
|
+ current_user=request.candidate_user,
|
|
99
|
+ session=request.dbsession,
|
|
100
|
+ config=app_config,
|
|
101
|
+ )
|
|
102
|
+ wapi = WorkspaceApi(
|
|
103
|
+ current_user=request.candidate_user,
|
|
104
|
+ session=request.dbsession,
|
|
105
|
+ config=app_config,
|
|
106
|
+ )
|
|
107
|
+ workspace = None
|
|
108
|
+ if hapic_data.path.workspace_id:
|
|
109
|
+ workspace = wapi.get_one(hapic_data.path.workspace_id)
|
|
110
|
+ last_actives = api.get_last_active(
|
|
111
|
+ workspace=workspace,
|
|
112
|
+ limit=None,
|
|
113
|
+ before_datetime=None,
|
|
114
|
+ content_ids=hapic_data.query.contents_ids or None
|
|
115
|
+ )
|
|
116
|
+ return [
|
|
117
|
+ api.get_content_in_context(content)
|
|
118
|
+ for content in last_actives
|
|
119
|
+ ]
|
|
120
|
+
|
109
|
121
|
|
110
|
122
|
@hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
|
111
|
123
|
@require_same_user_or_profile(Group.TIM_ADMIN)
|