class ImageFilter(django_filters.FilterSet): file_name = MultiValueFilter() image_format = MultiValueFilter(name='image_format__name') image_type = MultiValueFilter(name='image_type__name') disc_number = MultiIntFilter() disc_count = MultiIntFilter() arch = MultiValueFilter() mtime = MultiIntFilter() size = MultiIntFilter() implant_md5 = MultiValueFilter() volume_id = MultiValueFilter() md5 = MultiValueFilter() sha1 = MultiValueFilter() sha256 = MultiValueFilter() subvariant = MultiValueFilter() compose = MultiValueFilter( name='composeimage__variant_arch__variant__compose__compose_id', distinct=True) bootable = CaseInsensitiveBooleanFilter() class Meta: model = models.Image fields = ('file_name', 'image_format', 'image_type', 'disc_number', 'disc_count', 'arch', 'mtime', 'size', 'bootable', 'implant_md5', 'volume_id', 'md5', 'sha1', 'sha256', 'subvariant')
class MultiDestinationFilter(filters.FilterSet): global_component = MultiValueFilter(name='global_component__name') origin_repo = MultiIntFilter() destination_repo = MultiIntFilter() origin_repo_name = MultiValueFilter(name='origin_repo__name') destination_repo_name = MultiValueFilter(name='destination_repo__name') origin_repo_release_id = MultiValueFilter( name='origin_repo__variant_arch__variant__release__release_id') destination_repo_release_id = MultiValueFilter( name='destination_repo__variant_arch__variant__release__release_id') subscribers = MultiValueFilter(method='filter_by_subscribers') active = CaseInsensitiveBooleanFilter() @value_is_not_empty def filter_by_subscribers(self, qs, name, value): people = Person.objects.filter(username__in=value) return qs.filter(subscribers__in=people) class Meta: model = models.MultiDestination fields = ( 'id', 'global_component', 'origin_repo', 'destination_repo', 'origin_repo_name', 'destination_repo_name', 'origin_repo_release_id', 'destination_repo_release_id', 'subscribers', 'active', )
class RPMFilter(django_filters.FilterSet): name = MultiValueFilter() version = MultiValueFilter() epoch = MultiIntFilter() release = MultiValueFilter() arch = MultiValueFilter() srpm_name = MultiValueFilter() srpm_nevra = NullableCharFilter() filename = MultiValueFilter() compose = MultiValueFilter(name='composerpm__variant_arch__variant__compose__compose_id', distinct=True) linked_release = MultiValueFilter(name='linked_releases__release_id', distinct=True) built_for_release = MultiValueFilter(name='built_for_release__release_id', distinct=True) provides = django_filters.MethodFilter(action=partial(dependency_filter, models.Dependency.PROVIDES)) requires = django_filters.MethodFilter(action=partial(dependency_filter, models.Dependency.REQUIRES)) obsoletes = django_filters.MethodFilter(action=partial(dependency_filter, models.Dependency.OBSOLETES)) conflicts = django_filters.MethodFilter(action=partial(dependency_filter, models.Dependency.CONFLICTS)) recommends = django_filters.MethodFilter(action=partial(dependency_filter, models.Dependency.RECOMMENDS)) suggests = django_filters.MethodFilter(action=partial(dependency_filter, models.Dependency.SUGGESTS)) has_no_deps = CaseInsensitiveBooleanFilter(name='dependency__isnull', distinct=True) class Meta: model = models.RPM fields = ('name', 'version', 'epoch', 'release', 'arch', 'srpm_name', 'srpm_nevra', 'compose', 'filename', 'linked_release', 'built_for_release', 'provides', 'requires', 'obsoletes', 'conflicts', 'recommends', 'suggests', 'has_no_deps')
class ReleasedFilesFilter(django_filters.FilterSet): released_date = MultiValueFilter() release_date = MultiValueFilter() zero_day_release = CaseInsensitiveBooleanFilter() obsolete = CaseInsensitiveBooleanFilter() file_primary_key = MultiIntFilter() repo = MultiValueFilter(name='repo__id') repo_name = MultiValueFilter(name='repo__name') release_id = MultiValueFilter( name='repo__variant_arch__variant__release__release_id') service = MultiValueFilter(name='repo__service__name') arch = MultiValueFilter(name='repo__variant_arch__arch__name') variant_uid = MultiValueFilter( name='repo__variant_arch__variant__variant_uid') release_date_after = django_filters.DateFilter(name="release_date", lookup_type='gte') release_date_before = django_filters.DateFilter(name="release_date", lookup_type='lte') released_date_after = django_filters.DateFilter(name="released_date", lookup_type='gte') released_date_before = django_filters.DateFilter(name="released_date", lookup_type='lte') class Meta: model = models.ReleasedFiles fields = ('released_date', 'release_date', 'file_primary_key', 'zero_day_release', 'obsolete', 'repo', 'repo_name', 'release_id', 'service', 'arch', 'variant_uid')
def extend_release_filter(release_filter): add_filter(release_filter, 'brew_default_target', NullableCharFilter(name='brew_mapping__default_target')) add_filter(release_filter, 'brew_allowed_tag', MultiValueFilter(name='brew_mapping__allowed_tags__tag_name')) add_filter(release_filter, 'product_pages_release_id', MultiIntFilter(name='product_pages_link__product_pages_id')) add_filter(release_filter, 'errata_product_version', NullableCharFilter(name='errata__product_version'))
class RepoFilter(filters.FilterSet): arch = MultiValueFilter(name='variant_arch__arch__name') content_category = MultiValueFilter(name='content_category__name') content_format = MultiValueFilter(name='content_format__name') release_id = MultiValueFilter(name='variant_arch__variant__release__release_id') variant_uid = MultiValueFilter(name='variant_arch__variant__variant_uid') repo_family = MultiValueFilter(name='repo_family__name') service = MultiValueFilter(name='service__name') shadow = CaseInsensitiveBooleanFilter() product_id = MultiIntFilter() class Meta: model = models.Repo fields = ('arch', 'content_category', 'content_format', 'name', 'release_id', 'repo_family', 'service', 'shadow', 'variant_uid', 'product_id')
class RPMFilter(django_filters.FilterSet): name = MultiValueRegexFilter(help_text=""" Multiple values will be OR-ed. Preferably use OR inside the regexp. """) version = MultiValueFilter() epoch = MultiIntFilter() release = MultiValueFilter() arch = MultiValueFilter() srpm_name = MultiValueFilter() srpm_nevra = NullableCharFilter() filename = MultiValueFilter() compose = MultiValueFilter( name='composerpm__variant_arch__variant__compose__compose_id', distinct=True) srpm_commit_hash = MultiValueFilter() srpm_commit_branch = MultiValueFilter() linked_release = MultiValueFilter(name='linked_releases__release_id', distinct=True) built_for_release = MultiValueFilter(name='built_for_release__release_id', distinct=True) provides = django_filters.CharFilter( method=partial(dependency_filter, models.Dependency.PROVIDES)) requires = django_filters.CharFilter( method=partial(dependency_filter, models.Dependency.REQUIRES)) obsoletes = django_filters.CharFilter( method=partial(dependency_filter, models.Dependency.OBSOLETES)) conflicts = django_filters.CharFilter( method=partial(dependency_filter, models.Dependency.CONFLICTS)) recommends = django_filters.CharFilter( method=partial(dependency_filter, models.Dependency.RECOMMENDS)) suggests = django_filters.CharFilter( method=partial(dependency_filter, models.Dependency.SUGGESTS)) has_no_deps = CaseInsensitiveBooleanFilter(name='dependency__isnull', distinct=True, help_text=""" - If "true", lists only RPMs which do not have any dependencies. - If "false", lists only RPMs which have at least one dependency. """) class Meta: model = models.RPM fields = ('name', 'version', 'epoch', 'release', 'arch', 'srpm_name', 'srpm_nevra', 'compose', 'filename', 'linked_release', 'built_for_release', 'provides', 'requires', 'obsoletes', 'conflicts', 'recommends', 'suggests', 'has_no_deps')