Skip to content
Merged

Apis #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies = [
"drf-flex-fields",
"drf-spectacular",
"drf-renderer-xlsx",
"whitenoise",
]
description = "Spokane Python Community"
dynamic = ["version"]
Expand Down Expand Up @@ -44,7 +45,6 @@ dev = [
docker = [
"gunicorn",
"psycopg2-binary",
"whitenoise",
]


Expand All @@ -64,11 +64,11 @@ show_missing = true
branch = true
source = ["src/django_project"]
omit = [
"django_project/manage.py",
"django_project/core/asgi.py",
"django_project/core/wsgi.py",
"django_project/*/scripts/*",
"django_project/tests/*",
"src/django_project/manage.py",
"src/django_project/core/asgi.py",
"src/django_project/core/wsgi.py",
"src/django_project/*/scripts/*",
"src/django_project/tests/*",
]


Expand Down Expand Up @@ -97,7 +97,13 @@ filterwarnings = [

[tool.ruff]
line-length = 120
exclude = ["django_project/manage.py", "django_project/tests", "django_project/*/migrations", "django_project/*/scripts", "django_project/*/local_test"]
exclude = [
"src/django_project/manage.py",
"src/django_project/tests",
"src/django_project/*/migrations",
"src/django_project/*/scripts",
"src/django_project/*/local_test"
]


[tool.setuptools.packages.find]
Expand Down
11 changes: 7 additions & 4 deletions src/django_project/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
BASE_DIR = Path(__file__).resolve().parent.parent


ENV_PATH = os.environ.get("ENV_PATH", f"{BASE_DIR.parent}/envs/.env.local")
# ENV_PATH = os.environ.get("ENV_PATH", f"{BASE_DIR.parent}/envs/.env.local")
ENV_PATH = os.environ.get("ENV_PATH")
# now load the contents of the defined .env file
env = environ.Env()
if os.path.exists(ENV_PATH):
if ENV_PATH and os.path.exists(ENV_PATH):
print(f"loading ENV vars from {ENV_PATH}")
environ.Env.read_env(ENV_PATH)
else:
Expand All @@ -37,7 +38,7 @@
SECRET_KEY = env.str("SECRET_KEY", "default_key-this_is_insecure_and_should_be_changed")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("DEBUG", True)
DEBUG = env.bool("DEBUG", False)
DEPLOYMENT_ENV = env.str("DEPLOYMENT_ENV", "local")


Expand Down Expand Up @@ -268,7 +269,9 @@
# drf configuration
REST_FRAMEWORK = {
"DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticatedOrReadOnly",),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticatedOrReadOnly",)
if DEBUG
else ("rest_framework.permissions.IsAuthenticated",),
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.TokenAuthentication",
"rest_framework.authentication.SessionAuthentication",
Expand Down
14 changes: 11 additions & 3 deletions src/django_project/core/urls/rest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
from django.conf.urls import include
from django.urls import path
from rest_framework import routers
from web.views import viewsets

app_name = "rest"

v1_router = routers.DefaultRouter()
router = routers.DefaultRouter()

# web API Endpoints
router.register(r"event", viewsets.EventViewSet, "event")
router.register(r"presentationrequest", viewsets.PresentationRequestViewSet, "presentationrequest")
router.register(r"resource", viewsets.ResourceViewSet, "resource")
router.register(r"resourcecategory", viewsets.ResourceCategoryViewSet, "resourcecategory")
router.register(r"topicsuggestion", viewsets.TopicSuggestionViewSet, "topicsuggestion")


urlpatterns = [
# API views
path("", include(v1_router.urls)),
path("v1/", include(v1_router.urls)),
path("", include(router.urls)),
path("v1/", include(router.urls)),
]
2 changes: 1 addition & 1 deletion src/django_project/core/urls/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# 3rd party URLs
path("handyhelpers/", include("handyhelpers.urls")),
# RESTful API URLs
path("rest/", include("core.urls.rest", namespace="rest")),
path("rest/", include("core.urls.rest", namespace="")),
path("rest/schema/", SpectacularAPIView.as_view(), name="schema"),
path("rest/swagger/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger"),
path("rest/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"),
Expand Down
1 change: 1 addition & 0 deletions src/django_project/tests/unit/web/test_model_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

BASE_DIR = Path(__file__).parents[4]
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
os.environ.setdefault("ENV_PATH", "../envs/.env.test")
django.setup()
from model_bakery import baker # noqa: E402

Expand Down
Loading