コード例 #1
0
class BenthicPITMethodObsFilterSet(BaseTransectFilterSet):
    depth = RangeFilter()
    sample_unit_id = BaseInFilter(method="id_lookup")
    observers = BaseInFilter(method="json_name_lookup")
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    interval_size = RangeFilter()
    interval = RangeFilter()

    class Meta:
        model = BenthicPITObsView
        fields = [
            "depth",
            "sample_unit_id",
            "observers",
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "interval_size",
            "interval",
            "benthic_category",
            "benthic_attribute",
            "growth_form",
            "data_policy_benthicpit",
        ]
コード例 #2
0
class BleachingQCMethodSUFilterSet(BaseTransectFilterSet):
    sample_unit_id = BaseInFilter(method="id_lookup")
    depth = RangeFilter()
    observers = BaseInFilter(method="json_name_lookup")
    count_genera = RangeFilter()
    count_total = RangeFilter()
    percent_normal = RangeFilter()
    percent_pale = RangeFilter()
    percent_bleached = RangeFilter()
    quadrat_count = RangeFilter()
    percent_hard_avg = RangeFilter()
    percent_soft_avg = RangeFilter()
    percent_algae_avg = RangeFilter()

    class Meta:
        model = BleachingQCSUView
        fields = [
            "depth",
            "sample_unit_id",
            "observers",
            "label",
            "quadrat_size",
            "data_policy_bleachingqc",
            "count_genera",
            "count_total",
            "percent_normal",
            "percent_pale",
            "percent_bleached",
            "quadrat_count",
            "percent_hard_avg",
            "percent_soft_avg",
            "percent_algae_avg",
        ]
コード例 #3
0
class BleachingQCMethodColoniesBleachedObsFilterSet(BaseTransectFilterSet):
    sample_unit_id = BaseInFilter(method="id_lookup")
    depth = RangeFilter()
    observers = BaseInFilter(method="json_name_lookup")
    count_normal = RangeFilter()
    count_pale = RangeFilter()
    count_20 = RangeFilter()
    count_50 = RangeFilter()
    count_80 = RangeFilter()
    count_100 = RangeFilter()
    count_dead = RangeFilter()

    class Meta:
        model = BleachingQCColoniesBleachedObsView
        fields = [
            "depth",
            "sample_unit_id",
            "observers",
            "label",
            "quadrat_size",
            "benthic_attribute",
            "growth_form",
            "data_policy_bleachingqc",
            "count_normal",
            "count_pale",
            "count_20",
            "count_50",
            "count_80",
            "count_100",
            "count_dead",
        ]
コード例 #4
0
ファイル: base.py プロジェクト: data-mermaid/mermaid-api
class BaseSUObsFilterSet(BaseSEFilterSet):
    label = BaseInFilter(method="char_lookup")
    depth = RangeFilter()
    relative_depth = BaseInFilter(method="char_lookup")
    observers = BaseInFilter(method="json_name_lookup")

    class Meta:
        fields = [
            "label",
            "depth",
            "relative_depth",
            "observers",
        ]
コード例 #5
0
ファイル: base.py プロジェクト: data-mermaid/mermaid-api
class AggregatedViewFilterSet(OrFilterSetMixin, GeoFilterSet):
    site_id = BaseInFilter(method="id_lookup")
    site_name = BaseInFilter(method="char_lookup")
    site_within = GeometryFilter(field_name="location", lookup_expr="within")
    country_id = BaseInFilter(method="id_lookup")
    country_name = BaseInFilter(method="char_lookup")
    tag_id = BaseInFilter(field_name="tags", method="json_id_lookup")
    tag_name = BaseInFilter(field_name="tags", method="json_name_lookup")
    management_id = BaseInFilter(method="id_lookup")
    management_name = BaseInFilter(method="full_management_name")

    class Meta:
        fields = [
            "site_id",
            "site_name",
            "site_within",
            "country_id",
            "country_name",
            "tag_id",
            "tag_name",
            "reef_type",
            "reef_zone",
            "reef_exposure",
            "management_id",
            "management_name",
        ]

    def full_management_name(self, queryset, name, value):
        fields = ["management_name", "management_name_secondary"]
        return self.str_or_lookup(queryset, fields, value, lookup_expr="icontains")
コード例 #6
0
ファイル: base.py プロジェクト: data-mermaid/mermaid-api
class BaseSEFilterSet(AggregatedViewFilterSet):
    id = BaseInFilter(method="id_lookup")
    sample_event_id = BaseInFilter(method="id_lookup")
    sample_date = DateFromToRangeFilter()
    management_est_year = RangeFilter()
    management_size = RangeFilter()
    management_party = BaseInFilter(
        field_name="management_parties", method="char_lookup"
    )
    management_compliance = BaseInFilter(method="char_lookup")
    management_rule = BaseInFilter(field_name="management_rules", method="char_lookup")
    current_name = BaseInFilter(method="char_lookup")
    tide_name = BaseInFilter(method="char_lookup")
    visibility_name = BaseInFilter(method="char_lookup")

    class Meta:
        fields = [
            "sample_event_id",
            "sample_date",
            "management_est_year",
            "management_size",
            "management_party",
            "management_compliance",
            "management_rule",
            "current_name",
            "tide_name",
            "visibility_name",
        ]
コード例 #7
0
class BenthicLITMethodSUFilterSet(BaseTransectFilterSet):
    transect_len_surveyed = RangeFilter()
    depth = RangeFilter()
    observers = BaseInFilter(method="json_name_lookup")
    reef_slope = BaseInFilter(method="char_lookup")

    class Meta:
        model = BenthicLITSUView
        fields = [
            "depth",
            "observers",
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "data_policy_benthiclit",
        ]
コード例 #8
0
class UsuariosFilterSet(FilterSet):
    permissao__in = BaseInFilter(field_name='permissao', lookup_expr='in')

    class Meta:
        model = Usuarios
        fields = ('id', 'nome', 'apelido', 'matricula', 'cpf', 'email',
                  'funcao_1', 'funcao_2', 'login', 'permissao')
コード例 #9
0
class RateCardPositionFilter(FilterSet):
    rate_card_ids = BaseInFilter(name="rate_card__id",
                                 lookup_expr="in",
                                 label="rateCardIds")

    class Meta:
        model = RateCardPosition
        fields = ['rate_card_ids']
コード例 #10
0
class HabitatComplexityMethodSUFilterSet(BaseTransectFilterSet):
    transect_len_surveyed = RangeFilter()
    depth = RangeFilter()
    observers = BaseInFilter(method="json_name_lookup")
    reef_slope = BaseInFilter(method="char_lookup")
    interval_size = RangeFilter()

    class Meta:
        model = HabitatComplexitySUView
        fields = [
            "depth",
            "observers",
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "score_avg",
            "data_policy_habitatcomplexity",
        ]
コード例 #11
0
ファイル: beltfishmethod.py プロジェクト: vpop/mermaid-api
class BeltFishMethodSUFilterSet(BaseTransectFilterSet):
    transect_len_surveyed = RangeFilter()
    depth = RangeFilter()
    observers = BaseInFilter(method="json_name_lookup")
    reef_slope = BaseInFilter(method="char_lookup")
    biomass_kgha = RangeFilter()

    class Meta:
        model = BeltFishSUView
        fields = [
            "depth",
            "observers",
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "size_bin",
            "biomass_kgha",
            "data_policy_beltfish",
        ]
コード例 #12
0
class AddressFilter(FilterSet):
    """Фильтры для AddressViewSet.

    Добавляет фильтрацию по списку id.
    """

    ids = BaseInFilter(field_name='id')

    class Meta:
        model = Address
        fields = ('id', 'ids', )
コード例 #13
0
class BenthicLITMethodSUFilterSet(BaseSUObsFilterSet):
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")

    class Meta:
        model = BenthicLITSUSQLModel
        fields = [
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
        ]
コード例 #14
0
class HabitatComplexityMethodObsFilterSet(BaseTransectFilterSet):
    depth = RangeFilter()
    sample_unit_id = BaseInFilter(method="id_lookup")
    observers = BaseInFilter(method="json_name_lookup")
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    interval = RangeFilter()

    class Meta:
        model = HabitatComplexityObsView
        fields = [
            "depth",
            "sample_unit_id",
            "observers",
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "interval",
            "score",
            "data_policy_habitatcomplexity",
        ]
コード例 #15
0
ファイル: filters.py プロジェクト: genomics-geek/exome_slicer
class QualityStatFilter(BaseFilterSet):

    genes_in = BaseInFilter(label='Genes', method='filter_genes_in')
    quality_filters = BaseInFilter(
        label='Quality Filter',
        method='filter_quality_filters',
        help_text=
        'Quality filters comma separated.  Format: min_coverage,avg_mapping_quality.',
    )

    class Meta:
        model = QualityStat
        fields = '__all__'

    def filter_genes_in(self, qs, field_name, value):
        return qs.filter(gene__in=[x.upper() for x in value]).distinct()

    def filter_quality_filters(self, queryset, name, value):
        return queryset.filter(
            Q(min_coverage__lte=value[0])
            | Q(avg_mapping_quality__lte=value[1]))
コード例 #16
0
class BeltFishMethodObsFilterSet(BaseSUObsFilterSet):
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    fish_family = BaseInFilter(method="char_lookup")
    fish_genus = BaseInFilter(method="char_lookup")
    fish_taxon = BaseInFilter(method="char_lookup")
    trophic_group = BaseInFilter(method="char_lookup")
    trophic_level = RangeFilter()
    functional_group = BaseInFilter(method="id_lookup")
    vulnerability = RangeFilter()
    size = RangeFilter()
    count = RangeFilter()
    biomass_kgha = RangeFilter()

    class Meta:
        model = BeltFishObsSQLModel
        fields = [
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "fish_taxon",
            "fish_family",
            "fish_genus",
            "trophic_group",
            "trophic_level",
            "functional_group",
            "vulnerability",
            "size",
            "count",
            "biomass_kgha",
        ]
コード例 #17
0
class BaseFilterSet(FilterSet):
    FILTER_DEFAULTS = dict(itertools.chain(
        FILTER_FOR_DBFIELD_DEFAULTS.items(),
        FILTER_OVERRIDES.items(),
        GRAPHENE_FILTER_SET_OVERRIDES.items(),
    ))

    id__in = GlobalIDInFilter(field_name='pk', distinct=True)
    pk__in = BaseInFilter(field_name='pk', distinct=True)
    sort_by = CharFilter(label='filter_sort_by', method='filter_sort_by')

    def filter_sort_by(self, queryset, name, value):
        return queryset.order_by(*value.strip().split(','))
コード例 #18
0
class BeltFishMethodSUFilterSet(BaseSUObsFilterSet):
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    biomass_kgha = RangeFilter()

    class Meta:
        model = BeltFishSUSQLModel
        fields = [
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "biomass_kgha",
        ]
コード例 #19
0
class BleachingQCMethodQuadratBenthicPercentObsFilterSet(
        BaseTransectFilterSet):
    sample_unit_id = BaseInFilter(method="id_lookup")
    depth = RangeFilter()
    observers = BaseInFilter(method="json_name_lookup")
    percent_hard = RangeFilter()
    percent_soft = RangeFilter()
    percent_algae = RangeFilter()

    class Meta:
        model = BleachingQCQuadratBenthicPercentObsView
        fields = [
            "depth",
            "sample_unit_id",
            "observers",
            "label",
            "quadrat_size",
            "data_policy_bleachingqc",
            "quadrat_number",
            "percent_hard",
            "percent_soft",
            "percent_algae",
        ]
コード例 #20
0
class HabitatComplexityMethodSUFilterSet(BaseSUObsFilterSet):
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    interval_size = RangeFilter()
    score_avg = RangeFilter()

    class Meta:
        model = HabitatComplexitySUSQLModel
        fields = [
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "score_avg",
        ]
コード例 #21
0
class BenthicLITMethodObsFilterSet(BaseSUObsFilterSet):
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    length = RangeFilter()

    class Meta:
        model = BenthicLITObsSQLModel
        fields = [
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "length",
            "benthic_category",
            "benthic_attribute",
            "growth_form",
        ]
コード例 #22
0
class TerritoryFilter(FilterSet):
    bounds = Filter(method="filter_bounds")
    date = DateFilter(method="filter_date")
    exclude_ids = BaseInFilter(
        field_name="id", exclude=True, widget=widgets.CSVWidget()
    )

    def filter_bounds(self, queryset, field_name, value):
        geom = Polygon(make_tuple(value), srid=4326)
        return queryset.filter(geo__intersects=geom)

    def filter_date(self, queryset, field_name, value):
        return queryset.filter(start_date__lte=value, end_date__gte=value)

    class Meta:
        model = Territory
        fields = ("entity",)
コード例 #23
0
class UserFilterAPI(FilterSet):
    date_joined = DateTimeFromToRangeFilter(
        label='Date joined range',
        field_name='created',
        lookup_expr='date',
        widget=DateRangeWidget(attrs={
            'class': 'form-control datetimepicker-input',
            'type': 'date',
        }))
    is_active = BooleanFilter()
    user_id = BaseInFilter(field_name='id', label='User id')

    class Meta:
        model = User
        fields = {
            'email': ['icontains'],
            'first_name': ['icontains'],
            'last_name': ['icontains'],
        }
コード例 #24
0
ファイル: beltfishmethod.py プロジェクト: vpop/mermaid-api
class BeltFishMethodObsFilterSet(BaseTransectFilterSet):
    depth = RangeFilter()
    sample_unit_id = BaseInFilter(method="id_lookup")
    observers = BaseInFilter(method="json_name_lookup")
    transect_len_surveyed = RangeFilter()
    reef_slope = BaseInFilter(method="char_lookup")
    fish_family = BaseInFilter(method="id_lookup")
    fish_genus = BaseInFilter(method="id_lookup")
    fish_taxon = BaseInFilter(method="id_lookup")
    trophic_group = BaseInFilter(method="id_lookup")
    trophic_level = RangeFilter()
    functional_group = BaseInFilter(method="id_lookup")
    vulnerability = RangeFilter()
    size = RangeFilter()
    count = RangeFilter()
    biomass_kgha = RangeFilter()

    class Meta:
        model = BeltFishObsView
        fields = [
            "depth",
            "sample_unit_id",
            "observers",
            "transect_len_surveyed",
            "reef_slope",
            "transect_number",
            "label",
            "fish_taxon",
            "fish_family",
            "fish_genus",
            "trophic_group",
            "trophic_level",
            "functional_group",
            "vulnerability",
            "size",
            "count",
            "size_bin",
            "biomass_kgha",
            "data_policy_beltfish",
        ]
コード例 #25
0
class BaseTransectFilterSet(OrFilterSetMixin, GeoFilterSet):
    id = BaseInFilter(method="id_lookup")
    site_id = BaseInFilter(method="id_lookup")
    site_name = BaseInFilter(method="char_lookup")
    site_within = GeometryFilter(field_name="location", lookup_expr='within')
    country_id = BaseInFilter(method='id_lookup')
    country_name = BaseInFilter(method="char_lookup")
    sample_date = DateFromToRangeFilter()
    tag_id = BaseInFilter(field_name='tags', method='json_id_lookup')
    tag_name = BaseInFilter(field_name='tags', method='json_name_lookup')
    management_id = BaseInFilter(method="id_lookup")
    management_name = BaseInFilter(method="full_management_name")
    management_est_year = DateFromToRangeFilter()
    management_size = RangeFilter()
    management_party = BaseInFilter(field_name="management_parties",
                                    method="char_lookup")
    management_compliance = BaseInFilter(method="char_lookup")
    management_rule = BaseInFilter(field_name="management_rules",
                                   method="char_lookup")
    current_name = BaseInFilter(method="char_lookup")
    tide_name = BaseInFilter(method="char_lookup")
    visibility_name = BaseInFilter(method="char_lookup")

    class Meta:
        fields = [
            "site_id",
            "site_name",
            "site_within",
            "country_id",
            "country_name",
            "sample_date",
            "tag_id",
            "tag_name",
            "reef_type",
            "reef_zone",
            "reef_exposure",
            "management_id",
            "management_name",
            "management_est_year",
            "management_size",
            "management_party",
            "management_compliance",
            "management_rule",
            "current_name",
            "tide_name",
            "visibility_name",
        ]

    def full_management_name(self, queryset, name, value):
        fields = ["management_name", "management_name_secondary"]
        return self.str_or_lookup(queryset,
                                  fields,
                                  value,
                                  lookup_expr="icontains")