summaryrefslogtreecommitdiff
path: root/python-ax3-model-extras.spec
diff options
context:
space:
mode:
Diffstat (limited to 'python-ax3-model-extras.spec')
-rw-r--r--python-ax3-model-extras.spec499
1 files changed, 499 insertions, 0 deletions
diff --git a/python-ax3-model-extras.spec b/python-ax3-model-extras.spec
new file mode 100644
index 0000000..3834494
--- /dev/null
+++ b/python-ax3-model-extras.spec
@@ -0,0 +1,499 @@
+%global _empty_manifest_terminate_build 0
+Name: python-AX3-model-extras
+Version: 1.5.3
+Release: 1
+Summary: Django app extras for AX3 models
+License: MIT License
+URL: https://github.com/Axiacore/ax3-model-extras
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/cd/dc/c1d6894e0b58559b73001546e28eae4c3d684ae700fe56e3e488b96b891a/AX3%20model%20extras-1.5.3.tar.gz
+BuildArch: noarch
+
+Requires: python3-django
+Requires: python3-phonenumberslite
+Requires: python3-resize-image
+Requires: python3-magic
+
+%description
+# AX3 Model Extras
+
+## Installation
+AX3 Model Extras is easy to install from the PyPI package:
+
+```bash
+$ pip install ax3-model-extras
+```
+
+To enable ax3_model_extras in your project you need to add it to INSTALLED_APPS in your projects settings.py file:
+
+```python
+INSTALLED_APPS = (
+ ...
+ 'ax3_model_extras',
+ ...
+)
+```
+
+## Validate image size
+
+If you want to validate the dimension and file size for images:
+
+```python
+from ax3_model_extras.validators import FileSizeValidator, ImageDimensionValidator
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ validators=[ImageDimensionValidator([1920, 800]), FileSizeValidator(350)],
+ help_text='JPG. 1920x800px. 350kb max.',
+ )
+```
+
+If you want to validate one dimension, you have to send the other dimension with 0
+
+```python
+from ax3_model_extras.validators import FileSizeValidator, ImageDimensionValidator
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ validators=[ImageDimensionValidator([1920, 0]), FileSizeValidator(350)],
+ help_text='JPG. width=1920px. 350kb max.',
+ )
+```
+
+
+
+## Improve file storage
+
+If you want to improve the local file storage or use S3 upload:
+
+```python
+from ax3_model_extras.storages import get_storage, get_upload_path
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ upload_to=get_upload_path,
+ storage=get_storage(),
+ )
+```
+
+
+## Optimize images before upload them.
+
+Use as:
+
+```python
+from ax3_model_extras.fields import OptimizedImageField
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = OptimizedImageField()
+
+```
+
+
+If want to set the size of the image using the 'cover' method do:
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+)
+```
+
+
+If want to set the size of the image using the 'thumbnail' method do:
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+)
+```
+
+
+If want to restrict the file format do (If not set it supports JPEG, PNG and GIF):
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+ optimized_file_formats=['PNG'],
+)
+```
+
+
+If want to specific quality of the image (If not set it default = 75):
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+ optimized_file_formats=['PNG'],
+ optimized_image_quality=85.5,
+)
+```
+
+Resize is done using https://pypi.org/project/python-resize-image/
+
+Made by Axiacore.
+
+
+
+
+%package -n python3-AX3-model-extras
+Summary: Django app extras for AX3 models
+Provides: python-AX3-model-extras
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-AX3-model-extras
+# AX3 Model Extras
+
+## Installation
+AX3 Model Extras is easy to install from the PyPI package:
+
+```bash
+$ pip install ax3-model-extras
+```
+
+To enable ax3_model_extras in your project you need to add it to INSTALLED_APPS in your projects settings.py file:
+
+```python
+INSTALLED_APPS = (
+ ...
+ 'ax3_model_extras',
+ ...
+)
+```
+
+## Validate image size
+
+If you want to validate the dimension and file size for images:
+
+```python
+from ax3_model_extras.validators import FileSizeValidator, ImageDimensionValidator
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ validators=[ImageDimensionValidator([1920, 800]), FileSizeValidator(350)],
+ help_text='JPG. 1920x800px. 350kb max.',
+ )
+```
+
+If you want to validate one dimension, you have to send the other dimension with 0
+
+```python
+from ax3_model_extras.validators import FileSizeValidator, ImageDimensionValidator
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ validators=[ImageDimensionValidator([1920, 0]), FileSizeValidator(350)],
+ help_text='JPG. width=1920px. 350kb max.',
+ )
+```
+
+
+
+## Improve file storage
+
+If you want to improve the local file storage or use S3 upload:
+
+```python
+from ax3_model_extras.storages import get_storage, get_upload_path
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ upload_to=get_upload_path,
+ storage=get_storage(),
+ )
+```
+
+
+## Optimize images before upload them.
+
+Use as:
+
+```python
+from ax3_model_extras.fields import OptimizedImageField
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = OptimizedImageField()
+
+```
+
+
+If want to set the size of the image using the 'cover' method do:
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+)
+```
+
+
+If want to set the size of the image using the 'thumbnail' method do:
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+)
+```
+
+
+If want to restrict the file format do (If not set it supports JPEG, PNG and GIF):
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+ optimized_file_formats=['PNG'],
+)
+```
+
+
+If want to specific quality of the image (If not set it default = 75):
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+ optimized_file_formats=['PNG'],
+ optimized_image_quality=85.5,
+)
+```
+
+Resize is done using https://pypi.org/project/python-resize-image/
+
+Made by Axiacore.
+
+
+
+
+%package help
+Summary: Development documents and examples for AX3-model-extras
+Provides: python3-AX3-model-extras-doc
+%description help
+# AX3 Model Extras
+
+## Installation
+AX3 Model Extras is easy to install from the PyPI package:
+
+```bash
+$ pip install ax3-model-extras
+```
+
+To enable ax3_model_extras in your project you need to add it to INSTALLED_APPS in your projects settings.py file:
+
+```python
+INSTALLED_APPS = (
+ ...
+ 'ax3_model_extras',
+ ...
+)
+```
+
+## Validate image size
+
+If you want to validate the dimension and file size for images:
+
+```python
+from ax3_model_extras.validators import FileSizeValidator, ImageDimensionValidator
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ validators=[ImageDimensionValidator([1920, 800]), FileSizeValidator(350)],
+ help_text='JPG. 1920x800px. 350kb max.',
+ )
+```
+
+If you want to validate one dimension, you have to send the other dimension with 0
+
+```python
+from ax3_model_extras.validators import FileSizeValidator, ImageDimensionValidator
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ validators=[ImageDimensionValidator([1920, 0]), FileSizeValidator(350)],
+ help_text='JPG. width=1920px. 350kb max.',
+ )
+```
+
+
+
+## Improve file storage
+
+If you want to improve the local file storage or use S3 upload:
+
+```python
+from ax3_model_extras.storages import get_storage, get_upload_path
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = models.ImageField(
+ upload_to=get_upload_path,
+ storage=get_storage(),
+ )
+```
+
+
+## Optimize images before upload them.
+
+Use as:
+
+```python
+from ax3_model_extras.fields import OptimizedImageField
+
+
+class Post(models.Model):
+ title = models.CharField()
+
+ slug = models.SlugField()
+
+ image = OptimizedImageField()
+
+```
+
+
+If want to set the size of the image using the 'cover' method do:
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+)
+```
+
+
+If want to set the size of the image using the 'thumbnail' method do:
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+)
+```
+
+
+If want to restrict the file format do (If not set it supports JPEG, PNG and GIF):
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+ optimized_file_formats=['PNG'],
+)
+```
+
+
+If want to specific quality of the image (If not set it default = 75):
+
+```python
+image = OptimizedImageField(
+ optimized_image_output_size=(1920, 800),
+ optimized_image_resize_method='thumbnail',
+ optimized_file_formats=['PNG'],
+ optimized_image_quality=85.5,
+)
+```
+
+Resize is done using https://pypi.org/project/python-resize-image/
+
+Made by Axiacore.
+
+
+
+
+%prep
+%autosetup -n AX3-model-extras-1.5.3
+
+%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-AX3-model-extras -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.5.3-1
+- Package Spec generated