Cleaning up

main
Thu Trang Pham 2020-10-31 18:07:01 -07:00
parent 48c8e9bd10
commit 9d007df017
11 changed files with 6 additions and 185 deletions

View File

@ -1,10 +1,10 @@
from django.contrib.admin.exceptions import DisallowedModelAdminToField
from django.contrib.admin.utils import flatten_fieldsets, quote, unquote
from django.contrib.admin.utils import flatten_fieldsets, unquote
from django.core.exceptions import PermissionDenied
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.contrib.admin.options import TO_FIELD_VAR, IS_POPUP_VAR
from django.utils.translation import gettext as _, ngettext
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):
@ -38,9 +38,8 @@ class AdminConfirmMixin(object):
)
def change_view(self, request, object_id=None, form_url="", extra_context=None):
self.message_user(request, f"{request.POST}")
# self.message_user(request, f"{request.POST}")
if request.method == "POST" and request.POST.get("_change_needs_confirmation"):
self.message_user(request, "Needs confirmation was inside the request")
return self._change_confirmation_view(
request, object_id, form_url, extra_context
)
@ -80,7 +79,6 @@ class AdminConfirmMixin(object):
)
# Should we be validating the data here? Or just pass it to super?
form = ModelForm(request.POST, request.FILES, obj)
form_validated = form.is_valid()
if form_validated:
@ -88,7 +86,6 @@ class AdminConfirmMixin(object):
else:
new_object = form.instance
# End code copied from Django sourcecode
if add:
title = _("Add %s")
elif self.has_change_permission(request, obj):
@ -101,13 +98,13 @@ class AdminConfirmMixin(object):
save_action = action
break
# Parse raw form data from POST
form_data = {}
for key in request.POST:
if key.startswith("_") or key == 'csrfmiddlewaretoken':
continue
form_data[key] = request.POST.get(key)
# { k: v for k, v in request.POST.\\ if not(k.startswith('_') or k == 'csrfmiddlewaretoken')}
context = {
**self.admin_site.each_context(request),

View File

@ -1,18 +0,0 @@
# import json
#
# from django import template
# from django.template.context import Context
#
# from django.contrib.admin.templatetags import admin_modify
#
# from django.contrib.admin.templatetags.base import InclusionAdminNode
#
# register = template.Library()
#
# def submit_row(context):
# ctx = admin_modify.submit_row(context)
#
#
# @register.tag(name='submit_row')
# def submit_row_tag(parser, token):
# return InclusionAdminNode(parser, token, func=submit_row, template_name='submit_line.html')

View File

@ -26,7 +26,6 @@
{% for key, value in form_data.items %}
<input type="hidden" name="{{ key }}" value="{{ value }}">
{% endfor %}
{# <input type="hidden" name="post" value="yes">#}
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1">{% endif %}
{% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}">{% endif %}
<input type="submit" value="{% trans 'Yes, Im sure' %}" name="{{ submit_name }}">

View File

@ -1,20 +0,0 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -1,52 +0,0 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'Django Admin Confirm'
copyright = '2020, Thu Trang Pham'
author = 'Thu Trang Pham'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

View File

@ -1,20 +0,0 @@
.. Django Admin Confirm documentation master file, created by
sphinx-quickstart on Sat Oct 31 14:11:56 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Django Admin Confirm's documentation!
================================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -1,35 +0,0 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@ -1,18 +1,3 @@
"""testproject URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

View File

@ -1,12 +1,3 @@
"""
WSGI config for testproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application