Skip to content

Commit

Permalink
Direct api calls (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmihalik authored Dec 19, 2024
1 parent 6cd65a3 commit 5fa0fa5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
4 changes: 2 additions & 2 deletions cms/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class TestPosts(APITestCase, PermissionTestMixin):
'''cms/post'''

URL_PREFIX = '/cms/post'
URL_PREFIX = '/api/cms/post'

fixtures = get_app_fixtures([
'base',
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions competition/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions personal/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
9 changes: 6 additions & 3 deletions webstrom/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]

Expand Down Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions webstrom/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 10 additions & 5 deletions webstrom/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 5fa0fa5

Please sign in to comment.