diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-04-11 17:33:30 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-04-11 17:33:30 +0000 |
| commit | 35a9ae82df0de9cab8e937cf134767170fdbbdef (patch) | |
| tree | 11884c92b8e9820b2c7db040a5432227808a0e51 | |
| parent | d807947bfc69eb16058e5f0c8636bbbf5df878e8 (diff) | |
automatic import of python-django-admin-json-editor
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-django-admin-json-editor.spec | 318 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 320 insertions, 0 deletions
@@ -0,0 +1 @@ +/django-admin-json-editor-0.2.3.tar.gz diff --git a/python-django-admin-json-editor.spec b/python-django-admin-json-editor.spec new file mode 100644 index 0000000..75c1d56 --- /dev/null +++ b/python-django-admin-json-editor.spec @@ -0,0 +1,318 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-admin-json-editor +Version: 0.2.3 +Release: 1 +Summary: A simple Django app to add JSON widget into Django Administration. +License: MIT License +URL: https://github.com/abogushov/django-admin-json-editor +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/db/eb/33401a7c47b078b12a281952c6e963906602a3eeff13f400adda15e4de7f/django-admin-json-editor-0.2.3.tar.gz +BuildArch: noarch + + +%description +# Django Administration JSON Editor + +[](https://travis-ci.org/abogushov/django-admin-json-editor) + + + + +Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor. + +## Quick start + +Install application via pip: + +```bash +pip install django-admin-json-editor +``` + +Add application to the INSTALLED_APPS settings: + +```python +INSTALLED_APPS = [ + ... + 'django_admin_json_editor', + ... +] +``` + +Define schema of json field: + +```python +DATA_SCHEMA = { + 'type': 'object', + 'title': 'Data', + 'properties': { + 'text': { + 'title': 'Some text', + 'type': 'string', + 'format': 'textarea', + }, + 'status': { + 'title': 'Status', + 'type': 'boolean', + }, + }, +} +``` + +Use JSONEditorWidget to bind editor to the form field: + +```python +class JSONModelAdminForm(forms.ModelForm): + class Meta: + model = JSONModel + fields = '__all__' + widgets = { + 'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False), + } +``` + +### Dynamic schema + +It is possible to build dynamic schema for widget: + +```python +def dynamic_schema(widget): + return { + 'type': 'array', + 'title': 'tags', + 'items': { + 'type': 'string', + 'enum': [i for i in Tag.objects.values_list('name', flat=True)], + } + } +``` + +```python +@admin.register(JSONModel) +class JSONModelAdmin(admin.ModelAdmin): + def get_form(self, request, obj=None, **kwargs): + widget = JSONEditorWidget(dynamic_schema, False) + form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs) + return form +``` + +%package -n python3-django-admin-json-editor +Summary: A simple Django app to add JSON widget into Django Administration. +Provides: python-django-admin-json-editor +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-admin-json-editor +# Django Administration JSON Editor + +[](https://travis-ci.org/abogushov/django-admin-json-editor) + + + + +Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor. + +## Quick start + +Install application via pip: + +```bash +pip install django-admin-json-editor +``` + +Add application to the INSTALLED_APPS settings: + +```python +INSTALLED_APPS = [ + ... + 'django_admin_json_editor', + ... +] +``` + +Define schema of json field: + +```python +DATA_SCHEMA = { + 'type': 'object', + 'title': 'Data', + 'properties': { + 'text': { + 'title': 'Some text', + 'type': 'string', + 'format': 'textarea', + }, + 'status': { + 'title': 'Status', + 'type': 'boolean', + }, + }, +} +``` + +Use JSONEditorWidget to bind editor to the form field: + +```python +class JSONModelAdminForm(forms.ModelForm): + class Meta: + model = JSONModel + fields = '__all__' + widgets = { + 'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False), + } +``` + +### Dynamic schema + +It is possible to build dynamic schema for widget: + +```python +def dynamic_schema(widget): + return { + 'type': 'array', + 'title': 'tags', + 'items': { + 'type': 'string', + 'enum': [i for i in Tag.objects.values_list('name', flat=True)], + } + } +``` + +```python +@admin.register(JSONModel) +class JSONModelAdmin(admin.ModelAdmin): + def get_form(self, request, obj=None, **kwargs): + widget = JSONEditorWidget(dynamic_schema, False) + form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs) + return form +``` + +%package help +Summary: Development documents and examples for django-admin-json-editor +Provides: python3-django-admin-json-editor-doc +%description help +# Django Administration JSON Editor + +[](https://travis-ci.org/abogushov/django-admin-json-editor) + + + + +Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor. + +## Quick start + +Install application via pip: + +```bash +pip install django-admin-json-editor +``` + +Add application to the INSTALLED_APPS settings: + +```python +INSTALLED_APPS = [ + ... + 'django_admin_json_editor', + ... +] +``` + +Define schema of json field: + +```python +DATA_SCHEMA = { + 'type': 'object', + 'title': 'Data', + 'properties': { + 'text': { + 'title': 'Some text', + 'type': 'string', + 'format': 'textarea', + }, + 'status': { + 'title': 'Status', + 'type': 'boolean', + }, + }, +} +``` + +Use JSONEditorWidget to bind editor to the form field: + +```python +class JSONModelAdminForm(forms.ModelForm): + class Meta: + model = JSONModel + fields = '__all__' + widgets = { + 'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False), + } +``` + +### Dynamic schema + +It is possible to build dynamic schema for widget: + +```python +def dynamic_schema(widget): + return { + 'type': 'array', + 'title': 'tags', + 'items': { + 'type': 'string', + 'enum': [i for i in Tag.objects.values_list('name', flat=True)], + } + } +``` + +```python +@admin.register(JSONModel) +class JSONModelAdmin(admin.ModelAdmin): + def get_form(self, request, obj=None, **kwargs): + widget = JSONEditorWidget(dynamic_schema, False) + form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs) + return form +``` + +%prep +%autosetup -n django-admin-json-editor-0.2.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-django-admin-json-editor -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.3-1 +- Package Spec generated @@ -0,0 +1 @@ +990bca6805988987f33a504ee9facb2e django-admin-json-editor-0.2.3.tar.gz |
