Add Django REST Framework

This commit is contained in:
Adam Goldsmith 2022-12-23 20:36:24 -05:00
parent 0d9e2e970e
commit fe624c421f
4 changed files with 43 additions and 1 deletions

View File

@ -33,6 +33,8 @@ INSTALLED_APPS = [
"widget_tweaks", "widget_tweaks",
"markdownx", "markdownx",
"recurrence", "recurrence",
"rest_framework",
"rest_framework.authtoken",
"tasks.apps.TasksConfig", "tasks.apps.TasksConfig",
"rentals.apps.RentalsConfig", "rentals.apps.RentalsConfig",
"membershipworks.apps.MembershipworksConfig", "membershipworks.apps.MembershipworksConfig",
@ -94,3 +96,14 @@ USE_TZ = True
STATIC_URL = "/static/" STATIC_URL = "/static/"
WIKI_URL = "https://wiki.claremontmakerspace.org" WIKI_URL = "https://wiki.claremontmakerspace.org"
# Django Rest Framework
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.DjangoModelPermissions"],
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.TokenAuthentication",
],
"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.NamespaceVersioning",
}

View File

@ -19,13 +19,17 @@ from django.urls import include, path
from django.contrib.auth.views import LoginView, LogoutView from django.contrib.auth.views import LoginView, LogoutView
from django.conf import settings from django.conf import settings
from rest_framework import routers
router = routers.DefaultRouter()
urlpatterns = [ urlpatterns = [
path("", lambda request: redirect("/tasks/"), name="root"), path("", lambda request: redirect("/tasks/"), name="root"),
path("tasks/", include("tasks.urls")), path("tasks/", include("tasks.urls")),
path("rentals/", include("rentals.urls")), path("rentals/", include("rentals.urls")),
path("membershipworks/", include("membershipworks.urls")), path("membershipworks/", include("membershipworks.urls")),
path("paperwork/", include("paperwork.urls")), path("paperwork/", include("paperwork.urls")),
path("api/v1/", include((router.urls, "api"), namespace="v1")),
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
path( path(
"auth/", "auth/",
@ -47,6 +51,7 @@ urlpatterns = [
] ]
), ),
), ),
path("api-auth/", include("rest_framework.urls")),
path("markdownx/", include("markdownx.urls")), path("markdownx/", include("markdownx.urls")),
] ]

View File

@ -204,6 +204,16 @@ version = "1.4.12"
requires_python = ">=3.7" requires_python = ">=3.7"
summary = "Tweak the form field rendering in templates, not in python-level form definitions." summary = "Tweak the form field rendering in templates, not in python-level form definitions."
[[package]]
name = "djangorestframework"
version = "3.14.0"
requires_python = ">=3.6"
summary = "Web APIs for Django, made easy."
dependencies = [
"django>=3.0",
"pytz",
]
[[package]] [[package]]
name = "djlint" name = "djlint"
version = "1.19.6" version = "1.19.6"
@ -443,6 +453,11 @@ dependencies = [
"pyasn1>=0.3.7", "pyasn1>=0.3.7",
] ]
[[package]]
name = "pytz"
version = "2022.7"
summary = "World timezone definitions, modern and historical"
[[package]] [[package]]
name = "pyyaml" name = "pyyaml"
version = "6.0" version = "6.0"
@ -612,7 +627,7 @@ summary = "Zopfli module for python"
[metadata] [metadata]
lock_version = "4.1" lock_version = "4.1"
content_hash = "sha256:b6e7492191b0ecaef4aafad0b54753f08938080d3556bed56733e51bb1a39c5b" content_hash = "sha256:7c2b758527ac921e68c591216d325c06ebcf7aa3903366e23a02f02c37fd7241"
[metadata.files] [metadata.files]
"asgiref 3.5.2" = [ "asgiref 3.5.2" = [
@ -894,6 +909,10 @@ content_hash = "sha256:b6e7492191b0ecaef4aafad0b54753f08938080d3556bed56733e51bb
{url = "https://files.pythonhosted.org/packages/5f/bb/855748bfc347e6df94cae36a6da0043620e148b3965c33a79e5ad4af7036/django_widget_tweaks-1.4.12-py3-none-any.whl", hash = "sha256:fe6b17d5d595c63331f300917980db2afcf71f240ab9341b954aea8f45d25b9a"}, {url = "https://files.pythonhosted.org/packages/5f/bb/855748bfc347e6df94cae36a6da0043620e148b3965c33a79e5ad4af7036/django_widget_tweaks-1.4.12-py3-none-any.whl", hash = "sha256:fe6b17d5d595c63331f300917980db2afcf71f240ab9341b954aea8f45d25b9a"},
{url = "https://files.pythonhosted.org/packages/ee/68/64437dd92338064d3cd70030df25ee35c2cfee25522d1717de3ee8ed104a/django-widget-tweaks-1.4.12.tar.gz", hash = "sha256:9bfc5c705684754a83cc81da328b39ad1b80f32bd0f4340e2a810cbab4b0c00e"}, {url = "https://files.pythonhosted.org/packages/ee/68/64437dd92338064d3cd70030df25ee35c2cfee25522d1717de3ee8ed104a/django-widget-tweaks-1.4.12.tar.gz", hash = "sha256:9bfc5c705684754a83cc81da328b39ad1b80f32bd0f4340e2a810cbab4b0c00e"},
] ]
"djangorestframework 3.14.0" = [
{url = "https://files.pythonhosted.org/packages/8e/53/5b2a002c5ebafd60dff1e1945a7d63dee40155830997439a9ba324f0fd50/djangorestframework-3.14.0.tar.gz", hash = "sha256:579a333e6256b09489cbe0a067e66abe55c6595d8926be6b99423786334350c8"},
{url = "https://files.pythonhosted.org/packages/ff/4b/3b46c0914ba4b7546a758c35fdfa8e7f017fcbe7f23c878239e93623337a/djangorestframework-3.14.0-py3-none-any.whl", hash = "sha256:eb63f58c9f218e1a7d064d17a70751f528ed4e1d35547fdade9aaf4cd103fd08"},
]
"djlint 1.19.6" = [ "djlint 1.19.6" = [
{url = "https://files.pythonhosted.org/packages/1b/28/e0100f86e5b054ab3c169a612ab2fdca5cfc8ceb92c34420a8ba488de43e/djlint-1.19.6-py3-none-any.whl", hash = "sha256:e7fd305f93057cd205a29999b840210db70789e4cf277625f148447ad7de62b1"}, {url = "https://files.pythonhosted.org/packages/1b/28/e0100f86e5b054ab3c169a612ab2fdca5cfc8ceb92c34420a8ba488de43e/djlint-1.19.6-py3-none-any.whl", hash = "sha256:e7fd305f93057cd205a29999b840210db70789e4cf277625f148447ad7de62b1"},
{url = "https://files.pythonhosted.org/packages/5e/91/7306a912b237e2ea9b347ecd8dc6d0121165b3792eb3d3437aad0e64baf9/djlint-1.19.6.tar.gz", hash = "sha256:a28133317eccc3924b157c947f98f0bdc300f754f51097b5467c73e112aa9fec"}, {url = "https://files.pythonhosted.org/packages/5e/91/7306a912b237e2ea9b347ecd8dc6d0121165b3792eb3d3437aad0e64baf9/djlint-1.19.6.tar.gz", hash = "sha256:a28133317eccc3924b157c947f98f0bdc300f754f51097b5467c73e112aa9fec"},
@ -1100,6 +1119,10 @@ content_hash = "sha256:b6e7492191b0ecaef4aafad0b54753f08938080d3556bed56733e51bb
"python-ldap 3.4.3" = [ "python-ldap 3.4.3" = [
{url = "https://files.pythonhosted.org/packages/3a/7d/de9ae3e5843de77eae3a60c1e70ef5cad9960db50521e8459f7d567a1d1d/python-ldap-3.4.3.tar.gz", hash = "sha256:ab26c519a0ef2a443a2a10391fa3c5cb52d7871323399db949ebfaa9f25ee2a0"}, {url = "https://files.pythonhosted.org/packages/3a/7d/de9ae3e5843de77eae3a60c1e70ef5cad9960db50521e8459f7d567a1d1d/python-ldap-3.4.3.tar.gz", hash = "sha256:ab26c519a0ef2a443a2a10391fa3c5cb52d7871323399db949ebfaa9f25ee2a0"},
] ]
"pytz 2022.7" = [
{url = "https://files.pythonhosted.org/packages/3d/19/4de17f0d5cf5a0d87aa67532d4c2fa75e6e7d8df13c27635ff40fa6f4b76/pytz-2022.7-py2.py3-none-any.whl", hash = "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd"},
{url = "https://files.pythonhosted.org/packages/6d/37/54f2d7c147e42dc85ffbc6910862bb4f141fb3fc14d9a88efaa1a76c7df2/pytz-2022.7.tar.gz", hash = "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a"},
]
"pyyaml 6.0" = [ "pyyaml 6.0" = [
{url = "https://files.pythonhosted.org/packages/02/25/6ba9f6bb50a3d4fbe22c1a02554dc670682a07c8701d1716d19ddea2c940/PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, {url = "https://files.pythonhosted.org/packages/02/25/6ba9f6bb50a3d4fbe22c1a02554dc670682a07c8701d1716d19ddea2c940/PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"},
{url = "https://files.pythonhosted.org/packages/08/f4/ffa743f860f34a5e8c60abaaa686f82c9ac7a2b50e5a1c3b1eb564d59159/PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, {url = "https://files.pythonhosted.org/packages/08/f4/ffa743f860f34a5e8c60abaaa686f82c9ac7a2b50e5a1c3b1eb564d59159/PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"},

View File

@ -21,6 +21,7 @@ dependencies = [
"weasyprint~=57.1", "weasyprint~=57.1",
"requests~=2.27", "requests~=2.27",
"semver~=2.13", "semver~=2.13",
"djangorestframework>=3.14.0",
] ]
requires-python = ">=3.9" requires-python = ">=3.9"