示例#1
0
    class GET(FollowingSearchHandler):
        meta_serializer = DatasetsMeta()
        request_schema = DatasetsList()
        response_serializer = DatasetSerializer(many=True,
                                                include_data=('institution', ))
        search_document = DatasetsDoc()

        def _queryset(self, cleaned, *args, **kwargs):
            qs = super()._queryset(cleaned, *args, **kwargs)
            return qs.filter('match', status='published')
示例#2
0
    class GET(SearchHandler):
        meta_serializer = DatasetsMeta()
        request_schema = DatasetsList()
        response_serializer = DatasetSerializer(many=True)
        search_document = DatasetsDoc()

        def _queryset(self, cleaned, *args, **kwargs):
            qs = super()._queryset(cleaned, *args, **kwargs)
            if 'id' in kwargs:
                qs = qs.query("nested", path="institution",
                              query=Q("term", **{'institution.id': kwargs['id']}))
            return qs
示例#3
0
    class GET(RetrieveOneFollowHandler):
        database_model = apps.get_model('datasets', 'Dataset')
        response_serializer = DatasetSerializer(many=False,
                                                include_data=('institution',
                                                              'resources'))
        triggers = [
            LoginOptional(),
        ]

        def resource_clean(self, request, id, *args, **kwargs):
            model = self.database_model
            try:
                return model.objects.get(pk=id, status="published")
            except model.DoesNotExist:
                raise falcon.HTTPNotFound
示例#4
0
 class GET(FollowedListHandler):
     meta_serializer = DatasetsMeta()
     request_schema = DatasetsList()
     response_serializer = DatasetSerializer(many=True,
                                             include_data=('institution', ))
     search_document = DatasetsDoc()
示例#5
0
 class DELETE(DeleteFollowingHandler):
     database_model = apps.get_model('users', 'UserFollowingDataset')
     resource_model = apps.get_model('datasets', 'Dataset')
     resource_name = 'dataset'
     response_serializer = DatasetSerializer(many=False)