From 4215e329549c56d1bcd3ea17bbc8121bfe79d2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 5 Oct 2021 00:00:15 +0200 Subject: [PATCH] Move api do aplikace api --- api/__init__.py | 3 +++ api/apps.py | 5 +++++ api/migrations/__init__.py | 0 api/tests/__init__.py | 1 + .../tests}/test_skola_autocomplete.py | 0 api/urls.py | 19 +++++++++++++++++++ api/views/__init__.py | 2 ++ {seminar => api}/views/autocomplete.py | 0 {seminar => api}/views/exports.py | 0 {seminar => api}/views/helpers.py | 3 ++- mamweb/settings_common.py | 1 + mamweb/urls.py | 3 +++ seminar/urls.py | 13 ------------- seminar/views/__init__.py | 3 --- 14 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 api/__init__.py create mode 100644 api/apps.py create mode 100644 api/migrations/__init__.py create mode 100644 api/tests/__init__.py rename {seminar => api/tests}/test_skola_autocomplete.py (100%) create mode 100644 api/urls.py create mode 100644 api/views/__init__.py rename {seminar => api}/views/autocomplete.py (100%) rename {seminar => api}/views/exports.py (100%) rename {seminar => api}/views/helpers.py (91%) diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 00000000..4c5291cb --- /dev/null +++ b/api/__init__.py @@ -0,0 +1,3 @@ +""" +Obsahuje api = autocomplete + export škol. +""" diff --git a/api/apps.py b/api/apps.py new file mode 100644 index 00000000..d87006dd --- /dev/null +++ b/api/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + name = 'api' diff --git a/api/migrations/__init__.py b/api/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/api/tests/__init__.py b/api/tests/__init__.py new file mode 100644 index 00000000..7a6e81d2 --- /dev/null +++ b/api/tests/__init__.py @@ -0,0 +1 @@ +from .test_skola_autocomplete import * diff --git a/seminar/test_skola_autocomplete.py b/api/tests/test_skola_autocomplete.py similarity index 100% rename from seminar/test_skola_autocomplete.py rename to api/tests/test_skola_autocomplete.py diff --git a/api/urls.py b/api/urls.py new file mode 100644 index 00000000..e869df80 --- /dev/null +++ b/api/urls.py @@ -0,0 +1,19 @@ +from django.urls import path +from . import views +from seminar.utils import org_required + +urlpatterns = [ + # Export škol + path('api/export/skoly/', views.exportSkolView, name='export_skoly'), + + + # Autocomplete + path('api/autocomplete/skola/', views.SkolaAutocomplete.as_view(), name='autocomplete_skola'), + path('api/autocomplete/resitel/', org_required(views.ResitelAutocomplete.as_view()), name='autocomplete_resitel'), + path('api/autocomplete/problem/odevzdatelny', views.OdevzdatelnyProblemAutocomplete.as_view(), name='autocomplete_problem_odevzdatelny'), + + # Ceka na autocomplete v3 + # path('autocomplete/organizatori/', + # org_member_required(views.OrganizatorAutocomplete.as_view()), + # name='seminar_autocomplete_organizator') +] diff --git a/api/views/__init__.py b/api/views/__init__.py new file mode 100644 index 00000000..fc00554e --- /dev/null +++ b/api/views/__init__.py @@ -0,0 +1,2 @@ +from .autocomplete import * +from .exports import * diff --git a/seminar/views/autocomplete.py b/api/views/autocomplete.py similarity index 100% rename from seminar/views/autocomplete.py rename to api/views/autocomplete.py diff --git a/seminar/views/exports.py b/api/views/exports.py similarity index 100% rename from seminar/views/exports.py rename to api/views/exports.py diff --git a/seminar/views/helpers.py b/api/views/helpers.py similarity index 91% rename from seminar/views/helpers.py rename to api/views/helpers.py index 0b06c0eb..652344bc 100644 --- a/seminar/views/helpers.py +++ b/api/views/helpers.py @@ -1,4 +1,5 @@ -from dal import autocomplete +from django.http import JsonResponse + class LoginRequiredAjaxMixin(object): def dispatch(self, request, *args, **kwargs): diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 8f49375d..2b45663a 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -136,6 +136,7 @@ INSTALLED_APPS = ( 'header_fotky', 'various', 'various.autentizace', + 'api', # Admin upravy: diff --git a/mamweb/urls.py b/mamweb/urls.py index a9acedac..0989257d 100644 --- a/mamweb/urls.py +++ b/mamweb/urls.py @@ -26,6 +26,9 @@ urlpatterns = [ # Autentizační aplikace (ma vlastni podadresare) path('', include('various.autentizace.urls')), + # Api (ma vlastni podadresare) (autocomplete apod.) + path('', include('api.urls')), + # Comments (interni i verejne) path('comments_dj/', include('django_comments.urls')), path('comments_fl/', include('fluent_comments.urls')), diff --git a/seminar/urls.py b/seminar/urls.py index eee9511f..b9a798f3 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -144,14 +144,6 @@ urlpatterns = [ # Obecný view na profil -- orgům dá rozcestník, řešitelům jejich stránku path('profil/', views.profilView, name='profil'), - # Autocomplete - path('api/autocomplete/skola/',views.SkolaAutocomplete.as_view(), name='autocomplete_skola'), - path('api/autocomplete/resitel/', org_required(views.ResitelAutocomplete.as_view()), name='autocomplete_resitel'), - path('api/autocomplete/problem/odevzdatelny',views.OdevzdatelnyProblemAutocomplete.as_view(), name='autocomplete_problem_odevzdatelny'), - - # Export škol - path('api/export/skoly/', views.exportSkolView, name='export_skoly'), - path('org/add_solution', org_required(views.AddSolutionView.as_view()), name='seminar_vloz_reseni'), path('resitel/nahraj_reseni', resitel_required(views.NahrajReseniView.as_view()), name='seminar_nahraj_reseni'), @@ -161,11 +153,6 @@ urlpatterns = [ path('', views.TitulniStranaView.as_view(), name='titulni_strana'), path('jak-resit/', views.JakResitView.as_view(), name='jak_resit'), - # Ceka na autocomplete v3 - # path('autocomplete/organizatori/', - # org_member_required(views.OrganizatorAutocomplete.as_view()), - # name='seminar_autocomplete_organizator') - path('org/reseni/', org_required(views.TabulkaOdevzdanychReseniView.as_view()), name='odevzdavatko_tabulka'), path('org/reseni/rocnik//', org_required(views.TabulkaOdevzdanychReseniView.as_view()), name='odevzdavatko_tabulka'), path('org/reseni///', org_required(views.ReseniProblemuView.as_view()), name='odevzdavatko_reseni_resitele_k_problemu'), diff --git a/seminar/views/__init__.py b/seminar/views/__init__.py index f84d99d7..785102e5 100644 --- a/seminar/views/__init__.py +++ b/seminar/views/__init__.py @@ -1,9 +1,6 @@ from .views_all import * -from .autocomplete import * from .views_rest import * from .odevzdavatko import * -from .exports import * - # Dočsasné views from .docasne import *