From 220e9d8b414fbe6a01a053c71100d451e978d373 Mon Sep 17 00:00:00 2001 From: Thu Trang Pham Date: Sat, 31 Oct 2020 14:24:45 -0700 Subject: [PATCH] inital commit --- .gitignore | 31 +++++ LICENSE.txt | 13 ++ README.md | 0 docs/Makefile | 20 +++ docs/conf.py | 52 ++++++++ docs/index.rst | 20 +++ docs/make.bat | 35 +++++ requirements.txt | 3 + tests/db.sqlite3 | Bin 0 -> 155648 bytes tests/manage.py | 21 +++ tests/market/__init__.py | 0 tests/market/admin.py | 23 ++++ tests/market/apps.py | 5 + tests/market/migrations/0001_initial.py | 32 +++++ .../migrations/0002_auto_20201031_2057.py | 44 +++++++ tests/market/migrations/__init__.py | 0 tests/market/models.py | 31 +++++ tests/market/tests.py | 3 + tests/market/views.py | 3 + tests/testproject/__init__.py | 0 tests/testproject/asgi.py | 16 +++ tests/testproject/settings.py | 124 ++++++++++++++++++ tests/testproject/urls.py | 21 +++ tests/testproject/wsgi.py | 16 +++ 24 files changed, 513 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat create mode 100644 requirements.txt create mode 100644 tests/db.sqlite3 create mode 100755 tests/manage.py create mode 100644 tests/market/__init__.py create mode 100644 tests/market/admin.py create mode 100644 tests/market/apps.py create mode 100644 tests/market/migrations/0001_initial.py create mode 100644 tests/market/migrations/0002_auto_20201031_2057.py create mode 100644 tests/market/migrations/__init__.py create mode 100644 tests/market/models.py create mode 100644 tests/market/tests.py create mode 100644 tests/market/views.py create mode 100644 tests/testproject/__init__.py create mode 100644 tests/testproject/asgi.py create mode 100644 tests/testproject/settings.py create mode 100644 tests/testproject/urls.py create mode 100644 tests/testproject/wsgi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bedd6a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +__pycache__/ +*.py[cod] + +build/ +dist/ +sdist/ +.eggs/ +*.egg-info/ + + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +*.db + +# Sphinx documentation +docs/_build/ + +# pycharm +.idea/ \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..81efbf0 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,13 @@ + Copyright [2020] [Thu Trang Pham] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# 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) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..bbe7723 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,52 @@ +# 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'] \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..2009be8 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. 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` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..2119f51 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@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 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bc8afd4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Django>=2.2.0 +Sphinx~=3.2.1 +sphinx-rtd-theme==0.1.8 diff --git a/tests/db.sqlite3 b/tests/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..97bfceb323f42e46b5b342f5bcc80df6e94d9c21 GIT binary patch literal 155648 zcmeI5Uu+x6eaE>XDTHG;K>naW zdO(u`otfR`E|-+7-udo)&X#XsQ{^GAi8hVWP?3ZABzu()lu5*cqml>0vGMljeYd>?Og8&GC00@8p2!H?x zfB*=900@8p2t0fO1E+)3X42#o}3IyI#r0WAT_6 zlSKMPPO-?87@LyBNIZ64PM?>gb0SNZ#iO+Jm{nTLYGtjiDaGa@3GsX)c`lX_<#=2= z;&ly<&D7LdO{y{!{jN@miR zLe$B1!$~Y-IN7dIPer9xKa`_{EG5z}1gWEIrlYjo5%YE!L6V$Fr(W)%eqJ^Gqzpeh zN>QVHD%Dz6DHO75wOXlWOBA@WrqmqGkh$%6Xem+25yllFV?e*e-ij_63oGot`9Ua7IDN#;{@#p;1huPM#gxyDj zO=YXzz9O-t7*Aj5q8`k)j!AY8YDv+G4`}ODCP6#hi$3aP*{lj37QDk)eeE!fok~mT zWctNUuWRhmj2$B%XjQdT*=gX-GQQktJG`k>QqIKZyk1wB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tfu&Q%dj3|NMW~r zv+vRy=5zKNrn6Y%QhB+c7IISDX)xM+S8`^zlz*@~D(Tq+B^lbYxp*usrV_IAnr9v$ z$yt7XNexQa|9?-$5-tJ)AOHd&00JNY0w4eaAOHd&00QqT0nGp3SNym*2!H?xfB*=9 z00@8p2!H?xfB*=*Cj>D6e@`&uA|L<)AOHd&00JNY0w4eaAOHd&@V*jY^ZyP)p8@a_ z^3(TK2rdo+AOHd&00JNY0w4eaAOHd&00JQJa0z(bg5c}$xCMWgKL3BqMSe!!dbk&X zHxK{;5C8!X009sH0T2KI5C8!X0Dwcv>*&PUcH}I!{&jjuUZcvAKfdB}A00@8p z2!H?xJXQowO?X|x(0E`+Q}6IcVO>zl5f+KCXK_WwY3}G`fIb{jr4L1BNi1KF>K12p zi~PD$Ub8IpD7QE`0p%LBIP}E3gwuY=m+L>W$J3j4a+8T+>kO^!goQhDZq46$VCH)?531nZ&hiLBT zWS6PU$Tt|V2XsYF>lUUW!@?9pqbCNb#o$;M*I{IH3H1HxQ#5Zl>eE|@%_SO_ud&$3 zNt!=4`9yr$t)5fG`OqozC z<&4Mc@{fyLEPXCEeFkWCw;`1#M0m=Cn_5lMM-lQHrrpkvX<2q~OGBjH(vaA&91*DH z*fbMpH)HY|Hu(F0kJZOADgy!_00JNY0w4eaAOHd&00JNY0&NMf`M*H^!$p7a0s#;J z0T2KI5C8!X009sH0T2KI5ct3n7)I_t8 literal 0 HcmV?d00001 diff --git a/tests/manage.py b/tests/manage.py new file mode 100755 index 0000000..fb52456 --- /dev/null +++ b/tests/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/tests/market/__init__.py b/tests/market/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/market/admin.py b/tests/market/admin.py new file mode 100644 index 0000000..ec59149 --- /dev/null +++ b/tests/market/admin.py @@ -0,0 +1,23 @@ +from django.contrib import admin + +from admin_confirm.admin import AdminConfirmMixin + +from .models import Item, Inventory, Shop + + +class ItemAdmin(AdminConfirmMixin, admin.ModelAdmin): + list_display = ('name', 'price', 'currency') + change_needs_confirmation = True + + +class InventoryAdmin(admin.ModelAdmin): + list_display = ('shop', 'item', 'quantity') + + +class ShopAdmin(admin.ModelAdmin): + pass + + +admin.site.register(Item, ItemAdmin) +admin.site.register(Inventory, InventoryAdmin) +admin.site.register(Shop, ShopAdmin) \ No newline at end of file diff --git a/tests/market/apps.py b/tests/market/apps.py new file mode 100644 index 0000000..f9a1da8 --- /dev/null +++ b/tests/market/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class MarketConfig(AppConfig): + name = 'market' diff --git a/tests/market/migrations/0001_initial.py b/tests/market/migrations/0001_initial.py new file mode 100644 index 0000000..943fbbf --- /dev/null +++ b/tests/market/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 3.0.10 on 2020-10-31 20:41 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Item', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=120)), + ('price', models.DecimalField(decimal_places=2, max_digits=5)), + ('currency', models.CharField(choices=[('CAD', 'CAD'), ('USD', 'USD')], max_length=3)), + ], + ), + migrations.CreateModel( + name='Stock', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.PositiveIntegerField()), + ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='all_stock', to='market.Item')), + ], + ), + ] diff --git a/tests/market/migrations/0002_auto_20201031_2057.py b/tests/market/migrations/0002_auto_20201031_2057.py new file mode 100644 index 0000000..184e6bd --- /dev/null +++ b/tests/market/migrations/0002_auto_20201031_2057.py @@ -0,0 +1,44 @@ +# Generated by Django 3.0.10 on 2020-10-31 20:57 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('market', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Inventory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('quantity', models.PositiveIntegerField()), + ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='market.Item')), + ], + options={ + 'ordering': ['shop', 'item__name'], + }, + ), + migrations.CreateModel( + name='Shop', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=120)), + ], + ), + migrations.DeleteModel( + name='Stock', + ), + migrations.AddField( + model_name='inventory', + name='shop', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inventory', to='market.Shop'), + ), + migrations.AlterUniqueTogether( + name='inventory', + unique_together={('shop', 'item')}, + ), + ] diff --git a/tests/market/migrations/__init__.py b/tests/market/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/market/models.py b/tests/market/models.py new file mode 100644 index 0000000..5010888 --- /dev/null +++ b/tests/market/models.py @@ -0,0 +1,31 @@ +from django.db import models + + +class Item(models.Model): + VALID_CURRENCIES = ( + ('CAD', 'CAD'), + ('USD', 'USD'), + ) + name = models.CharField(max_length=120) + price = models.DecimalField(max_digits=5, decimal_places=2) + currency = models.CharField(max_length=3, choices=VALID_CURRENCIES) + + def __str__(self): + return self.name + + +class Shop(models.Model): + name = models.CharField(max_length=120) + + def __str__(self): + return self.name + + +class Inventory(models.Model): + class Meta: + unique_together = ['shop', 'item'] + ordering = ['shop', 'item__name'] + + shop = models.ForeignKey(to=Shop, on_delete=models.CASCADE, related_name='inventory') + item = models.ForeignKey(to=Item, on_delete=models.CASCADE) + quantity = models.PositiveIntegerField() diff --git a/tests/market/tests.py b/tests/market/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/tests/market/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/tests/market/views.py b/tests/market/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/tests/market/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/tests/testproject/__init__.py b/tests/testproject/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/testproject/asgi.py b/tests/testproject/asgi.py new file mode 100644 index 0000000..6c853f1 --- /dev/null +++ b/tests/testproject/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for testproject project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings') + +application = get_asgi_application() diff --git a/tests/testproject/settings.py b/tests/testproject/settings.py new file mode 100644 index 0000000..2c3d3aa --- /dev/null +++ b/tests/testproject/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for testproject project. + +Generated by 'django-admin startproject' using Django 3.0.10. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '=yddl-40388w3e2hl$e8)revce=n67_idi8pfejtn3!+2%!_qt' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['127.0.0.1'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'admin_confirm', + + 'tests.market', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'tests.testproject.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'tests.testproject.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.0/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/tests/testproject/urls.py b/tests/testproject/urls.py new file mode 100644 index 0000000..7843628 --- /dev/null +++ b/tests/testproject/urls.py @@ -0,0 +1,21 @@ +"""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 + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/tests/testproject/wsgi.py b/tests/testproject/wsgi.py new file mode 100644 index 0000000..da80dde --- /dev/null +++ b/tests/testproject/wsgi.py @@ -0,0 +1,16 @@ +""" +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 + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings') + +application = get_wsgi_application()