summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-django-toggle-switch-widget.spec318
-rw-r--r--sources1
3 files changed, 320 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..9b96659 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/django-toggle-switch-widget-0.1.1.tar.gz
diff --git a/python-django-toggle-switch-widget.spec b/python-django-toggle-switch-widget.spec
new file mode 100644
index 0000000..15c5256
--- /dev/null
+++ b/python-django-toggle-switch-widget.spec
@@ -0,0 +1,318 @@
+%global _empty_manifest_terminate_build 0
+Name: python-django-toggle-switch-widget
+Version: 0.1.1
+Release: 1
+Summary: Display toggle switch in stead of checkbox for BooleanField in django admin site.
+License: MIT
+URL: https://github.com/zencore-cn/zencore-issues
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/04/b0/dd576a4b40953af8fb29b5ea1a6a8b5145285d9e6efebe581d715d1df310/django-toggle-switch-widget-0.1.1.tar.gz
+BuildArch: noarch
+
+
+%description
+# django-toggle-switch-widget
+
+Display toggle switch in stead of checkbox for BooleanField in django admin site.
+
+## Install
+
+```shell
+pip install django-toggle-switch-widget
+```
+
+## Widget init parameters
+
+- attrs: Inherit from CheckboxInput.
+- check_test: Inherit from CheckboxInput.
+- round: Default to False. If round=True, display round switch. If round=False, display squire switch.
+- klass: Default to empty string "". Pre-setted klass are:
+ - django-toggle-switch-success: Show success color (green, #06ad3d) while toggle on.
+ - django-toggle-switch-warning: Show warning color (orange, #ff6a00) while toggle on.
+ - django-toggle-switch-danger: Show danger color (red, #ba2121) while toggle on.
+ - django-toggle-switch-dark-primary: Show dark primary color (darkcyan, #417690) while toggle on.
+ - django-toggle-switch-primary: Show primary color (cadetblue, #79aec8) while toggle on.
+
+## Usage
+
+**pro/settings.py**
+
+```python
+INSTALLED_APPS = [
+ ...
+ 'django_toggle_switch_widget',
+ ...
+]
+```
+
+**app/model.py**
+
+```python
+from django.db import models
+
+class TestModel(models.Model):
+ title = models.CharField(max_length=64, help_text="Please input model title.")
+ published = models.BooleanField(verbose_name="Is this test model published.")
+ is_demo = models.BooleanField(help_text="Is this a demo test model?")
+
+```
+
+**app/admin.py**
+
+```python
+from django.contrib import admin
+from django.forms import ModelForm
+from django_toggle_switch_widget.widgets import DjangoToggleSwitchWidget
+from .models import TestModel
+
+class TestModelForm(ModelForm):
+ class Meta:
+ model = TestModel
+ fields = "__all__"
+ widgets = {
+ "published": DjangoToggleSwitchWidget(klass="django-toggle-switch-dark-primary"),
+ "is_demo": DjangoToggleSwitchWidget(round=True, klass="django-toggle-switch-success"),
+ }
+
+class TestModeldmin(admin.ModelAdmin):
+ form = TestModelForm
+
+admin.site.register(TestModel, TestModeldmin)
+
+```
+
+## Tips
+
+- It's better to use together with django-checkbox-normalize app.
+
+## Release
+
+### v0.1.1 2020/09/09
+
+- Add License.
+
+### v0.1.0 2020/03/02
+
+- First release.
+
+%package -n python3-django-toggle-switch-widget
+Summary: Display toggle switch in stead of checkbox for BooleanField in django admin site.
+Provides: python-django-toggle-switch-widget
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-django-toggle-switch-widget
+# django-toggle-switch-widget
+
+Display toggle switch in stead of checkbox for BooleanField in django admin site.
+
+## Install
+
+```shell
+pip install django-toggle-switch-widget
+```
+
+## Widget init parameters
+
+- attrs: Inherit from CheckboxInput.
+- check_test: Inherit from CheckboxInput.
+- round: Default to False. If round=True, display round switch. If round=False, display squire switch.
+- klass: Default to empty string "". Pre-setted klass are:
+ - django-toggle-switch-success: Show success color (green, #06ad3d) while toggle on.
+ - django-toggle-switch-warning: Show warning color (orange, #ff6a00) while toggle on.
+ - django-toggle-switch-danger: Show danger color (red, #ba2121) while toggle on.
+ - django-toggle-switch-dark-primary: Show dark primary color (darkcyan, #417690) while toggle on.
+ - django-toggle-switch-primary: Show primary color (cadetblue, #79aec8) while toggle on.
+
+## Usage
+
+**pro/settings.py**
+
+```python
+INSTALLED_APPS = [
+ ...
+ 'django_toggle_switch_widget',
+ ...
+]
+```
+
+**app/model.py**
+
+```python
+from django.db import models
+
+class TestModel(models.Model):
+ title = models.CharField(max_length=64, help_text="Please input model title.")
+ published = models.BooleanField(verbose_name="Is this test model published.")
+ is_demo = models.BooleanField(help_text="Is this a demo test model?")
+
+```
+
+**app/admin.py**
+
+```python
+from django.contrib import admin
+from django.forms import ModelForm
+from django_toggle_switch_widget.widgets import DjangoToggleSwitchWidget
+from .models import TestModel
+
+class TestModelForm(ModelForm):
+ class Meta:
+ model = TestModel
+ fields = "__all__"
+ widgets = {
+ "published": DjangoToggleSwitchWidget(klass="django-toggle-switch-dark-primary"),
+ "is_demo": DjangoToggleSwitchWidget(round=True, klass="django-toggle-switch-success"),
+ }
+
+class TestModeldmin(admin.ModelAdmin):
+ form = TestModelForm
+
+admin.site.register(TestModel, TestModeldmin)
+
+```
+
+## Tips
+
+- It's better to use together with django-checkbox-normalize app.
+
+## Release
+
+### v0.1.1 2020/09/09
+
+- Add License.
+
+### v0.1.0 2020/03/02
+
+- First release.
+
+%package help
+Summary: Development documents and examples for django-toggle-switch-widget
+Provides: python3-django-toggle-switch-widget-doc
+%description help
+# django-toggle-switch-widget
+
+Display toggle switch in stead of checkbox for BooleanField in django admin site.
+
+## Install
+
+```shell
+pip install django-toggle-switch-widget
+```
+
+## Widget init parameters
+
+- attrs: Inherit from CheckboxInput.
+- check_test: Inherit from CheckboxInput.
+- round: Default to False. If round=True, display round switch. If round=False, display squire switch.
+- klass: Default to empty string "". Pre-setted klass are:
+ - django-toggle-switch-success: Show success color (green, #06ad3d) while toggle on.
+ - django-toggle-switch-warning: Show warning color (orange, #ff6a00) while toggle on.
+ - django-toggle-switch-danger: Show danger color (red, #ba2121) while toggle on.
+ - django-toggle-switch-dark-primary: Show dark primary color (darkcyan, #417690) while toggle on.
+ - django-toggle-switch-primary: Show primary color (cadetblue, #79aec8) while toggle on.
+
+## Usage
+
+**pro/settings.py**
+
+```python
+INSTALLED_APPS = [
+ ...
+ 'django_toggle_switch_widget',
+ ...
+]
+```
+
+**app/model.py**
+
+```python
+from django.db import models
+
+class TestModel(models.Model):
+ title = models.CharField(max_length=64, help_text="Please input model title.")
+ published = models.BooleanField(verbose_name="Is this test model published.")
+ is_demo = models.BooleanField(help_text="Is this a demo test model?")
+
+```
+
+**app/admin.py**
+
+```python
+from django.contrib import admin
+from django.forms import ModelForm
+from django_toggle_switch_widget.widgets import DjangoToggleSwitchWidget
+from .models import TestModel
+
+class TestModelForm(ModelForm):
+ class Meta:
+ model = TestModel
+ fields = "__all__"
+ widgets = {
+ "published": DjangoToggleSwitchWidget(klass="django-toggle-switch-dark-primary"),
+ "is_demo": DjangoToggleSwitchWidget(round=True, klass="django-toggle-switch-success"),
+ }
+
+class TestModeldmin(admin.ModelAdmin):
+ form = TestModelForm
+
+admin.site.register(TestModel, TestModeldmin)
+
+```
+
+## Tips
+
+- It's better to use together with django-checkbox-normalize app.
+
+## Release
+
+### v0.1.1 2020/09/09
+
+- Add License.
+
+### v0.1.0 2020/03/02
+
+- First release.
+
+%prep
+%autosetup -n django-toggle-switch-widget-0.1.1
+
+%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-toggle-switch-widget -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..ac22c61
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+099218b20db72214a7065437787aef4b django-toggle-switch-widget-0.1.1.tar.gz