|  | @@ -13,12 +13,13 @@ from tracim import hapic, TracimRequest
 | 
	
		
			
			| 13 | 13 |  
 | 
	
		
			
			| 14 | 14 |  from tracim.lib.core.workspace import WorkspaceApi
 | 
	
		
			
			| 15 | 15 |  from tracim.views.controllers import Controller
 | 
	
		
			
			| 16 |  | -from tracim.views.core_api.schemas import UserIdPathSchema
 | 
	
		
			
			|  | 16 | +from tracim.views.core_api.schemas import UserIdPathSchema, ReadStatusSchema, \
 | 
	
		
			
			|  | 17 | +    ContentIdsQuerySchema
 | 
	
		
			
			| 17 | 18 |  from tracim.views.core_api.schemas import NoContentSchema
 | 
	
		
			
			| 18 | 19 |  from tracim.views.core_api.schemas import UserWorkspaceIdPathSchema
 | 
	
		
			
			| 19 | 20 |  from tracim.views.core_api.schemas import UserWorkspaceAndContentIdPathSchema
 | 
	
		
			
			| 20 |  | -from tracim.views.core_api.schemas import UserContentDigestSchema
 | 
	
		
			
			| 21 |  | -from tracim.views.core_api.schemas import ExtendedFilterQuerySchema
 | 
	
		
			
			|  | 21 | +from tracim.views.core_api.schemas import ContentDigestSchema
 | 
	
		
			
			|  | 22 | +from tracim.views.core_api.schemas import ActiveContentFilterQuerySchema
 | 
	
		
			
			| 22 | 23 |  from tracim.views.core_api.schemas import WorkspaceDigestSchema
 | 
	
		
			
			| 23 | 24 |  from tracim.models.contents import ContentTypeLegacy as ContentType
 | 
	
		
			
			| 24 | 25 |  
 | 
	
	
		
			
			|  | @@ -51,57 +52,60 @@ class UserController(Controller):
 | 
	
		
			
			| 51 | 52 |      @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
 | 
	
		
			
			| 52 | 53 |      @require_same_user_or_profile(Group.TIM_ADMIN)
 | 
	
		
			
			| 53 | 54 |      @hapic.input_path(UserIdPathSchema())
 | 
	
		
			
			| 54 |  | -    @hapic.input_query(ExtendedFilterQuerySchema())
 | 
	
		
			
			| 55 |  | -    @hapic.output_body(UserContentDigestSchema(many=True))
 | 
	
		
			
			|  | 55 | +    @hapic.input_query(ActiveContentFilterQuerySchema())
 | 
	
		
			
			|  | 56 | +    @hapic.output_body(ContentDigestSchema(many=True))
 | 
	
		
			
			| 56 | 57 |      def last_active_content(self, context, request: TracimRequest, hapic_data=None):  # nopep8
 | 
	
		
			
			| 57 | 58 |          """
 | 
	
		
			
			| 58 | 59 |          Get last_active_content for user
 | 
	
		
			
			| 59 | 60 |          """
 | 
	
		
			
			| 60 |  | -        app_config = request.registry.settings['CFG']
 | 
	
		
			
			| 61 |  | -        content_filter = hapic_data.query
 | 
	
		
			
			| 62 |  | -        api = ContentApi(
 | 
	
		
			
			| 63 |  | -            current_user=request.candidate_user,  # User
 | 
	
		
			
			| 64 |  | -            session=request.dbsession,
 | 
	
		
			
			| 65 |  | -            config=app_config,
 | 
	
		
			
			| 66 |  | -            show_archived=content_filter.show_archived,
 | 
	
		
			
			| 67 |  | -            show_deleted=content_filter.show_deleted,
 | 
	
		
			
			| 68 |  | -            show_active=content_filter.show_active,
 | 
	
		
			
			| 69 |  | -        )
 | 
	
		
			
			| 70 |  | -        wapi = WorkspaceApi(
 | 
	
		
			
			| 71 |  | -            current_user=request.candidate_user,  # User
 | 
	
		
			
			| 72 |  | -            session=request.dbsession,
 | 
	
		
			
			| 73 |  | -            config=app_config,
 | 
	
		
			
			| 74 |  | -        )
 | 
	
		
			
			| 75 |  | -        workspace = None
 | 
	
		
			
			| 76 |  | -        if content_filter.workspace_id:
 | 
	
		
			
			| 77 |  | -            workspace = wapi.get_one(content_filter.workspace_id)
 | 
	
		
			
			| 78 |  | -        last_actives = api.get_last_active(
 | 
	
		
			
			| 79 |  | -            parent_id=content_filter.parent_id,
 | 
	
		
			
			| 80 |  | -            content_type=content_filter.content_type or ContentType.Any,
 | 
	
		
			
			| 81 |  | -            workspace=workspace,
 | 
	
		
			
			| 82 |  | -            offset=content_filter.offset or None,
 | 
	
		
			
			| 83 |  | -            limit=content_filter.limit or None,
 | 
	
		
			
			| 84 |  | -        )
 | 
	
		
			
			| 85 |  | -        return [
 | 
	
		
			
			| 86 |  | -            api.get_content_in_context(content)
 | 
	
		
			
			| 87 |  | -            for content in last_actives
 | 
	
		
			
			| 88 |  | -        ]
 | 
	
		
			
			|  | 61 | +        raise NotImplemented()
 | 
	
		
			
			|  | 62 | +        # app_config = request.registry.settings['CFG']
 | 
	
		
			
			|  | 63 | +        # content_filter = hapic_data.query
 | 
	
		
			
			|  | 64 | +        # api = ContentApi(
 | 
	
		
			
			|  | 65 | +        #     current_user=request.candidate_user,  # User
 | 
	
		
			
			|  | 66 | +        #     session=request.dbsession,
 | 
	
		
			
			|  | 67 | +        #     config=app_config,
 | 
	
		
			
			|  | 68 | +        #     show_archived=content_filter.show_archived,
 | 
	
		
			
			|  | 69 | +        #     show_deleted=content_filter.show_deleted,
 | 
	
		
			
			|  | 70 | +        #     show_active=content_filter.show_active,
 | 
	
		
			
			|  | 71 | +        # )
 | 
	
		
			
			|  | 72 | +        # wapi = WorkspaceApi(
 | 
	
		
			
			|  | 73 | +        #     current_user=request.candidate_user,  # User
 | 
	
		
			
			|  | 74 | +        #     session=request.dbsession,
 | 
	
		
			
			|  | 75 | +        #     config=app_config,
 | 
	
		
			
			|  | 76 | +        # )
 | 
	
		
			
			|  | 77 | +        # workspace = None
 | 
	
		
			
			|  | 78 | +        # if content_filter.workspace_id:
 | 
	
		
			
			|  | 79 | +        #     workspace = wapi.get_one(content_filter.workspace_id)
 | 
	
		
			
			|  | 80 | +        # last_actives = api.get_last_active(
 | 
	
		
			
			|  | 81 | +        #     parent_id=content_filter.parent_id,
 | 
	
		
			
			|  | 82 | +        #     content_type=content_filter.content_type or ContentType.Any,
 | 
	
		
			
			|  | 83 | +        #     workspace=workspace,
 | 
	
		
			
			|  | 84 | +        #     offset=content_filter.offset or None,
 | 
	
		
			
			|  | 85 | +        #     limit=content_filter.limit or None,
 | 
	
		
			
			|  | 86 | +        # )
 | 
	
		
			
			|  | 87 | +        # return [
 | 
	
		
			
			|  | 88 | +        #     api.get_content_in_context(content)
 | 
	
		
			
			|  | 89 | +        #     for content in last_actives
 | 
	
		
			
			|  | 90 | +        # ]
 | 
	
		
			
			| 89 | 91 |  
 | 
	
		
			
			| 90 | 92 |      @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
 | 
	
		
			
			| 91 | 93 |      @require_same_user_or_profile(Group.TIM_ADMIN)
 | 
	
		
			
			| 92 | 94 |      @hapic.input_path(UserWorkspaceAndContentIdPathSchema())
 | 
	
		
			
			| 93 |  | -    @hapic.output_body(UserContentDigestSchema())  # nopep8
 | 
	
		
			
			| 94 |  | -    def user_content(self, context, request: TracimRequest, hapic_data=None):  # nopep8
 | 
	
		
			
			|  | 95 | +    @hapic.input_query(ContentIdsQuerySchema())
 | 
	
		
			
			|  | 96 | +    @hapic.output_body(ReadStatusSchema(many=True))  # nopep8
 | 
	
		
			
			|  | 97 | +    def contents_read_status(self, context, request: TracimRequest, hapic_data=None):  # nopep8
 | 
	
		
			
			| 95 | 98 |          """
 | 
	
		
			
			| 96 |  | -        set user_read status of content to unread
 | 
	
		
			
			|  | 99 | +        get user_read status of contents
 | 
	
		
			
			| 97 | 100 |          """
 | 
	
		
			
			| 98 |  | -        app_config = request.registry.settings['CFG']
 | 
	
		
			
			| 99 |  | -        api = ContentApi(
 | 
	
		
			
			| 100 |  | -            current_user=request.candidate_user,
 | 
	
		
			
			| 101 |  | -            session=request.dbsession,
 | 
	
		
			
			| 102 |  | -            config=app_config,
 | 
	
		
			
			| 103 |  | -        )
 | 
	
		
			
			| 104 |  | -        return api.get_content_in_context(request.current_content)
 | 
	
		
			
			|  | 101 | +        raise NotImplemented()
 | 
	
		
			
			|  | 102 | +        # app_config = request.registry.settings['CFG']
 | 
	
		
			
			|  | 103 | +        # api = ContentApi(
 | 
	
		
			
			|  | 104 | +        #     current_user=request.candidate_user,
 | 
	
		
			
			|  | 105 | +        #     session=request.dbsession,
 | 
	
		
			
			|  | 106 | +        #     config=app_config,
 | 
	
		
			
			|  | 107 | +        # )
 | 
	
		
			
			|  | 108 | +        # return api.get_content_in_context(request.current_content)
 | 
	
		
			
			| 105 | 109 |  
 | 
	
		
			
			| 106 | 110 |      @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
 | 
	
		
			
			| 107 | 111 |      @require_same_user_or_profile(Group.TIM_ADMIN)
 | 
	
	
		
			
			|  | @@ -165,10 +169,10 @@ class UserController(Controller):
 | 
	
		
			
			| 165 | 169 |          configurator.add_view(self.user_workspace, route_name='user_workspace')
 | 
	
		
			
			| 166 | 170 |  
 | 
	
		
			
			| 167 | 171 |          # user content
 | 
	
		
			
			| 168 |  | -        configurator.add_route('user_content', '/users/{user_id}/workspaces/{workspace_id}/contents/{content_id}', request_method='GET')  # nopep8
 | 
	
		
			
			| 169 |  | -        configurator.add_view(self.user_content, route_name='user_content')
 | 
	
		
			
			|  | 172 | +        configurator.add_route('contents_read_status', '/users/{user_id}/workspaces/{workspace_id}/contents/read_status', request_method='GET')  # nopep8
 | 
	
		
			
			|  | 173 | +        configurator.add_view(self.contents_read_status, route_name='contents_read_status')  # nopep8
 | 
	
		
			
			| 170 | 174 |          # last active content for user
 | 
	
		
			
			| 171 |  | -        configurator.add_route('last_active_content', '/users/{user_id}/contents/actives', request_method='GET')  # nopep8
 | 
	
		
			
			|  | 175 | +        configurator.add_route('last_active_content', '/users/{user_id}/workspaces/{workspace_id}/contents/recently_active', request_method='GET')  # nopep8
 | 
	
		
			
			| 172 | 176 |          configurator.add_view(self.last_active_content, route_name='last_active_content')  # nopep8
 | 
	
		
			
			| 173 | 177 |  
 | 
	
		
			
			| 174 | 178 |          # set content as read/unread
 |