From 0a53bf46900390040f3007c4b72ee2431669e496 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:21:29 -0400 Subject: [PATCH 01/31] build(dotenv): install dependency --- poetry.lock | 16 +++++++++++++++- pyproject.toml | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 6371dd9..d6dad4e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -875,6 +875,20 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-dotenv" +version = "1.0.0" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.8" +files = [ + {file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"}, + {file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "pytz" version = "2023.3" @@ -1272,4 +1286,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "e502c53387c258268d126e574213c0baaa604a6e1a3eb2b0c457a899f89690df" +content-hash = "8b055a19044811108ba8bd73da7987899584d716e21ee201414cf082eafffb76" diff --git a/pyproject.toml b/pyproject.toml index c38146d..a01ea68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ python = "^3.11" [tool.poetry.group.dev.dependencies] commitizen = "^3.6.0" +python-dotenv = "^1.0.0" [tool.poetry.group.test.dependencies] From 2f21ae44337b380186f3588a247520c08d739877 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:22:34 -0400 Subject: [PATCH 02/31] build(django): install dependency --- poetry.lock | 52 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index d6dad4e..4e94fb3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -25,6 +25,20 @@ files = [ [package.extras] test = ["coverage", "mypy", "pexpect", "ruff", "wheel"] +[[package]] +name = "asgiref" +version = "3.7.2" +description = "ASGI specs, helper code, and adapters" +optional = false +python-versions = ">=3.7" +files = [ + {file = "asgiref-3.7.2-py3-none-any.whl", hash = "sha256:89b2ef2247e3b562a16eef663bc0e2e703ec6468e2fa8a5cd61cd449786d4f6e"}, + {file = "asgiref-3.7.2.tar.gz", hash = "sha256:9e0ce3aa93a819ba5b45120216b23878cf6e8525eb3848653452b4192b92afed"}, +] + +[package.extras] +tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] + [[package]] name = "babel" version = "2.12.1" @@ -344,6 +358,26 @@ files = [ {file = "distlib-0.3.7.tar.gz", hash = "sha256:9dafe54b34a028eafd95039d5e5d4851a13734540f1331060d31c9916e7147a8"}, ] +[[package]] +name = "django" +version = "4.2.4" +description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." +optional = false +python-versions = ">=3.8" +files = [ + {file = "Django-4.2.4-py3-none-any.whl", hash = "sha256:860ae6a138a238fc4f22c99b52f3ead982bb4b1aad8c0122bcd8c8a3a02e409d"}, + {file = "Django-4.2.4.tar.gz", hash = "sha256:7e4225ec065e0f354ccf7349a22d209de09cc1c074832be9eb84c51c1799c432"}, +] + +[package.dependencies] +asgiref = ">=3.6.0,<4" +sqlparse = ">=0.3.1" +tzdata = {version = "*", markers = "sys_platform == \"win32\""} + +[package.extras] +argon2 = ["argon2-cffi (>=19.1.0)"] +bcrypt = ["bcrypt"] + [[package]] name = "docopt" version = "0.6.2" @@ -1173,6 +1207,22 @@ Sphinx = ">=5" lint = ["docutils-stubs", "flake8", "mypy"] test = ["pytest"] +[[package]] +name = "sqlparse" +version = "0.4.4" +description = "A non-validating SQL parser." +optional = false +python-versions = ">=3.5" +files = [ + {file = "sqlparse-0.4.4-py3-none-any.whl", hash = "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3"}, + {file = "sqlparse-0.4.4.tar.gz", hash = "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c"}, +] + +[package.extras] +dev = ["build", "flake8"] +doc = ["sphinx"] +test = ["pytest", "pytest-cov"] + [[package]] name = "termcolor" version = "2.3.0" @@ -1286,4 +1336,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "8b055a19044811108ba8bd73da7987899584d716e21ee201414cf082eafffb76" +content-hash = "125754972095f308d8c5f3bcd781bca5c297fcdbf8fef4c179220e1a8a27ba79" diff --git a/pyproject.toml b/pyproject.toml index a01ea68..0e20ec3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ directory = 'coverage' [tool.poetry.dependencies] python = "^3.11" +django = "^4.2.4" [tool.poetry.group.dev.dependencies] From 1be2152205a1dc71909e86dc8b0c178f6e16f56a Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:29:41 -0400 Subject: [PATCH 03/31] build(django): initiate django project --- src/pydjango/manage.py | 22 ++++++ src/pydjango/pydjango/__init__.py | 0 src/pydjango/pydjango/asgi.py | 16 ++++ src/pydjango/pydjango/settings.py | 123 ++++++++++++++++++++++++++++++ src/pydjango/pydjango/urls.py | 22 ++++++ src/pydjango/pydjango/wsgi.py | 16 ++++ 6 files changed, 199 insertions(+) create mode 100644 src/pydjango/manage.py create mode 100644 src/pydjango/pydjango/__init__.py create mode 100644 src/pydjango/pydjango/asgi.py create mode 100644 src/pydjango/pydjango/settings.py create mode 100644 src/pydjango/pydjango/urls.py create mode 100644 src/pydjango/pydjango/wsgi.py diff --git a/src/pydjango/manage.py b/src/pydjango/manage.py new file mode 100644 index 0000000..5e19173 --- /dev/null +++ b/src/pydjango/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydjango.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/src/pydjango/pydjango/__init__.py b/src/pydjango/pydjango/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/pydjango/pydjango/asgi.py b/src/pydjango/pydjango/asgi.py new file mode 100644 index 0000000..0833579 --- /dev/null +++ b/src/pydjango/pydjango/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for pydjango 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/4.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydjango.settings") + +application = get_asgi_application() diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py new file mode 100644 index 0000000..61c31e2 --- /dev/null +++ b/src/pydjango/pydjango/settings.py @@ -0,0 +1,123 @@ +""" +Django settings for pydjango project. + +Generated by 'django-admin startproject' using Django 4.2.4. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-n-g&cz+%pmnklxel0l)l@6vhz13#91gmj^ml!6h)-+i$3ap#9j" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", +] + +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 = "pydjango.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 = "pydjango.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/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/4.2/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = "static/" + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/src/pydjango/pydjango/urls.py b/src/pydjango/pydjango/urls.py new file mode 100644 index 0000000..fa84fe7 --- /dev/null +++ b/src/pydjango/pydjango/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for pydjango project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.2/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/src/pydjango/pydjango/wsgi.py b/src/pydjango/pydjango/wsgi.py new file mode 100644 index 0000000..8cda617 --- /dev/null +++ b/src/pydjango/pydjango/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for pydjango 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/4.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydjango.settings") + +application = get_wsgi_application() From e64715c2067c1333d5ed673ba761f930607c363a Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:42:20 -0400 Subject: [PATCH 04/31] build(django): start app pymysql --- src/pydjango/pymysql/__init__.py | 0 src/pydjango/pymysql/admin.py | 3 +++ src/pydjango/pymysql/apps.py | 6 ++++++ src/pydjango/pymysql/migrations/__init__.py | 0 src/pydjango/pymysql/models.py | 3 +++ src/pydjango/pymysql/tests.py | 3 +++ src/pydjango/pymysql/views.py | 3 +++ 7 files changed, 18 insertions(+) create mode 100644 src/pydjango/pymysql/__init__.py create mode 100644 src/pydjango/pymysql/admin.py create mode 100644 src/pydjango/pymysql/apps.py create mode 100644 src/pydjango/pymysql/migrations/__init__.py create mode 100644 src/pydjango/pymysql/models.py create mode 100644 src/pydjango/pymysql/tests.py create mode 100644 src/pydjango/pymysql/views.py diff --git a/src/pydjango/pymysql/__init__.py b/src/pydjango/pymysql/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/pydjango/pymysql/admin.py b/src/pydjango/pymysql/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/src/pydjango/pymysql/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/src/pydjango/pymysql/apps.py b/src/pydjango/pymysql/apps.py new file mode 100644 index 0000000..95365d4 --- /dev/null +++ b/src/pydjango/pymysql/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class PymysqlConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "pymysql" diff --git a/src/pydjango/pymysql/migrations/__init__.py b/src/pydjango/pymysql/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/pydjango/pymysql/models.py b/src/pydjango/pymysql/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/src/pydjango/pymysql/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/src/pydjango/pymysql/tests.py b/src/pydjango/pymysql/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/src/pydjango/pymysql/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/src/pydjango/pymysql/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From b2ced0c3b49383a1632190ab3548ca247f95b906 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:47:11 -0400 Subject: [PATCH 05/31] build(django): create index view with url --- src/pydjango/pydjango/urls.py | 3 ++- src/pydjango/pymysql/urls.py | 7 +++++++ src/pydjango/pymysql/views.py | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/pydjango/pymysql/urls.py diff --git a/src/pydjango/pydjango/urls.py b/src/pydjango/pydjango/urls.py index fa84fe7..fe5d3dc 100644 --- a/src/pydjango/pydjango/urls.py +++ b/src/pydjango/pydjango/urls.py @@ -15,8 +15,9 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ + path("pymysql", include("pymysql.urls")), path("admin/", admin.site.urls), ] diff --git a/src/pydjango/pymysql/urls.py b/src/pydjango/pymysql/urls.py new file mode 100644 index 0000000..70df554 --- /dev/null +++ b/src/pydjango/pymysql/urls.py @@ -0,0 +1,7 @@ +"""Urls.""" + +from django.urls import path + +from . import views + +urlpatterns = [path("", views.index, name="index")] diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index 91ea44a..c8e1119 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -1,3 +1,8 @@ from django.shortcuts import render +from django.http import HttpResponse + # Create your views here. +def index(request): + """views index""" + return HttpResponse("Hello Django!") From 9f58299321ecbe5f8e575e4146f0fa3f86c773d6 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:56:51 -0400 Subject: [PATCH 06/31] build(django): update settings for database --- src/pydjango/pydjango/settings.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 61c31e2..7408677 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -11,6 +11,10 @@ """ from pathlib import Path +from os import environ +from dotenv import find_dotenv, load_dotenv + +load_dotenv(find_dotenv()) # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -75,8 +79,12 @@ DATABASES = { "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", + "ENGINE": "django.db.backends.mysql", + "USER": environ.get("DATABASE_USER"), + "PASSWORD": environ.get("DATABASE_PASSWORD"), + "NAME": environ.get("DATABASE_NAME"), + "HOST": environ.get("DATABASE_HOST"), + "PORT": environ.get("DATABASE_PORT"), } } @@ -105,7 +113,7 @@ LANGUAGE_CODE = "en-us" -TIME_ZONE = "UTC" +TIME_ZONE = "GMT-4" USE_I18N = True From 9fd536311b50c77a7713a1bf1658836aadfc25db Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 15:57:52 -0400 Subject: [PATCH 07/31] build(mysqlclient): install dependency --- poetry.lock | 18 +++++++++++++++++- pyproject.toml | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 4e94fb3..247f1bb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -637,6 +637,22 @@ dns-srv = ["dnspython (>=1.16.0,<=2.3.0)"] gssapi = ["gssapi (>=1.6.9,<=1.8.2)"] opentelemetry = ["Deprecated (>=1.2.6)", "typing-extensions (>=3.7.4)", "zipp (>=0.5)"] +[[package]] +name = "mysqlclient" +version = "2.2.0" +description = "Python interface to MySQL" +optional = false +python-versions = ">=3.8" +files = [ + {file = "mysqlclient-2.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:68837b6bb23170acffb43ae411e47533a560b6360c06dac39aa55700972c93b2"}, + {file = "mysqlclient-2.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:5670679ff1be1cc3fef0fa81bf39f0cd70605ba121141050f02743eb878ac114"}, + {file = "mysqlclient-2.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:004fe1d30d2c2ff8072f8ea513bcec235fd9b896f70dad369461d0ad7e570e98"}, + {file = "mysqlclient-2.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:9c6b142836c7dba4f723bf9c93cc46b6e5081d65b2af807f400dda9eb85a16d0"}, + {file = "mysqlclient-2.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:955dba905a7443ce4788c63fdb9f8d688316260cf60b20ff51ac3b1c77616ede"}, + {file = "mysqlclient-2.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:530ece9995a36cadb6211b9787f0c9e05cdab6702549bdb4236af5e9b535ed6a"}, + {file = "mysqlclient-2.2.0.tar.gz", hash = "sha256:04368445f9c487d8abb7a878e3d23e923e6072c04a6c320f9e0dc8a82efba14e"}, +] + [[package]] name = "nox" version = "2023.4.22" @@ -1336,4 +1352,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "125754972095f308d8c5f3bcd781bca5c297fcdbf8fef4c179220e1a8a27ba79" +content-hash = "9378e298223fc3e58c5faf3ab40e07f121634f55101dc2e483f522bba12e5c50" diff --git a/pyproject.toml b/pyproject.toml index 0e20ec3..bc594d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,5 +82,6 @@ mypy = "^1.5.1" [tool.poetry.group.mysql.dependencies] mysql-connector-python = "^8.1.0" +mysqlclient = "^2.2.0" From 27a130722c9985ed681faf6783cd12d913a9ca0f Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 16:26:53 -0400 Subject: [PATCH 08/31] build(django): create and migrate models --- src/pydjango/pydjango/settings.py | 1 + .../pymysql/migrations/0001_initial.py | 57 +++++++++++++++++++ src/pydjango/pymysql/models.py | 28 +++++++++ 3 files changed, 86 insertions(+) create mode 100644 src/pydjango/pymysql/migrations/0001_initial.py diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 7408677..4512285 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -35,6 +35,7 @@ # Application definition INSTALLED_APPS = [ + "pymysql.apps.PymysqlConfig", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", diff --git a/src/pydjango/pymysql/migrations/0001_initial.py b/src/pydjango/pymysql/migrations/0001_initial.py new file mode 100644 index 0000000..5509b2d --- /dev/null +++ b/src/pydjango/pymysql/migrations/0001_initial.py @@ -0,0 +1,57 @@ +# Generated by Django 4.2.4 on 2023-08-25 20:24 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="Employee", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("first_name", models.CharField(max_length=48)), + ("last_name", models.CharField(max_length=48)), + ("email", models.CharField(max_length=319)), + ("phone", models.CharField(max_length=20)), + ], + ), + migrations.CreateModel( + name="Task", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=50)), + ("description", models.TextField()), + ("date_start", models.DateTimeField()), + ("date_end", models.DateTimeField()), + ( + "employee", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="pymysql.employee", + ), + ), + ], + ), + ] diff --git a/src/pydjango/pymysql/models.py b/src/pydjango/pymysql/models.py index 71a8362..383d265 100644 --- a/src/pydjango/pymysql/models.py +++ b/src/pydjango/pymysql/models.py @@ -1,3 +1,31 @@ from django.db import models + # Create your models here. +class Employee(models.Model): + """Model Employee.""" + + first_name = models.CharField(max_length=48) + last_name = models.CharField(max_length=48) + email = models.CharField(max_length=319) + phone = models.CharField(max_length=20) + + def __str__(self: "Employee") -> str: + return f"{self.first_name} {self.last_name}" + + +class Task(models.Model): + """Model Task.""" + + employee = models.ForeignKey(Employee, null=True, on_delete=models.SET_NULL) + title = models.CharField(max_length=50) + description = models.TextField() + date_start = models.DateTimeField() + date_end = models.DateTimeField() + + def __str__(self: "Task") -> str: + return f"{self.title}" + + def is_assign(self: "Task") -> bool: + """Check if an employee is assigned to the task.""" + return self.employee is not None From f7095eceef5d0eb4481c54d3df0210213f6d6553 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 16:55:33 -0400 Subject: [PATCH 09/31] build(django): update timezone settings to america montreal --- src/pydjango/pydjango/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 4512285..8f7036d 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -114,7 +114,7 @@ LANGUAGE_CODE = "en-us" -TIME_ZONE = "GMT-4" +TIME_ZONE = "America/Montreal" USE_I18N = True From a33f695971a1d1e52b7bcc98b18ce85d4a33f0a2 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 17:02:43 -0400 Subject: [PATCH 10/31] build(django): register model for admin --- src/pydjango/pymysql/admin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pydjango/pymysql/admin.py b/src/pydjango/pymysql/admin.py index 8c38f3f..57bd7b1 100644 --- a/src/pydjango/pymysql/admin.py +++ b/src/pydjango/pymysql/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin +from .models import Employee, Task # Register your models here. +admin.site.register([Employee, Task]) From 43c11a89069e799fe964f5d178b168f86a554c01 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 17:42:58 -0400 Subject: [PATCH 11/31] build(django): test views with urls --- src/pydjango/pymysql/urls.py | 5 ++++- src/pydjango/pymysql/views.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pydjango/pymysql/urls.py b/src/pydjango/pymysql/urls.py index 70df554..9fe4c23 100644 --- a/src/pydjango/pymysql/urls.py +++ b/src/pydjango/pymysql/urls.py @@ -4,4 +4,7 @@ from . import views -urlpatterns = [path("", views.index, name="index")] +urlpatterns = [ + path("", views.index, name="index"), + path("/employee//", views.employee, name="employee"), +] diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index c8e1119..d83637d 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -1,8 +1,14 @@ from django.shortcuts import render from django.http import HttpResponse +from .models import Employee # Create your views here. def index(request): """views index""" return HttpResponse("Hello Django!") + + +def employee(request, id): + emp = Employee.objects().get(id=id) + return HttpResponse(f"Employee {id}: {emp}") From bb74124dee4d2d494ba71740c6f2867c8d91cd71 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 17:43:17 -0400 Subject: [PATCH 12/31] build(django): silence settings for urls with preceding slash --- src/pydjango/pydjango/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 8f7036d..659ac87 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -130,3 +130,7 @@ # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +# Custom + +SILENCED_SYSTEM_CHECKS = ["urls.W002"] From 5d58ca0902cf8a414c2e312c1b5cea4cf810a4cf Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 17:44:15 -0400 Subject: [PATCH 13/31] build(django): install lint for dhango --- poetry.lock | 245 ++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 245 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 247f1bb..e139539 100644 --- a/poetry.lock +++ b/poetry.lock @@ -39,6 +39,21 @@ files = [ [package.extras] tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] +[[package]] +name = "astroid" +version = "2.15.6" +description = "An abstract syntax tree for Python with inference support." +optional = false +python-versions = ">=3.7.2" +files = [ + {file = "astroid-2.15.6-py3-none-any.whl", hash = "sha256:389656ca57b6108f939cf5d2f9a2a825a3be50ba9d589670f393236e0a03b91c"}, + {file = "astroid-2.15.6.tar.gz", hash = "sha256:903f024859b7c7687d7a7f3a3f73b17301f8e42dfd9cc9df9d4418172d3e2dbd"}, +] + +[package.dependencies] +lazy-object-proxy = ">=1.4.0" +wrapt = {version = ">=1.14,<2", markers = "python_version >= \"3.11\""} + [[package]] name = "babel" version = "2.12.1" @@ -347,6 +362,20 @@ files = [ {file = "decli-0.6.1.tar.gz", hash = "sha256:ed88ccb947701e8e5509b7945fda56e150e2ac74a69f25d47ac85ef30ab0c0f0"}, ] +[[package]] +name = "dill" +version = "0.3.7" +description = "serialize all of Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "dill-0.3.7-py3-none-any.whl", hash = "sha256:76b122c08ef4ce2eedcd4d1abd8e641114bfc6c2867f49f3c41facf65bf19f5e"}, + {file = "dill-0.3.7.tar.gz", hash = "sha256:cc1c8b182eb3013e24bd475ff2e9295af86c1a38eb1aff128dac8962a9ce3c03"}, +] + +[package.extras] +graph = ["objgraph (>=1.7.2)"] + [[package]] name = "distlib" version = "0.3.7" @@ -466,6 +495,23 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] +[[package]] +name = "isort" +version = "5.12.0" +description = "A Python utility / library to sort Python imports." +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, + {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, +] + +[package.extras] +colors = ["colorama (>=0.4.3)"] +pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] +plugins = ["setuptools"] +requirements-deprecated-finder = ["pip-api", "pipreqs"] + [[package]] name = "jinja2" version = "3.1.2" @@ -483,6 +529,51 @@ MarkupSafe = ">=2.0" [package.extras] i18n = ["Babel (>=2.7)"] +[[package]] +name = "lazy-object-proxy" +version = "1.9.0" +description = "A fast and thorough lazy object proxy." +optional = false +python-versions = ">=3.7" +files = [ + {file = "lazy-object-proxy-1.9.0.tar.gz", hash = "sha256:659fb5809fa4629b8a1ac5106f669cfc7bef26fbb389dda53b3e010d1ac4ebae"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b40387277b0ed2d0602b8293b94d7257e17d1479e257b4de114ea11a8cb7f2d7"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8c6cfb338b133fbdbc5cfaa10fe3c6aeea827db80c978dbd13bc9dd8526b7d4"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:721532711daa7db0d8b779b0bb0318fa87af1c10d7fe5e52ef30f8eff254d0cd"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:66a3de4a3ec06cd8af3f61b8e1ec67614fbb7c995d02fa224813cb7afefee701"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:1aa3de4088c89a1b69f8ec0dcc169aa725b0ff017899ac568fe44ddc1396df46"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-win32.whl", hash = "sha256:f0705c376533ed2a9e5e97aacdbfe04cecd71e0aa84c7c0595d02ef93b6e4455"}, + {file = "lazy_object_proxy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea806fd4c37bf7e7ad82537b0757999264d5f70c45468447bb2b91afdbe73a6e"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:946d27deaff6cf8452ed0dba83ba38839a87f4f7a9732e8f9fd4107b21e6ff07"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79a31b086e7e68b24b99b23d57723ef7e2c6d81ed21007b6281ebcd1688acb0a"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f699ac1c768270c9e384e4cbd268d6e67aebcfae6cd623b4d7c3bfde5a35db59"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfb38f9ffb53b942f2b5954e0f610f1e721ccebe9cce9025a38c8ccf4a5183a4"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:189bbd5d41ae7a498397287c408617fe5c48633e7755287b21d741f7db2706a9"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-win32.whl", hash = "sha256:81fc4d08b062b535d95c9ea70dbe8a335c45c04029878e62d744bdced5141586"}, + {file = "lazy_object_proxy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:f2457189d8257dd41ae9b434ba33298aec198e30adf2dcdaaa3a28b9994f6adb"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:d9e25ef10a39e8afe59a5c348a4dbf29b4868ab76269f81ce1674494e2565a6e"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cbf9b082426036e19c6924a9ce90c740a9861e2bdc27a4834fd0a910742ac1e8"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f5fa4a61ce2438267163891961cfd5e32ec97a2c444e5b842d574251ade27d2"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:8fa02eaab317b1e9e03f69aab1f91e120e7899b392c4fc19807a8278a07a97e8"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:e7c21c95cae3c05c14aafffe2865bbd5e377cfc1348c4f7751d9dc9a48ca4bda"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-win32.whl", hash = "sha256:f12ad7126ae0c98d601a7ee504c1122bcef553d1d5e0c3bfa77b16b3968d2734"}, + {file = "lazy_object_proxy-1.9.0-cp37-cp37m-win_amd64.whl", hash = "sha256:edd20c5a55acb67c7ed471fa2b5fb66cb17f61430b7a6b9c3b4a1e40293b1671"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2d0daa332786cf3bb49e10dc6a17a52f6a8f9601b4cf5c295a4f85854d61de63"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cd077f3d04a58e83d04b20e334f678c2b0ff9879b9375ed107d5d07ff160171"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:660c94ea760b3ce47d1855a30984c78327500493d396eac4dfd8bd82041b22be"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:212774e4dfa851e74d393a2370871e174d7ff0ebc980907723bb67d25c8a7c30"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f0117049dd1d5635bbff65444496c90e0baa48ea405125c088e93d9cf4525b11"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-win32.whl", hash = "sha256:0a891e4e41b54fd5b8313b96399f8b0e173bbbfc03c7631f01efbe29bb0bcf82"}, + {file = "lazy_object_proxy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:9990d8e71b9f6488e91ad25f322898c136b008d87bf852ff65391b004da5e17b"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9e7551208b2aded9c1447453ee366f1c4070602b3d932ace044715d89666899b"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f83ac4d83ef0ab017683d715ed356e30dd48a93746309c8f3517e1287523ef4"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7322c3d6f1766d4ef1e51a465f47955f1e8123caee67dd641e67d539a534d006"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:18b78ec83edbbeb69efdc0e9c1cb41a3b1b1ed11ddd8ded602464c3fc6020494"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:09763491ce220c0299688940f8dc2c5d05fd1f45af1e42e636b2e8b2303e4382"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-win32.whl", hash = "sha256:9090d8e53235aa280fc9239a86ae3ea8ac58eff66a705fa6aa2ec4968b95c821"}, + {file = "lazy_object_proxy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:db1c1722726f47e10e0b5fdbf15ac3b8adb58c091d12b3ab713965795036985f"}, +] + [[package]] name = "markupsafe" version = "2.1.3" @@ -542,6 +633,17 @@ files = [ {file = "MarkupSafe-2.1.3.tar.gz", hash = "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + [[package]] name = "mypy" version = "1.5.1" @@ -873,6 +975,63 @@ files = [ [package.extras] plugins = ["importlib-metadata"] +[[package]] +name = "pylint" +version = "2.17.5" +description = "python code static checker" +optional = false +python-versions = ">=3.7.2" +files = [ + {file = "pylint-2.17.5-py3-none-any.whl", hash = "sha256:73995fb8216d3bed149c8d51bba25b2c52a8251a2c8ac846ec668ce38fab5413"}, + {file = "pylint-2.17.5.tar.gz", hash = "sha256:f7b601cbc06fef7e62a754e2b41294c2aa31f1cb659624b9a85bcba29eaf8252"}, +] + +[package.dependencies] +astroid = ">=2.15.6,<=2.17.0-dev0" +colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} +dill = {version = ">=0.3.6", markers = "python_version >= \"3.11\""} +isort = ">=4.2.5,<6" +mccabe = ">=0.6,<0.8" +platformdirs = ">=2.2.0" +tomlkit = ">=0.10.1" + +[package.extras] +spelling = ["pyenchant (>=3.2,<4.0)"] +testutils = ["gitpython (>3)"] + +[[package]] +name = "pylint-django" +version = "2.5.3" +description = "A Pylint plugin to help Pylint understand the Django web framework" +optional = false +python-versions = "*" +files = [ + {file = "pylint-django-2.5.3.tar.gz", hash = "sha256:0ac090d106c62fe33782a1d01bda1610b761bb1c9bf5035ced9d5f23a13d8591"}, + {file = "pylint_django-2.5.3-py3-none-any.whl", hash = "sha256:56b12b6adf56d548412445bd35483034394a1a94901c3f8571980a13882299d5"}, +] + +[package.dependencies] +pylint = ">=2.0,<3" +pylint-plugin-utils = ">=0.7" + +[package.extras] +for-tests = ["coverage", "django-tables2", "django-tastypie", "factory-boy", "pylint (>=2.13)", "pytest", "wheel"] +with-django = ["Django"] + +[[package]] +name = "pylint-plugin-utils" +version = "0.8.2" +description = "Utilities and helpers for writing Pylint plugins" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "pylint_plugin_utils-0.8.2-py3-none-any.whl", hash = "sha256:ae11664737aa2effbf26f973a9e0b6779ab7106ec0adc5fe104b0907ca04e507"}, + {file = "pylint_plugin_utils-0.8.2.tar.gz", hash = "sha256:d3cebf68a38ba3fba23a873809155562571386d4c1b03e5b4c4cc26c3eee93e4"}, +] + +[package.dependencies] +pylint = ">=1.7" + [[package]] name = "pytest" version = "7.4.0" @@ -1334,6 +1493,90 @@ files = [ {file = "wcwidth-0.2.6.tar.gz", hash = "sha256:a5220780a404dbe3353789870978e472cfe477761f06ee55077256e509b156d0"}, ] +[[package]] +name = "wrapt" +version = "1.15.0" +description = "Module for decorators, wrappers and monkey patching." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +files = [ + {file = "wrapt-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:ca1cccf838cd28d5a0883b342474c630ac48cac5df0ee6eacc9c7290f76b11c1"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e826aadda3cae59295b95343db8f3d965fb31059da7de01ee8d1c40a60398b29"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:5fc8e02f5984a55d2c653f5fea93531e9836abbd84342c1d1e17abc4a15084c2"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:96e25c8603a155559231c19c0349245eeb4ac0096fe3c1d0be5c47e075bd4f46"}, + {file = "wrapt-1.15.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:40737a081d7497efea35ab9304b829b857f21558acfc7b3272f908d33b0d9d4c"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:f87ec75864c37c4c6cb908d282e1969e79763e0d9becdfe9fe5473b7bb1e5f09"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:1286eb30261894e4c70d124d44b7fd07825340869945c79d05bda53a40caa079"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:493d389a2b63c88ad56cdc35d0fa5752daac56ca755805b1b0c530f785767d5e"}, + {file = "wrapt-1.15.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:58d7a75d731e8c63614222bcb21dd992b4ab01a399f1f09dd82af17bbfc2368a"}, + {file = "wrapt-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:21f6d9a0d5b3a207cdf7acf8e58d7d13d463e639f0c7e01d82cdb671e6cb7923"}, + {file = "wrapt-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ce42618f67741d4697684e501ef02f29e758a123aa2d669e2d964ff734ee00ee"}, + {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41d07d029dd4157ae27beab04d22b8e261eddfc6ecd64ff7000b10dc8b3a5727"}, + {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54accd4b8bc202966bafafd16e69da9d5640ff92389d33d28555c5fd4f25ccb7"}, + {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fbfbca668dd15b744418265a9607baa970c347eefd0db6a518aaf0cfbd153c0"}, + {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:76e9c727a874b4856d11a32fb0b389afc61ce8aaf281ada613713ddeadd1cfec"}, + {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e20076a211cd6f9b44a6be58f7eeafa7ab5720eb796975d0c03f05b47d89eb90"}, + {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a74d56552ddbde46c246b5b89199cb3fd182f9c346c784e1a93e4dc3f5ec9975"}, + {file = "wrapt-1.15.0-cp310-cp310-win32.whl", hash = "sha256:26458da5653aa5b3d8dc8b24192f574a58984c749401f98fff994d41d3f08da1"}, + {file = "wrapt-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:75760a47c06b5974aa5e01949bf7e66d2af4d08cb8c1d6516af5e39595397f5e"}, + {file = "wrapt-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ba1711cda2d30634a7e452fc79eabcadaffedf241ff206db2ee93dd2c89a60e7"}, + {file = "wrapt-1.15.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56374914b132c702aa9aa9959c550004b8847148f95e1b824772d453ac204a72"}, + {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a89ce3fd220ff144bd9d54da333ec0de0399b52c9ac3d2ce34b569cf1a5748fb"}, + {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3bbe623731d03b186b3d6b0d6f51865bf598587c38d6f7b0be2e27414f7f214e"}, + {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3abbe948c3cbde2689370a262a8d04e32ec2dd4f27103669a45c6929bcdbfe7c"}, + {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b67b819628e3b748fd3c2192c15fb951f549d0f47c0449af0764d7647302fda3"}, + {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:7eebcdbe3677e58dd4c0e03b4f2cfa346ed4049687d839adad68cc38bb559c92"}, + {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:74934ebd71950e3db69960a7da29204f89624dde411afbfb3b4858c1409b1e98"}, + {file = "wrapt-1.15.0-cp311-cp311-win32.whl", hash = "sha256:bd84395aab8e4d36263cd1b9308cd504f6cf713b7d6d3ce25ea55670baec5416"}, + {file = "wrapt-1.15.0-cp311-cp311-win_amd64.whl", hash = "sha256:a487f72a25904e2b4bbc0817ce7a8de94363bd7e79890510174da9d901c38705"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:4ff0d20f2e670800d3ed2b220d40984162089a6e2c9646fdb09b85e6f9a8fc29"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9ed6aa0726b9b60911f4aed8ec5b8dd7bf3491476015819f56473ffaef8959bd"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:896689fddba4f23ef7c718279e42f8834041a21342d95e56922e1c10c0cc7afb"}, + {file = "wrapt-1.15.0-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:75669d77bb2c071333417617a235324a1618dba66f82a750362eccbe5b61d248"}, + {file = "wrapt-1.15.0-cp35-cp35m-win32.whl", hash = "sha256:fbec11614dba0424ca72f4e8ba3c420dba07b4a7c206c8c8e4e73f2e98f4c559"}, + {file = "wrapt-1.15.0-cp35-cp35m-win_amd64.whl", hash = "sha256:fd69666217b62fa5d7c6aa88e507493a34dec4fa20c5bd925e4bc12fce586639"}, + {file = "wrapt-1.15.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b0724f05c396b0a4c36a3226c31648385deb6a65d8992644c12a4963c70326ba"}, + {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bbeccb1aa40ab88cd29e6c7d8585582c99548f55f9b2581dfc5ba68c59a85752"}, + {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:38adf7198f8f154502883242f9fe7333ab05a5b02de7d83aa2d88ea621f13364"}, + {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:578383d740457fa790fdf85e6d346fda1416a40549fe8db08e5e9bd281c6a475"}, + {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a4cbb9ff5795cd66f0066bdf5947f170f5d63a9274f99bdbca02fd973adcf2a8"}, + {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:af5bd9ccb188f6a5fdda9f1f09d9f4c86cc8a539bd48a0bfdc97723970348418"}, + {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:b56d5519e470d3f2fe4aa7585f0632b060d532d0696c5bdfb5e8319e1d0f69a2"}, + {file = "wrapt-1.15.0-cp36-cp36m-win32.whl", hash = "sha256:77d4c1b881076c3ba173484dfa53d3582c1c8ff1f914c6461ab70c8428b796c1"}, + {file = "wrapt-1.15.0-cp36-cp36m-win_amd64.whl", hash = "sha256:077ff0d1f9d9e4ce6476c1a924a3332452c1406e59d90a2cf24aeb29eeac9420"}, + {file = "wrapt-1.15.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5c5aa28df055697d7c37d2099a7bc09f559d5053c3349b1ad0c39000e611d317"}, + {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a8564f283394634a7a7054b7983e47dbf39c07712d7b177b37e03f2467a024e"}, + {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:780c82a41dc493b62fc5884fb1d3a3b81106642c5c5c78d6a0d4cbe96d62ba7e"}, + {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e169e957c33576f47e21864cf3fc9ff47c223a4ebca8960079b8bd36cb014fd0"}, + {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:b02f21c1e2074943312d03d243ac4388319f2456576b2c6023041c4d57cd7019"}, + {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f2e69b3ed24544b0d3dbe2c5c0ba5153ce50dcebb576fdc4696d52aa22db6034"}, + {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d787272ed958a05b2c86311d3a4135d3c2aeea4fc655705f074130aa57d71653"}, + {file = "wrapt-1.15.0-cp37-cp37m-win32.whl", hash = "sha256:02fce1852f755f44f95af51f69d22e45080102e9d00258053b79367d07af39c0"}, + {file = "wrapt-1.15.0-cp37-cp37m-win_amd64.whl", hash = "sha256:abd52a09d03adf9c763d706df707c343293d5d106aea53483e0ec8d9e310ad5e"}, + {file = "wrapt-1.15.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdb4f085756c96a3af04e6eca7f08b1345e94b53af8921b25c72f096e704e145"}, + {file = "wrapt-1.15.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:230ae493696a371f1dbffaad3dafbb742a4d27a0afd2b1aecebe52b740167e7f"}, + {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63424c681923b9f3bfbc5e3205aafe790904053d42ddcc08542181a30a7a51bd"}, + {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d6bcbfc99f55655c3d93feb7ef3800bd5bbe963a755687cbf1f490a71fb7794b"}, + {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c99f4309f5145b93eca6e35ac1a988f0dc0a7ccf9ccdcd78d3c0adf57224e62f"}, + {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b130fe77361d6771ecf5a219d8e0817d61b236b7d8b37cc045172e574ed219e6"}, + {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:96177eb5645b1c6985f5c11d03fc2dbda9ad24ec0f3a46dcce91445747e15094"}, + {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d5fe3e099cf07d0fb5a1e23d399e5d4d1ca3e6dfcbe5c8570ccff3e9208274f7"}, + {file = "wrapt-1.15.0-cp38-cp38-win32.whl", hash = "sha256:abd8f36c99512755b8456047b7be10372fca271bf1467a1caa88db991e7c421b"}, + {file = "wrapt-1.15.0-cp38-cp38-win_amd64.whl", hash = "sha256:b06fa97478a5f478fb05e1980980a7cdf2712015493b44d0c87606c1513ed5b1"}, + {file = "wrapt-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2e51de54d4fb8fb50d6ee8327f9828306a959ae394d3e01a1ba8b2f937747d86"}, + {file = "wrapt-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0970ddb69bba00670e58955f8019bec4a42d1785db3faa043c33d81de2bf843c"}, + {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76407ab327158c510f44ded207e2f76b657303e17cb7a572ffe2f5a8a48aa04d"}, + {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cd525e0e52a5ff16653a3fc9e3dd827981917d34996600bbc34c05d048ca35cc"}, + {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d37ac69edc5614b90516807de32d08cb8e7b12260a285ee330955604ed9dd29"}, + {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:078e2a1a86544e644a68422f881c48b84fef6d18f8c7a957ffd3f2e0a74a0d4a"}, + {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:2cf56d0e237280baed46f0b5316661da892565ff58309d4d2ed7dba763d984b8"}, + {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:7dc0713bf81287a00516ef43137273b23ee414fe41a3c14be10dd95ed98a2df9"}, + {file = "wrapt-1.15.0-cp39-cp39-win32.whl", hash = "sha256:46ed616d5fb42f98630ed70c3529541408166c22cdfd4540b88d5f21006b0eff"}, + {file = "wrapt-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:eef4d64c650f33347c1f9266fa5ae001440b232ad9b98f1f43dfe7a79435c0a6"}, + {file = "wrapt-1.15.0-py3-none-any.whl", hash = "sha256:64b1df0f83706b4ef4cfb4fb0e4c2669100fd7ecacfb59e091fad300d4e04640"}, + {file = "wrapt-1.15.0.tar.gz", hash = "sha256:d06730c6aed78cee4126234cf2d071e01b44b915e725a6cb439a879ec9754a3a"}, +] + [[package]] name = "zipp" version = "3.16.2" @@ -1352,4 +1595,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "9378e298223fc3e58c5faf3ab40e07f121634f55101dc2e483f522bba12e5c50" +content-hash = "354486551aa2b405a83029af8230180a34254729288514a4543623eeab5000ee" diff --git a/pyproject.toml b/pyproject.toml index bc594d5..7f20463 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,7 @@ sphinx = "^7.2.3" [tool.poetry.group.lint.dependencies] black = "^23.7.0" ruff = "^0.0.285" +pylint-django = "^2.5.3" [tool.poetry.group.data.dependencies] From 93275c90235a6c9ad585215888a7731d3af56fed Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 17:55:05 -0400 Subject: [PATCH 14/31] build(django): update views and urls with employee id --- src/pydjango/pymysql/urls.py | 2 +- src/pydjango/pymysql/views.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pydjango/pymysql/urls.py b/src/pydjango/pymysql/urls.py index 9fe4c23..e417f54 100644 --- a/src/pydjango/pymysql/urls.py +++ b/src/pydjango/pymysql/urls.py @@ -6,5 +6,5 @@ urlpatterns = [ path("", views.index, name="index"), - path("/employee//", views.employee, name="employee"), + path("/employee//", views.employee, name="employee"), ] diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index d83637d..2fc4303 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -9,6 +9,6 @@ def index(request): return HttpResponse("Hello Django!") -def employee(request, id): - emp = Employee.objects().get(id=id) - return HttpResponse(f"Employee {id}: {emp}") +def employee(request, employee_id): + emp = Employee.objects.get(id=employee_id) + return HttpResponse(f"Employee {employee_id}: {emp}") From 13aad88d5b3307f29e8d7316563203074668352a Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 19:56:49 -0400 Subject: [PATCH 15/31] build(django): update views and urls with render and templates --- .../pymysql/templates/pymysql/employee.html | 5 ++++ .../pymysql/templates/pymysql/employees.html | 9 +++++++ .../pymysql/templates/pymysql/index.html | 1 + src/pydjango/pymysql/urls.py | 3 ++- src/pydjango/pymysql/views.py | 27 ++++++++++++++----- 5 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 src/pydjango/pymysql/templates/pymysql/employee.html create mode 100644 src/pydjango/pymysql/templates/pymysql/employees.html create mode 100644 src/pydjango/pymysql/templates/pymysql/index.html diff --git a/src/pydjango/pymysql/templates/pymysql/employee.html b/src/pydjango/pymysql/templates/pymysql/employee.html new file mode 100644 index 0000000..d32b1ca --- /dev/null +++ b/src/pydjango/pymysql/templates/pymysql/employee.html @@ -0,0 +1,5 @@ +{% if employee %} +{{ employee.__str__() }} +{% else %} +

No employee available.

+{% endif %} diff --git a/src/pydjango/pymysql/templates/pymysql/employees.html b/src/pydjango/pymysql/templates/pymysql/employees.html new file mode 100644 index 0000000..503d98d --- /dev/null +++ b/src/pydjango/pymysql/templates/pymysql/employees.html @@ -0,0 +1,9 @@ +{% if employees %} + +{% else %} +

No employees are available.

+{% endif %} diff --git a/src/pydjango/pymysql/templates/pymysql/index.html b/src/pydjango/pymysql/templates/pymysql/index.html new file mode 100644 index 0000000..afc2780 --- /dev/null +++ b/src/pydjango/pymysql/templates/pymysql/index.html @@ -0,0 +1 @@ +

INDEX

diff --git a/src/pydjango/pymysql/urls.py b/src/pydjango/pymysql/urls.py index e417f54..2fe7d84 100644 --- a/src/pydjango/pymysql/urls.py +++ b/src/pydjango/pymysql/urls.py @@ -1,4 +1,4 @@ -"""Urls.""" +"""Urls for PyMySQL.""" from django.urls import path @@ -7,4 +7,5 @@ urlpatterns = [ path("", views.index, name="index"), path("/employee//", views.employee, name="employee"), + path("/employees/", views.employees, name="employees"), ] diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index 2fc4303..d5c1592 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -1,14 +1,29 @@ +"""Views for PyMySQL.""" + +from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.http import HttpResponse +from django.template import loader + from .models import Employee # Create your views here. -def index(request): - """views index""" - return HttpResponse("Hello Django!") +def index(request: HttpRequest) -> HttpResponse: + """Response index.""" + return render(request, "index.html") + + +def employees(request: HttpRequest) -> HttpResponse: + """Response employees.""" + emps = Employee.objects + template = loader.get_template("pymysql/index.html") + context = {"employees": emps} + return HttpResponse(template.render(context, request)) -def employee(request, employee_id): +def employee(request: HttpRequest, employee_id: int) -> HttpResponse: + """Response employee.""" emp = Employee.objects.get(id=employee_id) - return HttpResponse(f"Employee {employee_id}: {emp}") + template = loader.get_template("pymysql/employee.html") + context = {"employee": emp} + return HttpResponse(template.render(context, request)) From 15034231683d847dd2e53f51559177b9c6bd6182 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 19:57:08 -0400 Subject: [PATCH 16/31] build(ruff): fix ruff warnings --- src/pydjango/__init__.py | 1 + src/pydjango/manage.py | 21 ++++++++++--------- src/pydjango/pydjango/__init__.py | 1 + src/pydjango/pydjango/asgi.py | 3 +-- src/pydjango/pydjango/settings.py | 19 +++++++++-------- src/pydjango/pydjango/urls.py | 8 ++++--- src/pydjango/pydjango/wsgi.py | 3 +-- src/pydjango/pymysql/__init__.py | 1 + src/pydjango/pymysql/admin.py | 3 +++ src/pydjango/pymysql/apps.py | 4 ++++ .../pymysql/migrations/0001_initial.py | 13 +++++++++--- src/pydjango/pymysql/migrations/__init__.py | 1 + src/pydjango/pymysql/models.py | 4 ++++ src/pydjango/pymysql/tests.py | 5 +++++ 14 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 src/pydjango/__init__.py diff --git a/src/pydjango/__init__.py b/src/pydjango/__init__.py new file mode 100644 index 0000000..df3a2fd --- /dev/null +++ b/src/pydjango/__init__.py @@ -0,0 +1 @@ +"""Init PyDjango.""" diff --git a/src/pydjango/manage.py b/src/pydjango/manage.py index 5e19173..c4b6789 100644 --- a/src/pydjango/manage.py +++ b/src/pydjango/manage.py @@ -1,22 +1,23 @@ -#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys -def main(): +def main() -> None: """Run administrative tasks.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydjango.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__": + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + ERROR_MESSAGE = """ + 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? + """ + raise ImportError(ERROR_MESSAGE) from exc + main() diff --git a/src/pydjango/pydjango/__init__.py b/src/pydjango/pydjango/__init__.py index e69de29..df3a2fd 100644 --- a/src/pydjango/pydjango/__init__.py +++ b/src/pydjango/pydjango/__init__.py @@ -0,0 +1 @@ +"""Init PyDjango.""" diff --git a/src/pydjango/pydjango/asgi.py b/src/pydjango/pydjango/asgi.py index 0833579..c6d5eb8 100644 --- a/src/pydjango/pydjango/asgi.py +++ b/src/pydjango/pydjango/asgi.py @@ -1,5 +1,4 @@ -""" -ASGI config for pydjango project. +"""ASGI config for pydjango project. It exposes the ASGI callable as a module-level variable named ``application``. diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 659ac87..7a44eaf 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -1,5 +1,4 @@ -""" -Django settings for pydjango project. +"""Django settings for pydjango project. Generated by 'django-admin startproject' using Django 4.2.4. @@ -10,8 +9,9 @@ https://docs.djangoproject.com/en/4.2/ref/settings/ """ -from pathlib import Path from os import environ +from pathlib import Path + from dotenv import find_dotenv, load_dotenv load_dotenv(find_dotenv()) @@ -24,7 +24,7 @@ # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-n-g&cz+%pmnklxel0l)l@6vhz13#91gmj^ml!6h)-+i$3ap#9j" +SECRET_KEY = environ.get("DJANGO_SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -86,25 +86,26 @@ "NAME": environ.get("DATABASE_NAME"), "HOST": environ.get("DATABASE_HOST"), "PORT": environ.get("DATABASE_PORT"), - } + }, } # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators +DJANGO_CONTRIB_AUTH = "django.contrib.auth.password_validation" AUTH_PASSWORD_VALIDATORS = [ { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + "NAME": f"{DJANGO_CONTRIB_AUTH}.UserAttributeSimilarityValidator", }, { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + "NAME": f"{DJANGO_CONTRIB_AUTH}.MinimumLengthValidator", }, { - "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + "NAME": f"{DJANGO_CONTRIB_AUTH}.CommonPasswordValidator", }, { - "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + "NAME": f"{DJANGO_CONTRIB_AUTH}.NumericPasswordValidator", }, ] diff --git a/src/pydjango/pydjango/urls.py b/src/pydjango/pydjango/urls.py index fe5d3dc..8c3fdc5 100644 --- a/src/pydjango/pydjango/urls.py +++ b/src/pydjango/pydjango/urls.py @@ -1,9 +1,10 @@ -""" -URL configuration for pydjango project. +"""URL configuration for pydjango project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.2/topics/http/urls/ -Examples: + +Examples +-------- Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') @@ -13,6 +14,7 @@ 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 include, path diff --git a/src/pydjango/pydjango/wsgi.py b/src/pydjango/pydjango/wsgi.py index 8cda617..bb1054f 100644 --- a/src/pydjango/pydjango/wsgi.py +++ b/src/pydjango/pydjango/wsgi.py @@ -1,5 +1,4 @@ -""" -WSGI config for pydjango project. +"""WSGI config for pydjango project. It exposes the WSGI callable as a module-level variable named ``application``. diff --git a/src/pydjango/pymysql/__init__.py b/src/pydjango/pymysql/__init__.py index e69de29..20a2a12 100644 --- a/src/pydjango/pymysql/__init__.py +++ b/src/pydjango/pymysql/__init__.py @@ -0,0 +1 @@ +"""Init PyMySQL.""" diff --git a/src/pydjango/pymysql/admin.py b/src/pydjango/pymysql/admin.py index 57bd7b1..f2a68ea 100644 --- a/src/pydjango/pymysql/admin.py +++ b/src/pydjango/pymysql/admin.py @@ -1,4 +1,7 @@ +"""Admin setup for PyMySQL.""" + from django.contrib import admin + from .models import Employee, Task # Register your models here. diff --git a/src/pydjango/pymysql/apps.py b/src/pydjango/pymysql/apps.py index 95365d4..429b3d1 100644 --- a/src/pydjango/pymysql/apps.py +++ b/src/pydjango/pymysql/apps.py @@ -1,6 +1,10 @@ +"""Apps for PyMySQL.""" + from django.apps import AppConfig class PymysqlConfig(AppConfig): + """Config for PyMySQL.""" + default_auto_field = "django.db.models.BigAutoField" name = "pymysql" diff --git a/src/pydjango/pymysql/migrations/0001_initial.py b/src/pydjango/pymysql/migrations/0001_initial.py index 5509b2d..2dc58a4 100644 --- a/src/pydjango/pymysql/migrations/0001_initial.py +++ b/src/pydjango/pymysql/migrations/0001_initial.py @@ -1,15 +1,22 @@ +"""PyMySQL Migration.""" # Generated by Django 4.2.4 on 2023-08-25 20:24 -from django.db import migrations, models +from __future__ import annotations + +from typing import ClassVar + import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): + """Migration for PyMYSQL.""" + initial = True - dependencies = [] + dependencies: ClassVar = [] - operations = [ + operations: ClassVar = [ migrations.CreateModel( name="Employee", fields=[ diff --git a/src/pydjango/pymysql/migrations/__init__.py b/src/pydjango/pymysql/migrations/__init__.py index e69de29..5ca9b5a 100644 --- a/src/pydjango/pymysql/migrations/__init__.py +++ b/src/pydjango/pymysql/migrations/__init__.py @@ -0,0 +1 @@ +"""Init for PySQL migrations.""" diff --git a/src/pydjango/pymysql/models.py b/src/pydjango/pymysql/models.py index 383d265..29a59b0 100644 --- a/src/pydjango/pymysql/models.py +++ b/src/pydjango/pymysql/models.py @@ -1,3 +1,5 @@ +"""Models for PyMySQL.""" + from django.db import models @@ -11,6 +13,7 @@ class Employee(models.Model): phone = models.CharField(max_length=20) def __str__(self: "Employee") -> str: + """Employee string representation.""" return f"{self.first_name} {self.last_name}" @@ -24,6 +27,7 @@ class Task(models.Model): date_end = models.DateTimeField() def __str__(self: "Task") -> str: + """Task string representation.""" return f"{self.title}" def is_assign(self: "Task") -> bool: diff --git a/src/pydjango/pymysql/tests.py b/src/pydjango/pymysql/tests.py index 7ce503c..38e4f26 100644 --- a/src/pydjango/pymysql/tests.py +++ b/src/pydjango/pymysql/tests.py @@ -1,3 +1,8 @@ +"""Tests for PyMYSQL.""" + from django.test import TestCase + # Create your tests here. +class Test(TestCase): + """Test for PyMySQL.""" From 8b06eaae63ae24cc3aaf4d445aac774773106686 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 20:20:37 -0400 Subject: [PATCH 17/31] build(django): update views and urls with render and templates --- src/pydjango/pymysql/templates/pymysql/employee.html | 2 +- src/pydjango/pymysql/templates/pymysql/employees.html | 2 +- src/pydjango/pymysql/urls.py | 2 +- src/pydjango/pymysql/views.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pydjango/pymysql/templates/pymysql/employee.html b/src/pydjango/pymysql/templates/pymysql/employee.html index d32b1ca..c26109e 100644 --- a/src/pydjango/pymysql/templates/pymysql/employee.html +++ b/src/pydjango/pymysql/templates/pymysql/employee.html @@ -1,5 +1,5 @@ {% if employee %} -{{ employee.__str__() }} +{{ employee }} {% else %}

No employee available.

{% endif %} diff --git a/src/pydjango/pymysql/templates/pymysql/employees.html b/src/pydjango/pymysql/templates/pymysql/employees.html index 503d98d..8e2670d 100644 --- a/src/pydjango/pymysql/templates/pymysql/employees.html +++ b/src/pydjango/pymysql/templates/pymysql/employees.html @@ -1,7 +1,7 @@ {% if employees %} {% else %} diff --git a/src/pydjango/pymysql/urls.py b/src/pydjango/pymysql/urls.py index 2fe7d84..7c00c33 100644 --- a/src/pydjango/pymysql/urls.py +++ b/src/pydjango/pymysql/urls.py @@ -5,7 +5,7 @@ from . import views urlpatterns = [ - path("", views.index, name="index"), + path("/", views.index, name="index"), path("/employee//", views.employee, name="employee"), path("/employees/", views.employees, name="employees"), ] diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index d5c1592..6188fd0 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -10,13 +10,13 @@ # Create your views here. def index(request: HttpRequest) -> HttpResponse: """Response index.""" - return render(request, "index.html") + return render(request, "pymysql/index.html") def employees(request: HttpRequest) -> HttpResponse: """Response employees.""" - emps = Employee.objects - template = loader.get_template("pymysql/index.html") + emps = Employee.objects.all() + template = loader.get_template("pymysql/employees.html") context = {"employees": emps} return HttpResponse(template.render(context, request)) From 69d26a098c6590963983652a5066c6f15b5af943 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 20:55:43 -0400 Subject: [PATCH 18/31] build(django): use render shortcut --- src/pydjango/pymysql/views.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index 6188fd0..e6e8389 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -2,7 +2,6 @@ from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.template import loader from .models import Employee @@ -15,15 +14,11 @@ def index(request: HttpRequest) -> HttpResponse: def employees(request: HttpRequest) -> HttpResponse: """Response employees.""" - emps = Employee.objects.all() - template = loader.get_template("pymysql/employees.html") - context = {"employees": emps} - return HttpResponse(template.render(context, request)) + context = {"employees": Employee.objects.all()} + return render(request, "pymysql/employees.html", context) def employee(request: HttpRequest, employee_id: int) -> HttpResponse: """Response employee.""" - emp = Employee.objects.get(id=employee_id) - template = loader.get_template("pymysql/employee.html") - context = {"employee": emp} - return HttpResponse(template.render(context, request)) + context = {"employee": Employee.objects.get(id=employee_id)} + return render(request, "pymysql/employee.html", context) From 295e0d1deed193870a3d82772efdfc082070c572 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 20:58:53 -0400 Subject: [PATCH 19/31] build(django): use shortcut with get, list and 404 --- src/pydjango/pymysql/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index e6e8389..ec3639c 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -1,7 +1,7 @@ """Views for PyMySQL.""" from django.http import HttpRequest, HttpResponse -from django.shortcuts import render +from django.shortcuts import get_list_or_404, get_object_or_404, render from .models import Employee @@ -14,11 +14,11 @@ def index(request: HttpRequest) -> HttpResponse: def employees(request: HttpRequest) -> HttpResponse: """Response employees.""" - context = {"employees": Employee.objects.all()} + context = {"employees": get_list_or_404(Employee)} return render(request, "pymysql/employees.html", context) def employee(request: HttpRequest, employee_id: int) -> HttpResponse: """Response employee.""" - context = {"employee": Employee.objects.get(id=employee_id)} + context = {"employee": get_object_or_404(Employee, id=employee_id)} return render(request, "pymysql/employee.html", context) From 34ef60c35c8639bbd3eff9602050e735d86e845c Mon Sep 17 00:00:00 2001 From: MenSeb Date: Fri, 25 Aug 2023 21:08:54 -0400 Subject: [PATCH 20/31] build(django): update urls and html with namespaces --- src/pydjango/pymysql/templates/pymysql/employee.html | 2 +- src/pydjango/pymysql/templates/pymysql/employees.html | 2 +- src/pydjango/pymysql/urls.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pydjango/pymysql/templates/pymysql/employee.html b/src/pydjango/pymysql/templates/pymysql/employee.html index c26109e..37bcaad 100644 --- a/src/pydjango/pymysql/templates/pymysql/employee.html +++ b/src/pydjango/pymysql/templates/pymysql/employee.html @@ -1,5 +1,5 @@ {% if employee %} -{{ employee }} +{{ employee }} {% else %}

No employee available.

{% endif %} diff --git a/src/pydjango/pymysql/templates/pymysql/employees.html b/src/pydjango/pymysql/templates/pymysql/employees.html index 8e2670d..db0019c 100644 --- a/src/pydjango/pymysql/templates/pymysql/employees.html +++ b/src/pydjango/pymysql/templates/pymysql/employees.html @@ -1,7 +1,7 @@ {% if employees %} {% else %} diff --git a/src/pydjango/pymysql/urls.py b/src/pydjango/pymysql/urls.py index 7c00c33..eeb9564 100644 --- a/src/pydjango/pymysql/urls.py +++ b/src/pydjango/pymysql/urls.py @@ -4,6 +4,7 @@ from . import views +app_name = "pymysql" urlpatterns = [ path("/", views.index, name="index"), path("/employee//", views.employee, name="employee"), From b5489f69ac50bda1ed561c747addf3ede2498056 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 09:04:45 -0400 Subject: [PATCH 21/31] build(django): update templates with base layout --- src/pydjango/pydjango/settings.py | 2 +- src/pydjango/pymysql/templates/index.html | 33 +++++++++++++++++++ .../pymysql/templates/pymysql/employee.html | 4 +-- .../pymysql/templates/pymysql/employees.html | 4 +-- .../pymysql/templates/pymysql/index.html | 1 - 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/pydjango/pymysql/templates/index.html delete mode 100644 src/pydjango/pymysql/templates/pymysql/index.html diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 7a44eaf..904dc73 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -35,13 +35,13 @@ # Application definition INSTALLED_APPS = [ - "pymysql.apps.PymysqlConfig", "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "pymysql.apps.PymysqlConfig", ] MIDDLEWARE = [ diff --git a/src/pydjango/pymysql/templates/index.html b/src/pydjango/pymysql/templates/index.html new file mode 100644 index 0000000..04578f5 --- /dev/null +++ b/src/pydjango/pymysql/templates/index.html @@ -0,0 +1,33 @@ +{% load static %} + + + + + + + PyMySQL + + +
+ Python logo +

PyDjango

+ +
+
+
+

PyMySQL

+

MySQL database with Python and Django!

+
+
{% block content %} {% endblock content %}
+
+
Footer
+ + diff --git a/src/pydjango/pymysql/templates/pymysql/employee.html b/src/pydjango/pymysql/templates/pymysql/employee.html index 37bcaad..0c76fb7 100644 --- a/src/pydjango/pymysql/templates/pymysql/employee.html +++ b/src/pydjango/pymysql/templates/pymysql/employee.html @@ -1,5 +1,5 @@ -{% if employee %} +{% extends 'index.html' %} {% block content %} {% if employee %} {{ employee }} {% else %}

No employee available.

-{% endif %} +{% endif %} {% endblock content %} diff --git a/src/pydjango/pymysql/templates/pymysql/employees.html b/src/pydjango/pymysql/templates/pymysql/employees.html index db0019c..0a00cc8 100644 --- a/src/pydjango/pymysql/templates/pymysql/employees.html +++ b/src/pydjango/pymysql/templates/pymysql/employees.html @@ -1,4 +1,4 @@ -{% if employees %} +{% extends 'index.html' %} {% block content %} {% if employees %} {% else %}

No employees are available.

-{% endif %} +{% endif %} {% endblock content %} diff --git a/src/pydjango/pymysql/templates/pymysql/index.html b/src/pydjango/pymysql/templates/pymysql/index.html deleted file mode 100644 index afc2780..0000000 --- a/src/pydjango/pymysql/templates/pymysql/index.html +++ /dev/null @@ -1 +0,0 @@ -

INDEX

From df084be1bb8b79831636fadcf29caadc6938e65e Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 11:16:34 -0400 Subject: [PATCH 22/31] build(django): create static folder with assets --- src/pydjango/pymysql/static/assets/python.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/pydjango/pymysql/static/assets/python.svg diff --git a/src/pydjango/pymysql/static/assets/python.svg b/src/pydjango/pymysql/static/assets/python.svg new file mode 100644 index 0000000..1cbef49 --- /dev/null +++ b/src/pydjango/pymysql/static/assets/python.svg @@ -0,0 +1 @@ + \ No newline at end of file From 4dec9fe09e54082d19136d56157919047677979b Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 13:16:09 -0400 Subject: [PATCH 23/31] build(djlint): install and config djLint --- .djlintrc | 4 + .github/workflows/validate.yml | 4 +- README.md | 2 + poetry.lock | 219 ++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 5 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 .djlintrc diff --git a/.djlintrc b/.djlintrc new file mode 100644 index 0000000..d76c86d --- /dev/null +++ b/.djlintrc @@ -0,0 +1,4 @@ +{ + "ignore": "H006,T002", + "indent": "2" +} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index ff6b7eb..c2b397e 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -18,8 +18,10 @@ jobs: python-version: "3.11" - name: Install run: pip install poetry && poetry install - - name: Lint + - name: Lint Ruff uses: chartboost/ruff-action@v1 + - name: Lint Django + run: poetry run djlint . - name: Test run: poetry run pytest --cov=. --cov-report=lcov:coverage/lcov.info --verbose - name: Coverage diff --git a/README.md b/README.md index 38cdc2e..7c42834 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Code style: djLint](https://img.shields.io/badge/html%20style-djLint-blue.svg)](https://github.com/Riverside-Healthcare/djlint) + Commitizen diff --git a/poetry.lock b/poetry.lock index e139539..20b8875 100644 --- a/poetry.lock +++ b/poetry.lock @@ -351,6 +351,21 @@ requests = ">=1.0.0" [package.extras] yaml = ["PyYAML (>=3.10)"] +[[package]] +name = "cssbeautifier" +version = "1.14.9" +description = "CSS unobfuscator and beautifier." +optional = false +python-versions = "*" +files = [ + {file = "cssbeautifier-1.14.9.tar.gz", hash = "sha256:2da432472f68170eb854aff97b16a24721f5090ee36af2e31199590a89e7f71f"}, +] + +[package.dependencies] +editorconfig = ">=0.12.2" +jsbeautifier = "*" +six = ">=1.13.0" + [[package]] name = "decli" version = "0.6.1" @@ -407,6 +422,30 @@ tzdata = {version = "*", markers = "sys_platform == \"win32\""} argon2 = ["argon2-cffi (>=19.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "djlint" +version = "1.32.1" +description = "HTML Template Linter and Formatter" +optional = false +python-versions = ">=3.8.0,<4.0.0" +files = [ + {file = "djlint-1.32.1-py3-none-any.whl", hash = "sha256:8aaec6776376cfd41f3e742ed9f5e3c46dc7c6cd7646abf9e99860fb1ec9f19a"}, + {file = "djlint-1.32.1.tar.gz", hash = "sha256:c1e2141acf1547d244af7ef8abd15fbbae2abcc7a03e2bf31f8a491de69a6c72"}, +] + +[package.dependencies] +click = ">=8.0.1,<9.0.0" +colorama = ">=0.4.4,<0.5.0" +cssbeautifier = ">=1.14.4,<2.0.0" +html-tag-names = ">=0.1.2,<0.2.0" +html-void-elements = ">=0.1.0,<0.2.0" +jsbeautifier = ">=1.14.4,<2.0.0" +json5 = ">=0.9.11,<0.10.0" +pathspec = ">=0.11.0,<0.12.0" +PyYAML = ">=6.0,<7.0" +regex = ">=2023.0.0,<2024.0.0" +tqdm = ">=4.62.2,<5.0.0" + [[package]] name = "docopt" version = "0.6.2" @@ -428,6 +467,17 @@ files = [ {file = "docutils-0.20.1.tar.gz", hash = "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b"}, ] +[[package]] +name = "editorconfig" +version = "0.12.3" +description = "EditorConfig File Locator and Interpreter for Python" +optional = false +python-versions = "*" +files = [ + {file = "EditorConfig-0.12.3-py3-none-any.whl", hash = "sha256:6b0851425aa875b08b16789ee0eeadbd4ab59666e9ebe728e526314c4a2e52c1"}, + {file = "EditorConfig-0.12.3.tar.gz", hash = "sha256:57f8ce78afcba15c8b18d46b5170848c88d56fd38f05c2ec60dbbfcb8996e89e"}, +] + [[package]] name = "filelock" version = "3.12.2" @@ -443,6 +493,28 @@ files = [ docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] +[[package]] +name = "html-tag-names" +version = "0.1.2" +description = "List of known HTML tag names" +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "html-tag-names-0.1.2.tar.gz", hash = "sha256:04924aca48770f36b5a41c27e4d917062507be05118acb0ba869c97389084297"}, + {file = "html_tag_names-0.1.2-py3-none-any.whl", hash = "sha256:eeb69ef21078486b615241f0393a72b41352c5219ee648e7c61f5632d26f0420"}, +] + +[[package]] +name = "html-void-elements" +version = "0.1.0" +description = "List of HTML void tag names." +optional = false +python-versions = ">=3.7,<4.0" +files = [ + {file = "html-void-elements-0.1.0.tar.gz", hash = "sha256:931b88f84cd606fee0b582c28fcd00e41d7149421fb673e1e1abd2f0c4f231f0"}, + {file = "html_void_elements-0.1.0-py3-none-any.whl", hash = "sha256:784cf39db03cdeb017320d9301009f8f3480f9d7b254d0974272e80e0cb5e0d2"}, +] + [[package]] name = "idna" version = "3.4" @@ -529,6 +601,34 @@ MarkupSafe = ">=2.0" [package.extras] i18n = ["Babel (>=2.7)"] +[[package]] +name = "jsbeautifier" +version = "1.14.9" +description = "JavaScript unobfuscator and beautifier." +optional = false +python-versions = "*" +files = [ + {file = "jsbeautifier-1.14.9.tar.gz", hash = "sha256:c738ebc36b47bd94e4ca6dd17a9004c3cc74edad582ca1d60e0e5d5945a63cb9"}, +] + +[package.dependencies] +editorconfig = ">=0.12.2" +six = ">=1.13.0" + +[[package]] +name = "json5" +version = "0.9.14" +description = "A Python implementation of the JSON5 data format." +optional = false +python-versions = "*" +files = [ + {file = "json5-0.9.14-py2.py3-none-any.whl", hash = "sha256:740c7f1b9e584a468dbb2939d8d458db3427f2c93ae2139d05f47e453eae964f"}, + {file = "json5-0.9.14.tar.gz", hash = "sha256:9ed66c3a6ca3510a976a9ef9b8c0787de24802724ab1860bc0153c7fdd589b02"}, +] + +[package.extras] +dev = ["hypothesis"] + [[package]] name = "lazy-object-proxy" version = "1.9.0" @@ -1175,6 +1275,103 @@ prompt_toolkit = ">=2.0,<4.0" [package.extras] docs = ["Sphinx (>=3.3,<4.0)", "sphinx-autobuild (>=2020.9.1,<2021.0.0)", "sphinx-autodoc-typehints (>=1.11.1,<2.0.0)", "sphinx-copybutton (>=0.3.1,<0.4.0)", "sphinx-rtd-theme (>=0.5.0,<0.6.0)"] +[[package]] +name = "regex" +version = "2023.8.8" +description = "Alternative regular expression module, to replace re." +optional = false +python-versions = ">=3.6" +files = [ + {file = "regex-2023.8.8-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:88900f521c645f784260a8d346e12a1590f79e96403971241e64c3a265c8ecdb"}, + {file = "regex-2023.8.8-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:3611576aff55918af2697410ff0293d6071b7e00f4b09e005d614686ac4cd57c"}, + {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8a0ccc8f2698f120e9e5742f4b38dc944c38744d4bdfc427616f3a163dd9de5"}, + {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c662a4cbdd6280ee56f841f14620787215a171c4e2d1744c9528bed8f5816c96"}, + {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cf0633e4a1b667bfe0bb10b5e53fe0d5f34a6243ea2530eb342491f1adf4f739"}, + {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:551ad543fa19e94943c5b2cebc54c73353ffff08228ee5f3376bd27b3d5b9800"}, + {file = "regex-2023.8.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54de2619f5ea58474f2ac211ceea6b615af2d7e4306220d4f3fe690c91988a61"}, + {file = "regex-2023.8.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:5ec4b3f0aebbbe2fc0134ee30a791af522a92ad9f164858805a77442d7d18570"}, + {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:3ae646c35cb9f820491760ac62c25b6d6b496757fda2d51be429e0e7b67ae0ab"}, + {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ca339088839582d01654e6f83a637a4b8194d0960477b9769d2ff2cfa0fa36d2"}, + {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:d9b6627408021452dcd0d2cdf8da0534e19d93d070bfa8b6b4176f99711e7f90"}, + {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:bd3366aceedf274f765a3a4bc95d6cd97b130d1dda524d8f25225d14123c01db"}, + {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7aed90a72fc3654fba9bc4b7f851571dcc368120432ad68b226bd593f3f6c0b7"}, + {file = "regex-2023.8.8-cp310-cp310-win32.whl", hash = "sha256:80b80b889cb767cc47f31d2b2f3dec2db8126fbcd0cff31b3925b4dc6609dcdb"}, + {file = "regex-2023.8.8-cp310-cp310-win_amd64.whl", hash = "sha256:b82edc98d107cbc7357da7a5a695901b47d6eb0420e587256ba3ad24b80b7d0b"}, + {file = "regex-2023.8.8-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1e7d84d64c84ad97bf06f3c8cb5e48941f135ace28f450d86af6b6512f1c9a71"}, + {file = "regex-2023.8.8-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ce0f9fbe7d295f9922c0424a3637b88c6c472b75eafeaff6f910494a1fa719ef"}, + {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:06c57e14ac723b04458df5956cfb7e2d9caa6e9d353c0b4c7d5d54fcb1325c46"}, + {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e7a9aaa5a1267125eef22cef3b63484c3241aaec6f48949b366d26c7250e0357"}, + {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b7408511fca48a82a119d78a77c2f5eb1b22fe88b0d2450ed0756d194fe7a9a"}, + {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14dc6f2d88192a67d708341f3085df6a4f5a0c7b03dec08d763ca2cd86e9f559"}, + {file = "regex-2023.8.8-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:48c640b99213643d141550326f34f0502fedb1798adb3c9eb79650b1ecb2f177"}, + {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0085da0f6c6393428bf0d9c08d8b1874d805bb55e17cb1dfa5ddb7cfb11140bf"}, + {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:964b16dcc10c79a4a2be9f1273fcc2684a9eedb3906439720598029a797b46e6"}, + {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:7ce606c14bb195b0e5108544b540e2c5faed6843367e4ab3deb5c6aa5e681208"}, + {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:40f029d73b10fac448c73d6eb33d57b34607f40116e9f6e9f0d32e9229b147d7"}, + {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3b8e6ea6be6d64104d8e9afc34c151926f8182f84e7ac290a93925c0db004bfd"}, + {file = "regex-2023.8.8-cp311-cp311-win32.whl", hash = "sha256:942f8b1f3b223638b02df7df79140646c03938d488fbfb771824f3d05fc083a8"}, + {file = "regex-2023.8.8-cp311-cp311-win_amd64.whl", hash = "sha256:51d8ea2a3a1a8fe4f67de21b8b93757005213e8ac3917567872f2865185fa7fb"}, + {file = "regex-2023.8.8-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:e951d1a8e9963ea51efd7f150450803e3b95db5939f994ad3d5edac2b6f6e2b4"}, + {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:704f63b774218207b8ccc6c47fcef5340741e5d839d11d606f70af93ee78e4d4"}, + {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:22283c769a7b01c8ac355d5be0715bf6929b6267619505e289f792b01304d898"}, + {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:91129ff1bb0619bc1f4ad19485718cc623a2dc433dff95baadbf89405c7f6b57"}, + {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de35342190deb7b866ad6ba5cbcccb2d22c0487ee0cbb251efef0843d705f0d4"}, + {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b993b6f524d1e274a5062488a43e3f9f8764ee9745ccd8e8193df743dbe5ee61"}, + {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3026cbcf11d79095a32d9a13bbc572a458727bd5b1ca332df4a79faecd45281c"}, + {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:293352710172239bf579c90a9864d0df57340b6fd21272345222fb6371bf82b3"}, + {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:d909b5a3fff619dc7e48b6b1bedc2f30ec43033ba7af32f936c10839e81b9217"}, + {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:3d370ff652323c5307d9c8e4c62efd1956fb08051b0e9210212bc51168b4ff56"}, + {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:b076da1ed19dc37788f6a934c60adf97bd02c7eea461b73730513921a85d4235"}, + {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:e9941a4ada58f6218694f382e43fdd256e97615db9da135e77359da257a7168b"}, + {file = "regex-2023.8.8-cp36-cp36m-win32.whl", hash = "sha256:a8c65c17aed7e15a0c824cdc63a6b104dfc530f6fa8cb6ac51c437af52b481c7"}, + {file = "regex-2023.8.8-cp36-cp36m-win_amd64.whl", hash = "sha256:aadf28046e77a72f30dcc1ab185639e8de7f4104b8cb5c6dfa5d8ed860e57236"}, + {file = "regex-2023.8.8-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:423adfa872b4908843ac3e7a30f957f5d5282944b81ca0a3b8a7ccbbfaa06103"}, + {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4ae594c66f4a7e1ea67232a0846649a7c94c188d6c071ac0210c3e86a5f92109"}, + {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e51c80c168074faa793685656c38eb7a06cbad7774c8cbc3ea05552d615393d8"}, + {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:09b7f4c66aa9d1522b06e31a54f15581c37286237208df1345108fcf4e050c18"}, + {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2e73e5243af12d9cd6a9d6a45a43570dbe2e5b1cdfc862f5ae2b031e44dd95a8"}, + {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:941460db8fe3bd613db52f05259c9336f5a47ccae7d7def44cc277184030a116"}, + {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f0ccf3e01afeb412a1a9993049cb160d0352dba635bbca7762b2dc722aa5742a"}, + {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:2e9216e0d2cdce7dbc9be48cb3eacb962740a09b011a116fd7af8c832ab116ca"}, + {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:5cd9cd7170459b9223c5e592ac036e0704bee765706445c353d96f2890e816c8"}, + {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:4873ef92e03a4309b3ccd8281454801b291b689f6ad45ef8c3658b6fa761d7ac"}, + {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:239c3c2a339d3b3ddd51c2daef10874410917cd2b998f043c13e2084cb191684"}, + {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:1005c60ed7037be0d9dea1f9c53cc42f836188227366370867222bda4c3c6bd7"}, + {file = "regex-2023.8.8-cp37-cp37m-win32.whl", hash = "sha256:e6bd1e9b95bc5614a7a9c9c44fde9539cba1c823b43a9f7bc11266446dd568e3"}, + {file = "regex-2023.8.8-cp37-cp37m-win_amd64.whl", hash = "sha256:9a96edd79661e93327cfeac4edec72a4046e14550a1d22aa0dd2e3ca52aec921"}, + {file = "regex-2023.8.8-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f2181c20ef18747d5f4a7ea513e09ea03bdd50884a11ce46066bb90fe4213675"}, + {file = "regex-2023.8.8-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a2ad5add903eb7cdde2b7c64aaca405f3957ab34f16594d2b78d53b8b1a6a7d6"}, + {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9233ac249b354c54146e392e8a451e465dd2d967fc773690811d3a8c240ac601"}, + {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:920974009fb37b20d32afcdf0227a2e707eb83fe418713f7a8b7de038b870d0b"}, + {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd2b6c5dfe0929b6c23dde9624483380b170b6e34ed79054ad131b20203a1a63"}, + {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:96979d753b1dc3b2169003e1854dc67bfc86edf93c01e84757927f810b8c3c93"}, + {file = "regex-2023.8.8-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2ae54a338191e1356253e7883d9d19f8679b6143703086245fb14d1f20196be9"}, + {file = "regex-2023.8.8-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2162ae2eb8b079622176a81b65d486ba50b888271302190870b8cc488587d280"}, + {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:c884d1a59e69e03b93cf0dfee8794c63d7de0ee8f7ffb76e5f75be8131b6400a"}, + {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:cf9273e96f3ee2ac89ffcb17627a78f78e7516b08f94dc435844ae72576a276e"}, + {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:83215147121e15d5f3a45d99abeed9cf1fe16869d5c233b08c56cdf75f43a504"}, + {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:3f7454aa427b8ab9101f3787eb178057c5250478e39b99540cfc2b889c7d0586"}, + {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f0640913d2c1044d97e30d7c41728195fc37e54d190c5385eacb52115127b882"}, + {file = "regex-2023.8.8-cp38-cp38-win32.whl", hash = "sha256:0c59122ceccb905a941fb23b087b8eafc5290bf983ebcb14d2301febcbe199c7"}, + {file = "regex-2023.8.8-cp38-cp38-win_amd64.whl", hash = "sha256:c12f6f67495ea05c3d542d119d270007090bad5b843f642d418eb601ec0fa7be"}, + {file = "regex-2023.8.8-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:82cd0a69cd28f6cc3789cc6adeb1027f79526b1ab50b1f6062bbc3a0ccb2dbc3"}, + {file = "regex-2023.8.8-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:bb34d1605f96a245fc39790a117ac1bac8de84ab7691637b26ab2c5efb8f228c"}, + {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:987b9ac04d0b38ef4f89fbc035e84a7efad9cdd5f1e29024f9289182c8d99e09"}, + {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9dd6082f4e2aec9b6a0927202c85bc1b09dcab113f97265127c1dc20e2e32495"}, + {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7eb95fe8222932c10d4436e7a6f7c99991e3fdd9f36c949eff16a69246dee2dc"}, + {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7098c524ba9f20717a56a8d551d2ed491ea89cbf37e540759ed3b776a4f8d6eb"}, + {file = "regex-2023.8.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4b694430b3f00eb02c594ff5a16db30e054c1b9589a043fe9174584c6efa8033"}, + {file = "regex-2023.8.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:b2aeab3895d778155054abea5238d0eb9a72e9242bd4b43f42fd911ef9a13470"}, + {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:988631b9d78b546e284478c2ec15c8a85960e262e247b35ca5eaf7ee22f6050a"}, + {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:67ecd894e56a0c6108ec5ab1d8fa8418ec0cff45844a855966b875d1039a2e34"}, + {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:14898830f0a0eb67cae2bbbc787c1a7d6e34ecc06fbd39d3af5fe29a4468e2c9"}, + {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:f2200e00b62568cfd920127782c61bc1c546062a879cdc741cfcc6976668dfcf"}, + {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9691a549c19c22d26a4f3b948071e93517bdf86e41b81d8c6ac8a964bb71e5a6"}, + {file = "regex-2023.8.8-cp39-cp39-win32.whl", hash = "sha256:6ab2ed84bf0137927846b37e882745a827458689eb969028af8032b1b3dac78e"}, + {file = "regex-2023.8.8-cp39-cp39-win_amd64.whl", hash = "sha256:5543c055d8ec7801901e1193a51570643d6a6ab8751b1f7dd9af71af467538bb"}, + {file = "regex-2023.8.8.tar.gz", hash = "sha256:fcbdc5f2b0f1cd0f6a56cdb46fe41d2cce1e644e3b68832f3eeebc5fb0f7712e"}, +] + [[package]] name = "requests" version = "2.31.0" @@ -1423,6 +1620,26 @@ files = [ {file = "tomlkit-0.12.1.tar.gz", hash = "sha256:38e1ff8edb991273ec9f6181244a6a391ac30e9f5098e7535640ea6be97a7c86"}, ] +[[package]] +name = "tqdm" +version = "4.66.1" +description = "Fast, Extensible Progress Meter" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tqdm-4.66.1-py3-none-any.whl", hash = "sha256:d302b3c5b53d47bce91fea46679d9c3c6508cf6332229aa1e7d8653723793386"}, + {file = "tqdm-4.66.1.tar.gz", hash = "sha256:d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + +[package.extras] +dev = ["pytest (>=6)", "pytest-cov", "pytest-timeout", "pytest-xdist"] +notebook = ["ipywidgets (>=6)"] +slack = ["slack-sdk"] +telegram = ["requests"] + [[package]] name = "typing-extensions" version = "4.7.1" @@ -1595,4 +1812,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "354486551aa2b405a83029af8230180a34254729288514a4543623eeab5000ee" +content-hash = "31e7d4c69419b3822eb7d06035c9b147a2deab85d47a4e909c7a638f46faa44f" diff --git a/pyproject.toml b/pyproject.toml index 7f20463..147941f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,6 +70,7 @@ sphinx = "^7.2.3" black = "^23.7.0" ruff = "^0.0.285" pylint-django = "^2.5.3" +djlint = "^1.32.1" [tool.poetry.group.data.dependencies] From bd3939fb2f275798c8f98f89e451b4aad0b783b0 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 13:21:56 -0400 Subject: [PATCH 24/31] build(pydjando): create and lint templates --- src/pydjango/pymysql/templates/index.html | 22 +++++++++--------- src/pydjango/pymysql/templates/nav.html | 11 +++++++++ .../pymysql/templates/pymysql/employee.html | 13 +++++++---- .../pymysql/templates/pymysql/employees.html | 23 +++++++++++-------- 4 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 src/pydjango/pymysql/templates/nav.html diff --git a/src/pydjango/pymysql/templates/index.html b/src/pydjango/pymysql/templates/index.html index 04578f5..6075552 100644 --- a/src/pydjango/pymysql/templates/index.html +++ b/src/pydjango/pymysql/templates/index.html @@ -4,6 +4,8 @@ + + PyMySQL @@ -11,23 +13,21 @@
Python logo

PyDjango

- + {% include 'nav.html' with nav=nav_main %}

PyMySQL

MySQL database with Python and Django!

-
{% block content %} {% endblock content %}
+
+ {% block content %} + {% endblock content %} +
-
Footer
+
+ {% include 'nav.html' with nav=nav_socials %} + {% include 'nav.html' with nav=nav_main %} +
diff --git a/src/pydjango/pymysql/templates/nav.html b/src/pydjango/pymysql/templates/nav.html new file mode 100644 index 0000000..7845374 --- /dev/null +++ b/src/pydjango/pymysql/templates/nav.html @@ -0,0 +1,11 @@ +{% if nav %} + +{% endif %} diff --git a/src/pydjango/pymysql/templates/pymysql/employee.html b/src/pydjango/pymysql/templates/pymysql/employee.html index 0c76fb7..b0226d0 100644 --- a/src/pydjango/pymysql/templates/pymysql/employee.html +++ b/src/pydjango/pymysql/templates/pymysql/employee.html @@ -1,5 +1,8 @@ -{% extends 'index.html' %} {% block content %} {% if employee %} -{{ employee }} -{% else %} -

No employee available.

-{% endif %} {% endblock content %} +{% extends 'index.html' %} +{% block content %} + {% if employee %} + {{ employee }} + {% else %} +

No employee available.

+ {% endif %} +{% endblock content %} diff --git a/src/pydjango/pymysql/templates/pymysql/employees.html b/src/pydjango/pymysql/templates/pymysql/employees.html index 0a00cc8..3e22484 100644 --- a/src/pydjango/pymysql/templates/pymysql/employees.html +++ b/src/pydjango/pymysql/templates/pymysql/employees.html @@ -1,9 +1,14 @@ -{% extends 'index.html' %} {% block content %} {% if employees %} - -{% else %} -

No employees are available.

-{% endif %} {% endblock content %} +{% extends 'index.html' %} +{% block content %} + {% if employees %} +
    + {% for employee in employees %} +
  • + {{ employee }} +
  • + {% endfor %} +
+ {% else %} +

No employees are available.

+ {% endif %} +{% endblock content %} From cc40484950cb07b9763f4dc9bab09f3620e1af0c Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 13:54:17 -0400 Subject: [PATCH 25/31] build(pydjango): create root templates --- src/pydjango/pydjango/settings.py | 2 +- src/pydjango/templates/nav.html | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/pydjango/templates/nav.html diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 904dc73..86ba9cf 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -59,7 +59,7 @@ TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [Path(BASE_DIR, "templates/")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ diff --git a/src/pydjango/templates/nav.html b/src/pydjango/templates/nav.html new file mode 100644 index 0000000..7845374 --- /dev/null +++ b/src/pydjango/templates/nav.html @@ -0,0 +1,11 @@ +{% if nav %} + +{% endif %} From 508e952241d14efb446c4f63eefa4a551c1330f4 Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 14:17:52 -0400 Subject: [PATCH 26/31] build(pydjango): create & process context in template --- src/pydjango/pydjango/settings.py | 1 + src/pydjango/pymysql/contexts.py | 36 +++++++++++++++++++++++ src/pydjango/pymysql/templates/index.html | 10 +++---- src/pydjango/pymysql/templates/nav.html | 11 ------- 4 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 src/pydjango/pymysql/contexts.py delete mode 100644 src/pydjango/pymysql/templates/nav.html diff --git a/src/pydjango/pydjango/settings.py b/src/pydjango/pydjango/settings.py index 86ba9cf..05f21f2 100644 --- a/src/pydjango/pydjango/settings.py +++ b/src/pydjango/pydjango/settings.py @@ -67,6 +67,7 @@ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "pymysql.contexts.website_settings", ], }, }, diff --git a/src/pydjango/pymysql/contexts.py b/src/pydjango/pymysql/contexts.py new file mode 100644 index 0000000..129c0f9 --- /dev/null +++ b/src/pydjango/pymysql/contexts.py @@ -0,0 +1,36 @@ +"""Contexts for Django.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +from .models import Navigation + +if TYPE_CHECKING: + from django.http import HttpRequest + + +def website_settings(request: HttpRequest) -> dict[str, Any]: + """Context for website.""" + nav_main = Navigation( + name="main", + links=[ + {"text": "Home", "url": "/pymysql"}, + {"text": "Employees", "url": "/pymysql/employees"}, + ], + ) + nav_socials = Navigation( + name="socials", + links=[ + {"icon": "github", "text": "Github", "url": "/pymysql"}, + {"icon": "linkedin", "text": "LinkedIn", "url": "/pymysql/employees"}, + ], + ) + return { + "site_brand": "PyMySQL", + "site_description": "Python application made with MySQL and Django", + "site_keywords": "Python, MySQL, Django", + "site_title": "PyMySQL Application", + "nav_main": nav_main, + "nav_socials": nav_socials, + } diff --git a/src/pydjango/pymysql/templates/index.html b/src/pydjango/pymysql/templates/index.html index 6075552..cdd6599 100644 --- a/src/pydjango/pymysql/templates/index.html +++ b/src/pydjango/pymysql/templates/index.html @@ -4,20 +4,20 @@ - - + + - PyMySQL + {{ site_title }}
Python logo -

PyDjango

+

{{ site_brand }}

{% include 'nav.html' with nav=nav_main %}
-

PyMySQL

+

PyMySQL

MySQL database with Python and Django!

diff --git a/src/pydjango/pymysql/templates/nav.html b/src/pydjango/pymysql/templates/nav.html deleted file mode 100644 index 7845374..0000000 --- a/src/pydjango/pymysql/templates/nav.html +++ /dev/null @@ -1,11 +0,0 @@ -{% if nav %} - -{% endif %} From dc30d1db84df9077080e89b50cc64f127856ff2c Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 14:28:45 -0400 Subject: [PATCH 27/31] build(pydjango): update models and views --- src/pydjango/pymysql/admin.py | 1 + src/pydjango/pymysql/models.py | 41 +++++++++++++++++++++++++++++----- src/pydjango/pymysql/views.py | 2 +- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/pydjango/pymysql/admin.py b/src/pydjango/pymysql/admin.py index f2a68ea..744e237 100644 --- a/src/pydjango/pymysql/admin.py +++ b/src/pydjango/pymysql/admin.py @@ -1,5 +1,6 @@ """Admin setup for PyMySQL.""" + from django.contrib import admin from .models import Employee, Task diff --git a/src/pydjango/pymysql/models.py b/src/pydjango/pymysql/models.py index 29a59b0..38ecb7a 100644 --- a/src/pydjango/pymysql/models.py +++ b/src/pydjango/pymysql/models.py @@ -1,5 +1,7 @@ """Models for PyMySQL.""" +from __future__ import annotations + from django.db import models @@ -12,8 +14,8 @@ class Employee(models.Model): email = models.CharField(max_length=319) phone = models.CharField(max_length=20) - def __str__(self: "Employee") -> str: - """Employee string representation.""" + def __str__(self: Employee) -> str: + """ToString Employee.""" return f"{self.first_name} {self.last_name}" @@ -26,10 +28,39 @@ class Task(models.Model): date_start = models.DateTimeField() date_end = models.DateTimeField() - def __str__(self: "Task") -> str: - """Task string representation.""" + def __str__(self: Task) -> str: + """ToString Task.""" return f"{self.title}" - def is_assign(self: "Task") -> bool: + def is_assign(self: Task) -> bool: """Check if an employee is assigned to the task.""" return self.employee is not None + + +class Navigation: + """Model for site navigation.""" + + def __init__(self: Navigation, name: str, links: list[dict[str, str]]) -> None: + """Init Navigation.""" + self.name = name + self.links = links + + def __repr__(self: Navigation) -> str: + """Reprensentation of Navigation.""" + return f"{type(self).__name__}({vars(self)})" + + def __str__(self: Navigation) -> str: + """ToString Navigation.""" + return f"Navigation for {self.name}." + + +class NavigationSocials(Navigation): + """Model for socials navigation.""" + + def __init__( + self: NavigationSocials, + name: str, + links: list[dict[str, str]], + ) -> None: + """Init NavigationSocials.""" + super().__init__(name, links) diff --git a/src/pydjango/pymysql/views.py b/src/pydjango/pymysql/views.py index ec3639c..bb348e8 100644 --- a/src/pydjango/pymysql/views.py +++ b/src/pydjango/pymysql/views.py @@ -9,7 +9,7 @@ # Create your views here. def index(request: HttpRequest) -> HttpResponse: """Response index.""" - return render(request, "pymysql/index.html") + return render(request, "index.html") def employees(request: HttpRequest) -> HttpResponse: From 15024d1d9a799d53fd1b0b94270d61a3b55fb6db Mon Sep 17 00:00:00 2001 From: MenSeb Date: Mon, 28 Aug 2023 14:36:17 -0400 Subject: [PATCH 28/31] refactor(pydjango): update views and templates --- .../templates/{index.html => base.html} | 10 ++----- .../pymysql/templates/pymysql/employee.html | 18 +++++++---- .../pymysql/templates/pymysql/employees.html | 30 +++++++++++-------- .../pymysql/templates/pymysql/index.html | 10 +++++++ src/pydjango/pymysql/views.py | 2 +- 5 files changed, 43 insertions(+), 27 deletions(-) rename src/pydjango/pymysql/templates/{index.html => base.html} (78%) create mode 100644 src/pydjango/pymysql/templates/pymysql/index.html diff --git a/src/pydjango/pymysql/templates/index.html b/src/pydjango/pymysql/templates/base.html similarity index 78% rename from src/pydjango/pymysql/templates/index.html rename to src/pydjango/pymysql/templates/base.html index cdd6599..8435864 100644 --- a/src/pydjango/pymysql/templates/index.html +++ b/src/pydjango/pymysql/templates/base.html @@ -16,14 +16,8 @@

{{ site_brand }}

{% include 'nav.html' with nav=nav_main %}
-
-

PyMySQL

-

MySQL database with Python and Django!

-
-
- {% block content %} - {% endblock content %} -
+ {% block content %} + {% endblock content %}