From ca1019765b0c307c831f04c247436f8511baff5c Mon Sep 17 00:00:00 2001 From: Thu Trang Pham Date: Sun, 1 Nov 2020 21:11:33 -0800 Subject: [PATCH] Updating readme --- README.md | 68 +++++++++++++++++++++++++++++++++++++++ README.rst | 0 admin_confirm/__init__.py | 1 + admin_confirm/admin.py | 4 --- requirements.txt | 4 +-- setup.py | 4 +-- 6 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..074e8be --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +Django Admin Confirm +======== + +AdminConfirmMixin is a mixin for ModelAdmin to add confirmations to changes and additions. + +It can be configured to add a confirmation page upon saving changes and/or additions on ModelAdmin. + +Typical Usage: + + from admin_confirm.admin import AdminConfirmMixin + + class MyModelAdmin(AdminConfirmMixin, ModelAdmin): + confirm_change = True + confirmation_fields = ['field1', 'field2'] + + +Installation +------------ + +Install django-admin-confirm by running: + + pip install django-admin-confirm + +Add to INSTALLED_APPS in your project settings before `django.contrib.admin`: + + INSTALLED_APPS = [ + ... + 'admin_confirm', + + 'django.contrib.admin', + ... + ] + +Note that this project follows the template override rules of Django. +To override a template, your app should be listed before `admin_confirm` in INSTALLED_APPS. + + +Configuration Options +-------- +- `confirm_change` Optional[bool] - decides if changes should trigger confirmation +- `confirm_add` Optional[bool] - decides if additions should trigger confirmation +- `confirmation_fields` Optional[Array[string]] - sets which fields changes/additions should trigger confirmation +- `change_confirmation_template` Optional[string] - path to custom html template to use + +Note that setting `confirmation_fields` without setting `confirm_change` or `confirm_add` would not trigger confirmation. + +Contribution & Appreciation +---------- + +Contributions are most welcome :) Feel free to: +- address an issue +- raise an issue +- add more test cases +- add feature requests + +Your appreciation is also very welcome :) Feel free to: +- star the project +- open an issue just to share your thanks + +Support +------- + +If you are having issues, please let us know through raising an issue. + +License +------- + +The project is licensed under the Apache 2.0 license. \ No newline at end of file diff --git a/README.rst b/README.rst deleted file mode 100644 index e69de29..0000000 diff --git a/admin_confirm/__init__.py b/admin_confirm/__init__.py index e69de29..8b13789 100644 --- a/admin_confirm/__init__.py +++ b/admin_confirm/__init__.py @@ -0,0 +1 @@ + diff --git a/admin_confirm/admin.py b/admin_confirm/admin.py index 7166e91..59483d8 100644 --- a/admin_confirm/admin.py +++ b/admin_confirm/admin.py @@ -1,4 +1,3 @@ - from django.contrib.admin.exceptions import DisallowedModelAdminToField from django.contrib.admin.utils import flatten_fieldsets, unquote from django.core.exceptions import PermissionDenied @@ -6,10 +5,7 @@ from django.template.response import TemplateResponse from django.contrib.admin.options import TO_FIELD_VAR from django.utils.translation import gettext as _ - class AdminConfirmMixin(object): - """Generic AdminConfirm Mixin""" - # Should we ask for confirmation for changes? confirm_change = None diff --git a/requirements.txt b/requirements.txt index bc8afd4..ddd637a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ -Django>=2.2.0 -Sphinx~=3.2.1 -sphinx-rtd-theme==0.1.8 +Django>=1.7.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 2d89a69..284f506 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,13 @@ import os from setuptools import setup here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.rst')).read() +README = open(os.path.join(here, 'README.md')).read() setup( name='django-admin-confirm', version='0.1', packages=['admin_confirm'], - description='Adds confirmation to Django Admin change', + description='Adds confirmation to Django Admin changes and additions', long_description=README, author='Thu Trang Pham', author_email='thuutrangpham@gmail.com',