diff --git a/cms/tests.py b/cms/tests.py index ec48d22..2e5c44b 100644 --- a/cms/tests.py +++ b/cms/tests.py @@ -6,7 +6,7 @@ class TestPosts(APITestCase, PermissionTestMixin): '''cms/post''' - URL_PREFIX = '/cms/post' + URL_PREFIX = '/api/cms/post' fixtures = get_app_fixtures([ 'base', @@ -55,7 +55,7 @@ def test_get_response_format(self): class TestMenuItems(APITestCase, PermissionTestMixin): '''cms/menu-item''' - URL_PREFIX = '/cms/menu-item' + URL_PREFIX = '/api/cms/menu-item' fixtures = get_app_fixtures([ 'base', diff --git a/competition/tests.py b/competition/tests.py index 4b41acb..9993e6f 100644 --- a/competition/tests.py +++ b/competition/tests.py @@ -81,7 +81,7 @@ def semester_assert_format(self, semester): class TestSeries(APITestCase, PermissionTestMixin): '''competition/series''' - URL_PREFIX = '/competition/series' + URL_PREFIX = '/api/competition/series' fixtures = get_app_fixtures([ 'base', @@ -146,7 +146,7 @@ def test_permission_create(self): class TestSemester(APITestCase, PermissionTestMixin): '''competition/semester''' - URL_PREFIX = '/competition/semester' + URL_PREFIX = '/api/competition/semester' fixtures = get_app_fixtures([ 'base', @@ -208,7 +208,7 @@ def test_staff_only_points_permissions(self): class TestAPISemester(APITestCase, PermissionTestMixin): '''competition/semester - Create all''' - URL_PREFIX = '/competition/semester/' + URL_PREFIX = '/api/competition/semester/' fixtures = PermissionTestMixin.get_basic_fixtures() def setUp(self): @@ -240,7 +240,7 @@ def test_create_semester(self): class TestCompetition(APITestCase, PermissionTestMixin): '''competition/competition''' - URL_PREFIX = '/competition/competition' + URL_PREFIX = '/api/competition/competition' fixtures = PermissionTestMixin.get_basic_fixtures() @@ -324,7 +324,7 @@ def test_permission_create(self): class TestSolution(APITestCase, PermissionTestMixin): '''competition/solution''' - URL_PREFIX = '/competition/solution' + URL_PREFIX = '/api/competition/solution' fixtures = get_app_fixtures([ 'base', diff --git a/personal/tests.py b/personal/tests.py index 3e02871..4065639 100644 --- a/personal/tests.py +++ b/personal/tests.py @@ -48,7 +48,7 @@ def setUp(self): County.objects.create(name="Prešovský kraj"), County.objects.create(name="Bratislavský kraj")] - URL_PREFIX = '/personal/counties' + URL_PREFIX = '/api/personal/counties' def test_can_browse_all_counties(self): response = self.client.get(self.URL_PREFIX, {}, 'json') @@ -91,7 +91,7 @@ def setUp(self): name="Rožňava", county=county1), District.objects.create(name="Sabinov", county=county2)] - URL_PREFIX = '/personal/districts' + URL_PREFIX = '/api/personal/districts' def test_can_browse_all_districts(self): response = self.client.get(self.URL_PREFIX, {}, 'json') @@ -211,7 +211,7 @@ def setUp(self): ) ] - URL_PREFIX = '/personal/schools' + URL_PREFIX = '/api/personal/schools' def test_can_browse_all_schools(self): response = self.client.get(self.URL_PREFIX, {}, 'json') diff --git a/webstrom/settings.py b/webstrom/settings.py index da4af46..f5b3944 100644 --- a/webstrom/settings.py +++ b/webstrom/settings.py @@ -60,6 +60,7 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.common.BrokenLinkEmailsMiddleware', 'allauth.account.middleware.AccountMiddleware', ] @@ -165,19 +166,21 @@ USE_TZ = True DATETIME_FORMAT = 'd.m.Y H:i:s' + +API_PREFIX = 'api/' + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_ROOT = os.path.join(BASE_DIR, 'static') -STATIC_URL = '/static/' - +STATIC_URL = 'static/' # Media files MEDIA_ROOT = os.path.join(BASE_DIR, 'media') -MEDIA_URL = '/media/' +MEDIA_URL = 'media/' PRIVATE_STORAGE_ROOT = os.path.join(BASE_DIR, 'protected_media/') SENDFILE_ROOT = PRIVATE_STORAGE_ROOT SENDFILE_BACKEND = "django_sendfile.backends.simple" diff --git a/webstrom/settings_test.py b/webstrom/settings_test.py index 478dbfc..0531638 100644 --- a/webstrom/settings_test.py +++ b/webstrom/settings_test.py @@ -5,14 +5,9 @@ DEBUG = False ALLOWED_HOSTS = [ - "localhost", "test.strom.sk", ] -CSRF_TRUSTED_ORIGINS = [ - "https://test.strom.sk", -] - USE_X_FORWARDED_HOST = True SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") diff --git a/webstrom/urls.py b/webstrom/urls.py index 5a51983..ed938ae 100644 --- a/webstrom/urls.py +++ b/webstrom/urls.py @@ -3,19 +3,24 @@ from django.contrib import admin from django.urls import include, path -urlpatterns = [ - path('django-admin/', admin.site.urls), +api_urlpatterns = [ path('user/', include('user.urls')), path('competition/', include('competition.urls')), path('cms/', include('cms.urls')), path('personal/', include('personal.urls')), path('base/', include('base.urls')), path('protected/', include('downloads.urls')), - # Dočasná cesta pre allauth bez rest frameworku +] + +urlpatterns = [ path('accounts/', include('allauth.urls')), + path('django-admin/', admin.site.urls), + path(settings.API_PREFIX, include(api_urlpatterns)), ] # Pri vývoji servuj media files priamo z djanga if settings.DEBUG: - urlpatterns += static(settings.MEDIA_URL, - document_root=settings.MEDIA_ROOT) + urlpatterns += static( + settings.MEDIA_URL, + document_root=settings.MEDIA_ROOT + )