summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-django-property-filter.spec683
-rw-r--r--sources1
3 files changed, 685 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..f200388 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/django-property-filter-1.1.2.tar.gz
diff --git a/python-django-property-filter.spec b/python-django-property-filter.spec
new file mode 100644
index 0000000..66a2020
--- /dev/null
+++ b/python-django-property-filter.spec
@@ -0,0 +1,683 @@
+%global _empty_manifest_terminate_build 0
+Name: python-django-property-filter
+Version: 1.1.2
+Release: 1
+Summary: Django Filter extension to support filtering by Properties
+License: MIT
+URL: https://pypi.org/project/django-property-filter/
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/17/fa/c869dedc7dab6c7307c3be2c38350c15b63ce9a038c8d313420040bb9cc1/django-property-filter-1.1.2.tar.gz
+BuildArch: noarch
+
+Requires: python3-Django
+Requires: python3-django-filter
+
+%description
+# Django Property Filter
+
+Django-property-filter is an extension to [django-filter](https://pypi.org/projhttps://pypi.org/project/django-filter/ect/django-filter/) and provides functionality to filter querysets by class properties.
+
+It does so by providing sub-classes for Filters and Filtersets to keep existing django-filter functionality.
+
+<table>
+ <tr>
+ <td>License</td>
+ <td><img src='https://img.shields.io/pypi/l/django-property-filter.svg'></td>
+ <td>Version</td>
+ <td><img src='https://img.shields.io/pypi/v/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Github Action</td>
+ <td><img src='https://github.com/ericziethen/django-property-filter/workflows/CI/badge.svg'></td>
+ <td>Coverage</td>
+ <td><img src='https://codecov.io/gh/ericziethen/django-property-filter/branch/master/graph/badge.svg'></td>
+ </tr>
+ <tr>
+ <td>Wheel</td>
+ <td><img src='https://img.shields.io/pypi/wheel/django-property-filter.svg'></td>
+ <td>Implementation</td>
+ <td><img src='https://img.shields.io/pypi/implementation/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Status</td>
+ <td><img src='https://img.shields.io/pypi/status/django-property-filter.svg'></td>
+ <td>Downloads</td>
+ <td><img src='https://img.shields.io/pypi/dm/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Supported versions</td>
+ <td><img src='https://img.shields.io/pypi/pyversions/django-property-filter.svg'></td>
+ </tr>
+</table>
+
+For more details and examples check the [documentation](https://django-property-filter.readthedocs.io/en/stable/).
+
+## Requirements
+
+* Python: 3.7, 3.8, 3.9, 3.10, 3.11
+* Django: 3.2, 4.0, 4.1
+* Django-filter: 2.3+
+
+## Limitations
+
+### Performance
+Because this app preserved Django Filtersets and filters them agains fields that are not Database fields all filtering happens in memory.
+Compared with direct sql optimized queries that might be slower and more memory intensive.
+
+### Limit on returned results
+In theory there is no limit for most databases how many results can be returned from a filter query unless the database implements a limit which will impact how many results django-property-filter can return.
+Sqlite3 defines different limits depending on the version used.
+For further details see the documentation for [limitations](https://django-property-filter.readthedocs.io/en/stable/guide/overview.html#limitations)
+
+## Installation
+
+Install using pip:
+
+```python
+pip install django-property-filter
+```
+
+Then add 'django_property_filter' to your INSTALLED_APPS.
+
+```python
+INSTALLED_APPS = [
+ ...
+ 'django_property_filter',
+]
+```
+
+## Usage
+
+### Example Model
+
+Our Model
+
+```python
+from django.db import models
+
+class BookSeries(models.Model):
+ name = models.CharField(max_length=255)
+
+ @property
+ def book_count(self):
+ return Book.objects.filter(series=self).count()
+
+class Book(models.Model):
+ title = models.CharField(max_length=255)
+ price = models.DecimalField()
+ discount_percentage = models.IntegerField()
+ author = models.TextField()
+ series = models.ForeignKey(BookSeries)
+
+ @property
+ def discounted_price(self):
+ return self.price * self.discount_percentage \ 100
+```
+
+### Implicit Filter Creation
+
+If we want to filter by discounted price as well as number of books in a series,
+which both are properties and not fields in the database, we would do the
+following.::
+
+```python
+from django_property_filter import PropertyFilterSet, PropertyNumberFilter
+
+class BookFilterSet(PropertyFilterSet):
+
+ class Meta:
+ model = Book
+ exclude = ['price']
+ property_fields = [
+ ('discounted_price', PropertyNumberFilter, ['lt', 'exact']),
+ ('series.book_count.', PropertyNumberFilter, ['gt', 'exact']),
+ ]
+```
+
+This will create 4 Filters
+
+ 1.) A "less than" and an "exact" filter for the "discounted_price" property
+ of the Book Model
+ 2.) A "greater than" and an "exact" filter for the "book_count" property
+ of the related Model "series".
+
+The order in which the property filters are applied are in the same order as
+they are defined. In the above filter will be in order of
+
+ 1.) discounted_price: lt
+ 2.) discounted_price: exact
+ 3.) series.book_count: gt
+ 4.) series.book_count: exact
+
+This can be usefull to speed up the filtering by property filters if filters
+are defined first that are likely to filter a large number of values.
+E.g. a boolean field might be filtering an average of half the values, while a
+field representing a name will likely filter fewer.
+
+Since PropertyFilterSet is and extension to django-filter's Filterset which
+requires either the Meta attribute "fields" or "exclude" to be set we excluded
+the "price" field. If we had instead used::
+ fields = ['price']
+
+It would also have created an "exact" filter for the book price.
+
+The only difference to using a normal FilterSet from django-filter is the
+"property_fields" field.
+
+The "property_fields" is a list of tuples with 3 values.
+
+ 1.) The property name.
+ If the property is on a related Model it should be separated by "__",
+ and can span multiple levels e.g. fk__fk__fk__property
+ 2.) The specific Property Filter to use.
+ This is necessary since it can't be determined what the return type
+ of the property will be in all cases
+ 3.) The list of lookup expressions.
+
+### Explicit Filter Creation
+
+It is also possible to create Filters explicitely.
+
+```python
+from django_property_filter import PropertyNumberFilter, PropertyFilterSet
+
+class BookFilterSet(PropertyFilterSet):
+ prop_number_gte = PropertyNumberFilter(field_name='discounted_price', lookup_expr='gte')
+ prop_number_lt = PropertyNumberFilter(field_name='discounted_price', lookup_expr='lt')
+
+ class Meta:
+ model = NumberClass
+ fields = ['prop_number_gte', 'prop_number_lt']
+```
+
+This creates a "greater than or equel" and a "less than" filter for the
+discounted_price property.
+
+The order in which the property filters are applied are in the same order as
+they are defined. In the above filter will be in order of
+
+ 1.) prop_number_gte
+ 2.) prop_number_lt
+This can be usefull to speed up the filtering by property filters if filters
+are defined first that are likely to filter a large number of values.
+E.g. a boolean field might be filtering an average of half the values, while a
+field representing a name will likely filter fewer.
+
+## Development
+
+# Run the Django Test Project to see the filters in action
+
+* go to "tests\django_test_proj"
+* run "python manage.py makemigrations"
+* run "python manage.py migrate"
+* run "python manage.py setup_data"
+* run "python manage.py runserver"
+
+## Issue Raising ##
+
+Raising bugs, feature requests and questions is possible via the public repository <a href="https://github.com/ericziethen/django-property-filter-issue-reporting" target="_blank">django-property-filter-issue-reporting</a>
+
+
+%package -n python3-django-property-filter
+Summary: Django Filter extension to support filtering by Properties
+Provides: python-django-property-filter
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-django-property-filter
+# Django Property Filter
+
+Django-property-filter is an extension to [django-filter](https://pypi.org/projhttps://pypi.org/project/django-filter/ect/django-filter/) and provides functionality to filter querysets by class properties.
+
+It does so by providing sub-classes for Filters and Filtersets to keep existing django-filter functionality.
+
+<table>
+ <tr>
+ <td>License</td>
+ <td><img src='https://img.shields.io/pypi/l/django-property-filter.svg'></td>
+ <td>Version</td>
+ <td><img src='https://img.shields.io/pypi/v/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Github Action</td>
+ <td><img src='https://github.com/ericziethen/django-property-filter/workflows/CI/badge.svg'></td>
+ <td>Coverage</td>
+ <td><img src='https://codecov.io/gh/ericziethen/django-property-filter/branch/master/graph/badge.svg'></td>
+ </tr>
+ <tr>
+ <td>Wheel</td>
+ <td><img src='https://img.shields.io/pypi/wheel/django-property-filter.svg'></td>
+ <td>Implementation</td>
+ <td><img src='https://img.shields.io/pypi/implementation/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Status</td>
+ <td><img src='https://img.shields.io/pypi/status/django-property-filter.svg'></td>
+ <td>Downloads</td>
+ <td><img src='https://img.shields.io/pypi/dm/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Supported versions</td>
+ <td><img src='https://img.shields.io/pypi/pyversions/django-property-filter.svg'></td>
+ </tr>
+</table>
+
+For more details and examples check the [documentation](https://django-property-filter.readthedocs.io/en/stable/).
+
+## Requirements
+
+* Python: 3.7, 3.8, 3.9, 3.10, 3.11
+* Django: 3.2, 4.0, 4.1
+* Django-filter: 2.3+
+
+## Limitations
+
+### Performance
+Because this app preserved Django Filtersets and filters them agains fields that are not Database fields all filtering happens in memory.
+Compared with direct sql optimized queries that might be slower and more memory intensive.
+
+### Limit on returned results
+In theory there is no limit for most databases how many results can be returned from a filter query unless the database implements a limit which will impact how many results django-property-filter can return.
+Sqlite3 defines different limits depending on the version used.
+For further details see the documentation for [limitations](https://django-property-filter.readthedocs.io/en/stable/guide/overview.html#limitations)
+
+## Installation
+
+Install using pip:
+
+```python
+pip install django-property-filter
+```
+
+Then add 'django_property_filter' to your INSTALLED_APPS.
+
+```python
+INSTALLED_APPS = [
+ ...
+ 'django_property_filter',
+]
+```
+
+## Usage
+
+### Example Model
+
+Our Model
+
+```python
+from django.db import models
+
+class BookSeries(models.Model):
+ name = models.CharField(max_length=255)
+
+ @property
+ def book_count(self):
+ return Book.objects.filter(series=self).count()
+
+class Book(models.Model):
+ title = models.CharField(max_length=255)
+ price = models.DecimalField()
+ discount_percentage = models.IntegerField()
+ author = models.TextField()
+ series = models.ForeignKey(BookSeries)
+
+ @property
+ def discounted_price(self):
+ return self.price * self.discount_percentage \ 100
+```
+
+### Implicit Filter Creation
+
+If we want to filter by discounted price as well as number of books in a series,
+which both are properties and not fields in the database, we would do the
+following.::
+
+```python
+from django_property_filter import PropertyFilterSet, PropertyNumberFilter
+
+class BookFilterSet(PropertyFilterSet):
+
+ class Meta:
+ model = Book
+ exclude = ['price']
+ property_fields = [
+ ('discounted_price', PropertyNumberFilter, ['lt', 'exact']),
+ ('series.book_count.', PropertyNumberFilter, ['gt', 'exact']),
+ ]
+```
+
+This will create 4 Filters
+
+ 1.) A "less than" and an "exact" filter for the "discounted_price" property
+ of the Book Model
+ 2.) A "greater than" and an "exact" filter for the "book_count" property
+ of the related Model "series".
+
+The order in which the property filters are applied are in the same order as
+they are defined. In the above filter will be in order of
+
+ 1.) discounted_price: lt
+ 2.) discounted_price: exact
+ 3.) series.book_count: gt
+ 4.) series.book_count: exact
+
+This can be usefull to speed up the filtering by property filters if filters
+are defined first that are likely to filter a large number of values.
+E.g. a boolean field might be filtering an average of half the values, while a
+field representing a name will likely filter fewer.
+
+Since PropertyFilterSet is and extension to django-filter's Filterset which
+requires either the Meta attribute "fields" or "exclude" to be set we excluded
+the "price" field. If we had instead used::
+ fields = ['price']
+
+It would also have created an "exact" filter for the book price.
+
+The only difference to using a normal FilterSet from django-filter is the
+"property_fields" field.
+
+The "property_fields" is a list of tuples with 3 values.
+
+ 1.) The property name.
+ If the property is on a related Model it should be separated by "__",
+ and can span multiple levels e.g. fk__fk__fk__property
+ 2.) The specific Property Filter to use.
+ This is necessary since it can't be determined what the return type
+ of the property will be in all cases
+ 3.) The list of lookup expressions.
+
+### Explicit Filter Creation
+
+It is also possible to create Filters explicitely.
+
+```python
+from django_property_filter import PropertyNumberFilter, PropertyFilterSet
+
+class BookFilterSet(PropertyFilterSet):
+ prop_number_gte = PropertyNumberFilter(field_name='discounted_price', lookup_expr='gte')
+ prop_number_lt = PropertyNumberFilter(field_name='discounted_price', lookup_expr='lt')
+
+ class Meta:
+ model = NumberClass
+ fields = ['prop_number_gte', 'prop_number_lt']
+```
+
+This creates a "greater than or equel" and a "less than" filter for the
+discounted_price property.
+
+The order in which the property filters are applied are in the same order as
+they are defined. In the above filter will be in order of
+
+ 1.) prop_number_gte
+ 2.) prop_number_lt
+This can be usefull to speed up the filtering by property filters if filters
+are defined first that are likely to filter a large number of values.
+E.g. a boolean field might be filtering an average of half the values, while a
+field representing a name will likely filter fewer.
+
+## Development
+
+# Run the Django Test Project to see the filters in action
+
+* go to "tests\django_test_proj"
+* run "python manage.py makemigrations"
+* run "python manage.py migrate"
+* run "python manage.py setup_data"
+* run "python manage.py runserver"
+
+## Issue Raising ##
+
+Raising bugs, feature requests and questions is possible via the public repository <a href="https://github.com/ericziethen/django-property-filter-issue-reporting" target="_blank">django-property-filter-issue-reporting</a>
+
+
+%package help
+Summary: Development documents and examples for django-property-filter
+Provides: python3-django-property-filter-doc
+%description help
+# Django Property Filter
+
+Django-property-filter is an extension to [django-filter](https://pypi.org/projhttps://pypi.org/project/django-filter/ect/django-filter/) and provides functionality to filter querysets by class properties.
+
+It does so by providing sub-classes for Filters and Filtersets to keep existing django-filter functionality.
+
+<table>
+ <tr>
+ <td>License</td>
+ <td><img src='https://img.shields.io/pypi/l/django-property-filter.svg'></td>
+ <td>Version</td>
+ <td><img src='https://img.shields.io/pypi/v/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Github Action</td>
+ <td><img src='https://github.com/ericziethen/django-property-filter/workflows/CI/badge.svg'></td>
+ <td>Coverage</td>
+ <td><img src='https://codecov.io/gh/ericziethen/django-property-filter/branch/master/graph/badge.svg'></td>
+ </tr>
+ <tr>
+ <td>Wheel</td>
+ <td><img src='https://img.shields.io/pypi/wheel/django-property-filter.svg'></td>
+ <td>Implementation</td>
+ <td><img src='https://img.shields.io/pypi/implementation/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Status</td>
+ <td><img src='https://img.shields.io/pypi/status/django-property-filter.svg'></td>
+ <td>Downloads</td>
+ <td><img src='https://img.shields.io/pypi/dm/django-property-filter.svg'></td>
+ </tr>
+ <tr>
+ <td>Supported versions</td>
+ <td><img src='https://img.shields.io/pypi/pyversions/django-property-filter.svg'></td>
+ </tr>
+</table>
+
+For more details and examples check the [documentation](https://django-property-filter.readthedocs.io/en/stable/).
+
+## Requirements
+
+* Python: 3.7, 3.8, 3.9, 3.10, 3.11
+* Django: 3.2, 4.0, 4.1
+* Django-filter: 2.3+
+
+## Limitations
+
+### Performance
+Because this app preserved Django Filtersets and filters them agains fields that are not Database fields all filtering happens in memory.
+Compared with direct sql optimized queries that might be slower and more memory intensive.
+
+### Limit on returned results
+In theory there is no limit for most databases how many results can be returned from a filter query unless the database implements a limit which will impact how many results django-property-filter can return.
+Sqlite3 defines different limits depending on the version used.
+For further details see the documentation for [limitations](https://django-property-filter.readthedocs.io/en/stable/guide/overview.html#limitations)
+
+## Installation
+
+Install using pip:
+
+```python
+pip install django-property-filter
+```
+
+Then add 'django_property_filter' to your INSTALLED_APPS.
+
+```python
+INSTALLED_APPS = [
+ ...
+ 'django_property_filter',
+]
+```
+
+## Usage
+
+### Example Model
+
+Our Model
+
+```python
+from django.db import models
+
+class BookSeries(models.Model):
+ name = models.CharField(max_length=255)
+
+ @property
+ def book_count(self):
+ return Book.objects.filter(series=self).count()
+
+class Book(models.Model):
+ title = models.CharField(max_length=255)
+ price = models.DecimalField()
+ discount_percentage = models.IntegerField()
+ author = models.TextField()
+ series = models.ForeignKey(BookSeries)
+
+ @property
+ def discounted_price(self):
+ return self.price * self.discount_percentage \ 100
+```
+
+### Implicit Filter Creation
+
+If we want to filter by discounted price as well as number of books in a series,
+which both are properties and not fields in the database, we would do the
+following.::
+
+```python
+from django_property_filter import PropertyFilterSet, PropertyNumberFilter
+
+class BookFilterSet(PropertyFilterSet):
+
+ class Meta:
+ model = Book
+ exclude = ['price']
+ property_fields = [
+ ('discounted_price', PropertyNumberFilter, ['lt', 'exact']),
+ ('series.book_count.', PropertyNumberFilter, ['gt', 'exact']),
+ ]
+```
+
+This will create 4 Filters
+
+ 1.) A "less than" and an "exact" filter for the "discounted_price" property
+ of the Book Model
+ 2.) A "greater than" and an "exact" filter for the "book_count" property
+ of the related Model "series".
+
+The order in which the property filters are applied are in the same order as
+they are defined. In the above filter will be in order of
+
+ 1.) discounted_price: lt
+ 2.) discounted_price: exact
+ 3.) series.book_count: gt
+ 4.) series.book_count: exact
+
+This can be usefull to speed up the filtering by property filters if filters
+are defined first that are likely to filter a large number of values.
+E.g. a boolean field might be filtering an average of half the values, while a
+field representing a name will likely filter fewer.
+
+Since PropertyFilterSet is and extension to django-filter's Filterset which
+requires either the Meta attribute "fields" or "exclude" to be set we excluded
+the "price" field. If we had instead used::
+ fields = ['price']
+
+It would also have created an "exact" filter for the book price.
+
+The only difference to using a normal FilterSet from django-filter is the
+"property_fields" field.
+
+The "property_fields" is a list of tuples with 3 values.
+
+ 1.) The property name.
+ If the property is on a related Model it should be separated by "__",
+ and can span multiple levels e.g. fk__fk__fk__property
+ 2.) The specific Property Filter to use.
+ This is necessary since it can't be determined what the return type
+ of the property will be in all cases
+ 3.) The list of lookup expressions.
+
+### Explicit Filter Creation
+
+It is also possible to create Filters explicitely.
+
+```python
+from django_property_filter import PropertyNumberFilter, PropertyFilterSet
+
+class BookFilterSet(PropertyFilterSet):
+ prop_number_gte = PropertyNumberFilter(field_name='discounted_price', lookup_expr='gte')
+ prop_number_lt = PropertyNumberFilter(field_name='discounted_price', lookup_expr='lt')
+
+ class Meta:
+ model = NumberClass
+ fields = ['prop_number_gte', 'prop_number_lt']
+```
+
+This creates a "greater than or equel" and a "less than" filter for the
+discounted_price property.
+
+The order in which the property filters are applied are in the same order as
+they are defined. In the above filter will be in order of
+
+ 1.) prop_number_gte
+ 2.) prop_number_lt
+This can be usefull to speed up the filtering by property filters if filters
+are defined first that are likely to filter a large number of values.
+E.g. a boolean field might be filtering an average of half the values, while a
+field representing a name will likely filter fewer.
+
+## Development
+
+# Run the Django Test Project to see the filters in action
+
+* go to "tests\django_test_proj"
+* run "python manage.py makemigrations"
+* run "python manage.py migrate"
+* run "python manage.py setup_data"
+* run "python manage.py runserver"
+
+## Issue Raising ##
+
+Raising bugs, feature requests and questions is possible via the public repository <a href="https://github.com/ericziethen/django-property-filter-issue-reporting" target="_blank">django-property-filter-issue-reporting</a>
+
+
+%prep
+%autosetup -n django-property-filter-1.1.2
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-django-property-filter -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.2-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..fa31e42
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+5cc8b2f3defd734bf7886cfd6f770960 django-property-filter-1.1.2.tar.gz