chore: disable the api until it is developed

!1
This commit is contained in:
2024-05-15 11:49:37 +09:30
parent de83d7490b
commit 460f59d889
3 changed files with 58 additions and 31 deletions

View File

@ -158,33 +158,41 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
SITE_TITLE = "Site Title"
REST_FRAMEWORK = {
'PAGE_SIZE': 10,
'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
],
'DEFAULT_PAGINATION_CLASS':
'rest_framework_json_api.pagination.JsonApiPageNumberPagination',
'DEFAULT_PARSER_CLASSES': (
'rest_framework_json_api.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser'
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework_json_api.renderers.JSONRenderer',
'rest_framework_json_api.renderers.BrowsableAPIRenderer',
),
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
'DEFAULT_FILTER_BACKENDS': (
'rest_framework_json_api.filters.QueryParameterValidationFilter',
'rest_framework_json_api.filters.OrderingFilter',
'rest_framework_json_api.django_filters.DjangoFilterBackend',
'rest_framework.filters.SearchFilter',
),
'SEARCH_PARAM': 'filter[search]',
'TEST_REQUEST_RENDERER_CLASSES': (
'rest_framework_json_api.renderers.JSONRenderer',
),
'TEST_REQUEST_DEFAULT_FORMAT': 'vnd.api+json'
}
API_ENABLED = False # Disabled until setup and secure
if API_ENABLED:
INSTALLED_APPS += [
'api.apps.ApiConfig',
]
REST_FRAMEWORK = {
'PAGE_SIZE': 10,
'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
],
'DEFAULT_PAGINATION_CLASS':
'rest_framework_json_api.pagination.JsonApiPageNumberPagination',
'DEFAULT_PARSER_CLASSES': (
'rest_framework_json_api.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser'
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework_json_api.renderers.JSONRenderer',
'rest_framework_json_api.renderers.BrowsableAPIRenderer',
),
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
'DEFAULT_FILTER_BACKENDS': (
'rest_framework_json_api.filters.QueryParameterValidationFilter',
'rest_framework_json_api.filters.OrderingFilter',
'rest_framework_json_api.django_filters.DjangoFilterBackend',
'rest_framework.filters.SearchFilter',
),
'SEARCH_PARAM': 'filter[search]',
'TEST_REQUEST_RENDERER_CLASSES': (
'rest_framework_json_api.renderers.JSONRenderer',
),
'TEST_REQUEST_DEFAULT_FORMAT': 'vnd.api+json'
}

View File

@ -5,6 +5,16 @@ import unittest
class Test_aa_settings_default(unittest.TestCase):
@pytest.mark.django_db
def test_setting_api_disabled_default(self):
""" As the API is only partially developed, it must be disabled.
This test can be removed when the API has been fully developed and functioning as it should.
"""
assert not settings.API_ENABLED
@pytest.mark.django_db
def test_setting_login_required_default(self):
""" By default login should be required
@ -24,6 +34,8 @@ class Test_aa_settings_default(unittest.TestCase):
@pytest.mark.django_db
def test_setting_debug_off(self):
""" Ensure that debug is off within settings by default
Debug is only required during development with this setting must always remain off within the committed code.
"""
assert not settings.DEBUG

View File

@ -23,14 +23,21 @@ from .views import HomeView
urlpatterns = [
path('', HomeView.as_view(), name='home'),
path("api/", include("api.urls")),
path('admin/', admin.site.urls, name='_administration'),
path('account/password_change/', auth_views.PasswordChangeView.as_view(template_name="password_change.html.j2"),
name="change_password"),
path("account/", include("django.contrib.auth.urls")),
path("organization/", include("access.urls")),
path("itam/", include("itam.urls")),
]
if settings.API_ENABLED:
urlpatterns += [
path("api/", include("api.urls")),
]
if settings.DEBUG:
urlpatterns += [