diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-31 04:56:42 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-31 04:56:42 +0000 |
commit | 4da2ce346eca2be62e8eea160e49563b89db6c19 (patch) | |
tree | 460b1827579429ebd5c23ee307f22316223c0ef7 | |
parent | c0c6b1f9bfcce448bf5544d2395ee49ca263a71f (diff) |
automatic import of python-django-treewidget
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-django-treewidget.spec | 318 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 320 insertions, 0 deletions
@@ -0,0 +1 @@ +/django-treewidget-0.4.2.tar.gz diff --git a/python-django-treewidget.spec b/python-django-treewidget.spec new file mode 100644 index 0000000..d602d88 --- /dev/null +++ b/python-django-treewidget.spec @@ -0,0 +1,318 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-treewidget +Version: 0.4.2 +Release: 1 +Summary: treewidget for django admin +License: MIT +URL: https://github.com/jerch/django-treewidget +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/fe/58/485d90c0bac965125b15889460b920ea3ac99093f720cd0b1d59fbe91aac/django-treewidget-0.4.2.tar.gz +BuildArch: noarch + + +%description +## treewidget for Django ## + +Provides the model fields TreeForeignKey, TreeOneToOneField, TreeManyToManyField +for tree models with a tree widget for django. Uses `jstree` (thanks to vakata). + +Tested with django-mptt 0.13.4 and django-treebeard 4.5.1 with Django 3.2 & 4.0. + + +### Installation ### + +- `pip install django-treewidget` +- place `'treewidget'` in `INSTALLED_APPS` +- for AJAX tree updates add the routes to your urls.py, +e.g. `url(r'^treewidget/', include('treewidget.urls'))` + + +### Usage ### + +Just replace any foreign key, m2m or one2one tree model field with the provided counterpart. +jstree depends on jQuery to work. This module does not provide a jQuery version, use the +admin version or place your own version along with your other assets. + + +### Customization ### + +The fields understand two additional arguments: + +- **settings**: Dictionary containing the optional boolean values for 'show_buttons' +(shows "Expand", "Collapse" and "Selected" buttons), 'search' (for in-tree search), +'dnd' (drag and drop support) and 'sort' (apply tree order in frontend). Defaults to `{}`. +- **treeoptions**: Settings directly applied to `jstree`. Must be a JSON string, if given as +argument to a field, otherwise a python dictionary. Defaults to `treewidget.fields.TREEOPTIONS`. +Note that some widget settings will override treeoptions to keep working. + +Both settings can be provided project wide in settings.py as `TREEWIDGET_SETTINGS` and +`TREEWIDGET_TREEOPTIONS`. + +It is possible to render a deeper nested subtree by overriding the default +formatter. Just set the parent id to '#' in the formatter's `render` method for the entries, +that should appear at top level. + +**NOTE**: If you use a prefiltered queryset which data does not form a well-formed tree +containing all parents up to the top level, jstree cannot render it correctly. +With 'filtered' in settings set to `True` those querysets will be rendered by +adding missing nodes as not selectable. Make sure, that this does not leak +sensitive tree data (if so, resort to subtree rendering). + +### Example ### +```python +from django.db import models +from mptt.models import MPTTModel +from treewidget.fields import TreeForeignKey + +class Mptt(MPTTModel): + name = models.CharField(max_length=32) + parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE) + + def __str__(self): + return self.name +``` + +Renders like this: + + + + +To run the provided example project: + +```bash +$> cd example +$> pip install Django~=3.2 # or 4.0 +$> pip install -r requirements.txt +$> ./manage.py migrate +$> ./manage.py createsuperuser +$> ./manage.py loaddata initial_data +$> ./manage.py runserver +``` + +and point your browser to `http://localhost:8000/admin/exampleapp/example/add/`. +After login you see the widgets in action with different settings. +Also see `exampleapp.Example` model in admin to get an idea of several tree rendering options. + + + +%package -n python3-django-treewidget +Summary: treewidget for django admin +Provides: python-django-treewidget +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-treewidget +## treewidget for Django ## + +Provides the model fields TreeForeignKey, TreeOneToOneField, TreeManyToManyField +for tree models with a tree widget for django. Uses `jstree` (thanks to vakata). + +Tested with django-mptt 0.13.4 and django-treebeard 4.5.1 with Django 3.2 & 4.0. + + +### Installation ### + +- `pip install django-treewidget` +- place `'treewidget'` in `INSTALLED_APPS` +- for AJAX tree updates add the routes to your urls.py, +e.g. `url(r'^treewidget/', include('treewidget.urls'))` + + +### Usage ### + +Just replace any foreign key, m2m or one2one tree model field with the provided counterpart. +jstree depends on jQuery to work. This module does not provide a jQuery version, use the +admin version or place your own version along with your other assets. + + +### Customization ### + +The fields understand two additional arguments: + +- **settings**: Dictionary containing the optional boolean values for 'show_buttons' +(shows "Expand", "Collapse" and "Selected" buttons), 'search' (for in-tree search), +'dnd' (drag and drop support) and 'sort' (apply tree order in frontend). Defaults to `{}`. +- **treeoptions**: Settings directly applied to `jstree`. Must be a JSON string, if given as +argument to a field, otherwise a python dictionary. Defaults to `treewidget.fields.TREEOPTIONS`. +Note that some widget settings will override treeoptions to keep working. + +Both settings can be provided project wide in settings.py as `TREEWIDGET_SETTINGS` and +`TREEWIDGET_TREEOPTIONS`. + +It is possible to render a deeper nested subtree by overriding the default +formatter. Just set the parent id to '#' in the formatter's `render` method for the entries, +that should appear at top level. + +**NOTE**: If you use a prefiltered queryset which data does not form a well-formed tree +containing all parents up to the top level, jstree cannot render it correctly. +With 'filtered' in settings set to `True` those querysets will be rendered by +adding missing nodes as not selectable. Make sure, that this does not leak +sensitive tree data (if so, resort to subtree rendering). + +### Example ### +```python +from django.db import models +from mptt.models import MPTTModel +from treewidget.fields import TreeForeignKey + +class Mptt(MPTTModel): + name = models.CharField(max_length=32) + parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE) + + def __str__(self): + return self.name +``` + +Renders like this: + + + + +To run the provided example project: + +```bash +$> cd example +$> pip install Django~=3.2 # or 4.0 +$> pip install -r requirements.txt +$> ./manage.py migrate +$> ./manage.py createsuperuser +$> ./manage.py loaddata initial_data +$> ./manage.py runserver +``` + +and point your browser to `http://localhost:8000/admin/exampleapp/example/add/`. +After login you see the widgets in action with different settings. +Also see `exampleapp.Example` model in admin to get an idea of several tree rendering options. + + + +%package help +Summary: Development documents and examples for django-treewidget +Provides: python3-django-treewidget-doc +%description help +## treewidget for Django ## + +Provides the model fields TreeForeignKey, TreeOneToOneField, TreeManyToManyField +for tree models with a tree widget for django. Uses `jstree` (thanks to vakata). + +Tested with django-mptt 0.13.4 and django-treebeard 4.5.1 with Django 3.2 & 4.0. + + +### Installation ### + +- `pip install django-treewidget` +- place `'treewidget'` in `INSTALLED_APPS` +- for AJAX tree updates add the routes to your urls.py, +e.g. `url(r'^treewidget/', include('treewidget.urls'))` + + +### Usage ### + +Just replace any foreign key, m2m or one2one tree model field with the provided counterpart. +jstree depends on jQuery to work. This module does not provide a jQuery version, use the +admin version or place your own version along with your other assets. + + +### Customization ### + +The fields understand two additional arguments: + +- **settings**: Dictionary containing the optional boolean values for 'show_buttons' +(shows "Expand", "Collapse" and "Selected" buttons), 'search' (for in-tree search), +'dnd' (drag and drop support) and 'sort' (apply tree order in frontend). Defaults to `{}`. +- **treeoptions**: Settings directly applied to `jstree`. Must be a JSON string, if given as +argument to a field, otherwise a python dictionary. Defaults to `treewidget.fields.TREEOPTIONS`. +Note that some widget settings will override treeoptions to keep working. + +Both settings can be provided project wide in settings.py as `TREEWIDGET_SETTINGS` and +`TREEWIDGET_TREEOPTIONS`. + +It is possible to render a deeper nested subtree by overriding the default +formatter. Just set the parent id to '#' in the formatter's `render` method for the entries, +that should appear at top level. + +**NOTE**: If you use a prefiltered queryset which data does not form a well-formed tree +containing all parents up to the top level, jstree cannot render it correctly. +With 'filtered' in settings set to `True` those querysets will be rendered by +adding missing nodes as not selectable. Make sure, that this does not leak +sensitive tree data (if so, resort to subtree rendering). + +### Example ### +```python +from django.db import models +from mptt.models import MPTTModel +from treewidget.fields import TreeForeignKey + +class Mptt(MPTTModel): + name = models.CharField(max_length=32) + parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE) + + def __str__(self): + return self.name +``` + +Renders like this: + + + + +To run the provided example project: + +```bash +$> cd example +$> pip install Django~=3.2 # or 4.0 +$> pip install -r requirements.txt +$> ./manage.py migrate +$> ./manage.py createsuperuser +$> ./manage.py loaddata initial_data +$> ./manage.py runserver +``` + +and point your browser to `http://localhost:8000/admin/exampleapp/example/add/`. +After login you see the widgets in action with different settings. +Also see `exampleapp.Example` model in admin to get an idea of several tree rendering options. + + + +%prep +%autosetup -n django-treewidget-0.4.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-treewidget -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.2-1 +- Package Spec generated @@ -0,0 +1 @@ +80dfb0448e89d4738ae48baa16d5617d django-treewidget-0.4.2.tar.gz |