示例#1
0
class ApplicationsList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS, constants.
        LOOKUP_QUERY_GT, constants.LOOKUP_QUERY_GTE, constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE, constants.LOOKUP_QUERY_IN
    ])
    ids = fields.IdsSearchField()
    q = fields.SearchFilterField(
        search_fields=['title', 'notes', 'author', 'tags', 'datasets.title'], )

    tags = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD, constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN, constants.LOOKUP_QUERY_EXCLUDE
    ])

    author = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD, constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN, constants.LOOKUP_QUERY_EXCLUDE
    ])

    facet = fields.FacetedFilterField(facets={
        'tags':
        TermsFacet(field='tags', size=500),
        'modified':
        DateHistogramFacet(field='modified', interval='month', size=500)
    }, )

    sort = fields.OrderingFilterField(default_ordering=[
        '-modified',
    ],
                                      ordering_fields={
                                          "id": "id",
                                          "title": "title.raw",
                                          "modified": "modified",
                                          "created": "created"
                                      })

    highlight = fields.HighlightBackend(
        highlight_fields={
            'title': {
                'options': {
                    'pre_tags': ['<em>'],
                    'post_tags': ['</em>'],
                },
                'enabled': True
            },
            'notes': {
                'options': {
                    'pre_tags': ['<em>'],
                    'post_tags': ['</em>'],
                },
                'enabled': True
            }
        })

    class Meta:
        strict = True
示例#2
0
class HistoriesList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS, constants.
        LOOKUP_QUERY_GT, constants.LOOKUP_QUERY_GTE, constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE, constants.LOOKUP_QUERY_IN
    ])
    ids = fields.IdsSearchField()

    table_name = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_REGEXP, constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_ENDSWITH, constants.LOOKUP_QUERY_STARTSWITH
    ])

    row_id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
    ])

    action = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        # constants.LOOKUP_QUERY_IN,
    ])

    old_value = fields.FilteringFilterField()
    new_value = fields.FilteringFilterField()
    difference = fields.FilteringFilterField()
    change_user_id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
    ])
    change_timestamp = fields.FilteringFilterField()
    message = fields.FilteringFilterField()

    q = fields.SearchFilterField(search_fields=['table_name', 'action'], )

    sort = fields.OrderingFilterField(
        ordering_fields={
            "id": "id",
            "row_id": "row_id",
            "table_name": "table_name",
            "change_timestamp": "change_timestamp",
            "change_user_id": "change_user_id"
        })

    class Meta:
        strict = True
示例#3
0
class SearchHistoriesList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
        constants.LOOKUP_QUERY_IN
    ])
    ids = fields.IdsSearchField()

    url = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_REGEXP,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_ENDSWITH,
        constants.LOOKUP_QUERY_STARTSWITH
    ])

    query_sentence = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_REGEXP,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_ENDSWITH,
        constants.LOOKUP_QUERY_STARTSWITH
    ])

    user = fields.NestedFilteringField('user', field_name='user.id', lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,

    ]
    )

    modfied = fields.FilteringFilterField()

    q = fields.SearchFilterField(
        search_fields=['query_sentence', 'url'],
    )

    sort = fields.OrderingFilterField(
        ordering_fields={
            "id": "id",
            "query_sentence": "query_sentence",
            "modified": "modified",
            "user": "******"
        }
    )

    class Meta:
        strict = True
 class SomeSchema(QuerysetTestHelper, List):
     ids = fields.IdsSearchField()
     q = fields.SearchFilterField(search_fields=['title', 'body'], )
     filtered_field = fields.FilteringFilterField(lookups=[
         constants.LOOKUP_FILTER_TERM, constants.LOOKUP_QUERY_ENDSWITH,
         constants.LOOKUP_QUERY_EXCLUDE, constants.LOOKUP_QUERY_LTE,
         constants.LOOKUP_FILTER_RANGE
     ])
     nested_field = fields.NestedFilteringField(
         'nested_field',
         field_name='nested_field.id',
         lookups=[constants.LOOKUP_FILTER_TERM])
示例#5
0
class DatasetsList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS, constants.
        LOOKUP_QUERY_GT, constants.LOOKUP_QUERY_GTE, constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE, constants.LOOKUP_QUERY_IN
    ])
    ids = fields.IdsSearchField()

    slug = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
        constants.LOOKUP_QUERY_STARTSWITH,
        constants.LOOKUP_QUERY_ENDSWITH,
    ])

    title = fields.SearchFilterField(search_i18n_fields=['title'])

    notes = fields.SearchFilterField(search_i18n_fields=['notes'])

    category = fields.NestedFilteringField('category',
                                           field_name='category.id',
                                           lookups=[
                                               constants.LOOKUP_FILTER_TERM,
                                               constants.LOOKUP_FILTER_TERMS,
                                               constants.LOOKUP_QUERY_GT,
                                               constants.LOOKUP_QUERY_GTE,
                                               constants.LOOKUP_QUERY_LT,
                                               constants.LOOKUP_QUERY_LTE,
                                               constants.LOOKUP_QUERY_IN,
                                               constants.LOOKUP_QUERY_EXCLUDE,
                                           ])

    institution = fields.NestedFilteringField(
        'institution',
        field_name='institution.id',
        lookups=[
            constants.LOOKUP_FILTER_TERM,
            constants.LOOKUP_FILTER_TERMS,
            constants.LOOKUP_QUERY_GT,
            constants.LOOKUP_QUERY_GTE,
            constants.LOOKUP_QUERY_LT,
            constants.LOOKUP_QUERY_LTE,
            constants.LOOKUP_QUERY_IN,
            constants.LOOKUP_QUERY_EXCLUDE,
        ])

    tags = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
        constants.LOOKUP_QUERY_CONTAINS,
    ],
                                       translated=True)

    formats = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_EXCLUDE,
    ])

    openness_scores = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM, constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD, constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN, constants.LOOKUP_QUERY_EXCLUDE,
        constants.LOOKUP_QUERY_CONTAINS
    ])

    q = fields.SearchFilterField(search_i18n_fields=['title', 'notes'], )

    facet = fields.FacetedFilterField(facets={
        'institutions':
        NestedFacet('institution', TermsFacet(field='institution.id',
                                              size=500)),
        'categories':
        NestedFacet('category', TermsFacet(field='category.id', size=500)),
        'tags':
        TermsFacet(field='tags', size=500),
        'formats':
        TermsFacet(field='formats', size=500),
        'openness_scores':
        TermsFacet(field='openness_scores')
    }, )

    views_count = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
    ])

    sort = fields.OrderingFilterField(
        ordering_fields={
            "id": "id",
            "title": "title.{lang}.sort",
            "modified": "last_modified_resource",
            "created": "created",
            "views_count": "views_count",
            "verified": "verified",
        })

    class Meta:
        strict = True
示例#6
0
class InstitutionsList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
        constants.LOOKUP_QUERY_IN
    ])
    ids = fields.IdsSearchField()
    city = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,

    ])
    postal_code = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,

    ])
    email = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,

    ])
    type = fields.FilteringFilterField(field_name='institution_type', lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
    ])
    tel = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,

    ])
    fax = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,

    ])
    website = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,

    ])

    q = fields.SearchFilterField(
        search_fields=['title', 'description'],
    )

    facet = fields.FacetedFilterField(
        facets={
            'cities': TermsFacet(field='city', size=500),
            'types': TermsFacet(field='institution_type', size=500)
        },
    )

    title_suggest = fields.SuggesterFilterField(
        field='title.suggest',
        suggesters=[
            constants.SUGGESTER_COMPLETION,
            constants.SUGGESTER_PHRASE,
            constants.SUGGESTER_TERM
        ]
    )
    sort = fields.OrderingFilterField(
        ordering_fields={
            "id": "id",
            "title": "title.raw",
            "city": "city",
            "modified": "modified",
            "created": "created"
        }
    )

    #
    # highlight = fields.HighlightBackend(
    #     highlight_fields={
    #         'title': {
    #             'options': {
    #                 'pre_tags': ['<em>'],
    #                 'post_tags': ['</em>'],
    #             },
    #             'enabled': True
    #         },
    #         'notes': {
    #             'options': {
    #                 'pre_tags': ['<em>'],
    #                 'post_tags': ['</em>'],
    #             },
    #             'enabled': True
    #         }
    #     }
    # )

    class Meta:
        strict = True
示例#7
0
class ResourcesList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
    ])

    uuid = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
        constants.LOOKUP_QUERY_STARTSWITH,
        constants.LOOKUP_QUERY_ENDSWITH,
    ])

    ids = fields.IdsSearchField()

    title = fields.SearchFilterField(search_i18n_fields=['title'])

    description = fields.SearchFilterField(search_i18n_fields=['description'])

    dataset = fields.NestedFilteringField('dataset',
                                          field_name='dataset.id',
                                          lookups=[
                                              constants.LOOKUP_FILTER_TERM,
                                              constants.LOOKUP_FILTER_TERMS,
                                              constants.LOOKUP_QUERY_GT,
                                              constants.LOOKUP_QUERY_GTE,
                                              constants.LOOKUP_QUERY_LT,
                                              constants.LOOKUP_QUERY_LTE,
                                              constants.LOOKUP_QUERY_IN,
                                              constants.LOOKUP_QUERY_EXCLUDE,
                                          ])

    formats = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_EXCLUDE,
    ])

    type = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_EXCLUDE,
    ])

    openness_score = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_EXCLUDE,
    ])

    q = fields.SearchFilterField(search_i18n_fields=['title', 'description'], )

    facet = fields.FacetedFilterField(facets={
        'formats':
        TermsFacet(field='formats', size=500),
        'types':
        TermsFacet(fields='type', size=500),
        'openness_score':
        TermsFacet(field='openness_score', size=500)
    }, )

    sort = fields.OrderingFilterField(
        ordering_fields={
            "id": "id",
            "title": "title.{lang}.sort",
            "modified": "modified",
            "created": "created",
            "verified": "verified",
            "data_date": "data_date"
        })

    class Meta:
        strict = True
示例#8
0
class ArticlesList(List):
    id = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
    ])
    ids = fields.IdsSearchField()
    title = fields.SearchFilterField(search_i18n_fields=['title'])

    notes = fields.SearchFilterField(search_i18n_fields=['notes'])

    q = fields.SearchFilterField(
        search_i18n_fields=['title', 'notes', 'datasets.title'],
    )

    tags = fields.FilteringFilterField(
        lookups=[
            constants.LOOKUP_FILTER_TERM,
            constants.LOOKUP_FILTER_TERMS,
            constants.LOOKUP_FILTER_WILDCARD,
            constants.LOOKUP_FILTER_PREFIX,
            constants.LOOKUP_QUERY_IN,
            constants.LOOKUP_QUERY_EXCLUDE,
            constants.LOOKUP_QUERY_CONTAINS
        ],
        translated=True
    )

    author = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_FILTER_WILDCARD,
        constants.LOOKUP_FILTER_PREFIX,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
        constants.LOOKUP_QUERY_CONTAINS,
        constants.LOOKUP_QUERY_STARTSWITH,
        constants.LOOKUP_QUERY_ENDSWITH,
    ])

    slug = fields.FilteringFilterField(lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_IN,
        constants.LOOKUP_QUERY_EXCLUDE,
        constants.LOOKUP_QUERY_STARTSWITH,
        constants.LOOKUP_QUERY_ENDSWITH,
    ])

    category = fields.NestedFilteringField('category', field_name='category.id', lookups=[
        constants.LOOKUP_FILTER_TERM,
        constants.LOOKUP_FILTER_TERMS,
        constants.LOOKUP_QUERY_GT,
        constants.LOOKUP_QUERY_GTE,
        constants.LOOKUP_QUERY_LT,
        constants.LOOKUP_QUERY_LTE,
        constants.LOOKUP_QUERY_IN
    ])

    facet = fields.FacetedFilterField(
        facets={
            'tags': TermsFacet(field='tags', size=500),
            'modified': DateHistogramFacet(field='modified', interval='month', size=500)
        },
    )

    title_suggest = fields.SuggesterFilterField(
        field='title.suggest',
        suggesters=[
            constants.SUGGESTER_COMPLETION,
            constants.SUGGESTER_PHRASE,
            constants.SUGGESTER_TERM
        ]
    )
    sort = fields.OrderingFilterField(
        default_ordering=['-modified', ],
        ordering_fields={
            "id": "id",
            "title": "title.{lang}.sort",
            "modified": "modified",
            "created": "created"
        }
    )

    highlight = fields.HighlightBackend(
        highlight_fields={
            'title': {
                'options': {
                    'pre_tags': ['<em>'],
                    'post_tags': ['</em>'],
                },
                'enabled': True
            },
            'notes': {
                'options': {
                    'pre_tags': ['<em>'],
                    'post_tags': ['</em>'],
                },
                'enabled': True
            }
        }
    )

    class Meta:
        strict = True