diff --git a/Makefile b/Makefile index 93d9b6a..fb6b564 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,16 @@ package: python3 setup.py sdist bdist_wheel upload-testpypi: - python3 -m twine upload --repository testpypi dist/django_admin_confirm-$(VERSION) + python3 -m twine upload --repository testpypi dist/django_admin_confirm-$(VERSION)* i-have-tested-with-testpypi-and-am-ready-to-release: - python3 -m twine upload --repository pypi dist/django_admin_confirm-$(VERSION) + python3 -m twine upload --repository pypi dist/django_admin_confirm-$(VERSION)* install-testpypi: pip uninstall django_admin_confirm python -m pip install --index-url https://test.pypi.org/simple/ django_admin_confirm==${VERSION} + +testpypi: + python3 -m twine upload --repository testpypi dist/django_admin_confirm-$(VERSION)* + pip uninstall django_admin_confirm + python -m pip install --index-url https://test.pypi.org/simple/ django_admin_confirm==${VERSION} diff --git a/admin_confirm/admin.py b/admin_confirm/admin.py index 84aa74a..6c8ee56 100644 --- a/admin_confirm/admin.py +++ b/admin_confirm/admin.py @@ -137,26 +137,9 @@ class AdminConfirmMixin: return changed_data - def _get_form_data(self, request): - """ - Parses the request post params into a format that can be used for the hidden form on the - change confirmation page. - """ - form_data = request.POST.copy() - - for key in SAVE_ACTIONS + [ - "_confirm_change", - "_confirm_add", - "csrfmiddlewaretoken", - ]: - if form_data.get(key): - form_data.pop(key) - - form_data = [(k, list(v)) for k, v in form_data.lists()] - return form_data - def _change_confirmation_view(self, request, object_id, form_url, extra_context): # This code is taken from super()._changeform_view + # https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1575-L1592 to_field = request.POST.get(TO_FIELD_VAR, request.GET.get(TO_FIELD_VAR)) if to_field and not self.to_field_allowed(request, to_field): raise DisallowedModelAdminToField( @@ -186,8 +169,12 @@ class AdminConfirmMixin: ) form = ModelForm(request.POST, request.FILES, obj) + # Note to self: For inline instances see: + # https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1582 + # End code from super()._changeform_view + # Get changed data to show on confirmation changed_data = self._get_changed_data(form, model, obj, add) changed_confirmation_fields = set( @@ -197,8 +184,6 @@ class AdminConfirmMixin: # No confirmation required for changed fields, continue to save return super()._changeform_view(request, object_id, form_url, extra_context) - # Parse raw form data from POST - form_data = self._get_form_data(request) # Parse the original save action from request save_action = None for key in request.POST.keys(): @@ -218,10 +203,10 @@ class AdminConfirmMixin: "app_label": opts.app_label, "model_name": opts.model_name, "opts": opts, - "form_data": form_data, "changed_data": changed_data, "add": add, "submit_name": save_action, + "form": form, **(extra_context or {}), } return self.render_change_confirmation(request, context) diff --git a/admin_confirm/static/admin/css/confirmation.css b/admin_confirm/static/admin/css/confirmation.css index 244f6fa..2169466 100644 --- a/admin_confirm/static/admin/css/confirmation.css +++ b/admin_confirm/static/admin/css/confirmation.css @@ -1,24 +1,28 @@ .submit-row a.cancel-link { - display: block; - background: #ba2121; - border-radius: 4px; - padding: 10px 15px; - height: 15px; - line-height: 15px; - color: #fff; + display: block; + background: #ba2121; + border-radius: 4px; + padding: 10px 15px; + height: 15px; + line-height: 15px; + color: #fff; } .submit-row a.cancel-link:focus, .submit-row a.cancel-link:hover, .submit-row a.cancel-link:active { - background: #a41515; + background: #a41515; } .changed-data table { - width: 100%; + width: 100%; } .changed-data th, .changed-data td { - width: 30%; - white-space: nowrap; -} \ No newline at end of file + width: 30%; + white-space: nowrap; +} + +.hidden { + display: none; +} diff --git a/admin_confirm/templates/admin/change_confirmation.html b/admin_confirm/templates/admin/change_confirmation.html index dc2adee..6f123f3 100644 --- a/admin_confirm/templates/admin/change_confirmation.html +++ b/admin_confirm/templates/admin/change_confirmation.html @@ -42,12 +42,9 @@ {% include "admin/change_data.html" %}