Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: backend template #123

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
53 changes: 51 additions & 2 deletions codeforlife/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_databases(base_dir: Path): # pragma: no cover
# URLs
# https://docs.djangoproject.com/en/3.2/ref/settings/#root-urlconf

ROOT_URLCONF = "src.urls"
ROOT_URLCONF = "api.urls"

# App
# https://docs.djangoproject.com/en/3.2/ref/settings/#wsgi-application
Expand Down Expand Up @@ -183,9 +183,58 @@ def get_databases(base_dir: Path): # pragma: no cover
# https://docs.djangoproject.com/en/3.2/ref/settings/#installed-apps

INSTALLED_APPS = [
"src.api",
"django.contrib.admin",
"django.contrib.admindocs",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.sites",
"django.contrib.staticfiles",
"aimmo", # TODO: remove
"game", # TODO: remove
"portal", # TODO: remove
"common", # TODO: remove
"api",
"codeforlife.user",
"corsheaders",
"rest_framework",
"django_filters",
]

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/


def get_static_root(base_dir: Path):
"""Get the static root for the Django project.

Args:
base_dir: The base directory of the Django project.

Returns:
The static root for the django project.
"""
return base_dir / "static"


STATIC_URL = "/static/"

# Templates
# https://docs.djangoproject.com/en/3.2/ref/templates/

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",
],
},
},
]
6 changes: 0 additions & 6 deletions codeforlife/tests/model_view_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ def list(
"""
# pylint: enable=line-too-long

assert self._model_class.objects.difference(
self._model_class.objects.filter(
pk__in=[model.pk for model in models]
)
).exists(), "List must exclude some models for a valid test."

response: Response = self.get(
(
self._test_case.reverse_action("list", kwargs=reverse_kwargs)
Expand Down
4 changes: 2 additions & 2 deletions codeforlife/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def get_urlpatterns(
api_urls_path: str = "src.api.urls",
api_url_patterns: UrlPatterns,
include_user_urls: bool = True,
) -> UrlPatterns:
"""Generate standard url patterns for each service.
Expand Down Expand Up @@ -61,7 +61,7 @@ def get_urlpatterns(
),
path(
"api/",
include(api_urls_path),
include(api_url_patterns),
name="api",
),
]
Expand Down
Loading