diff --git a/seminar/urls.py b/seminar/urls.py index ddd46d00..141453c7 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -158,6 +158,9 @@ urlpatterns = [ 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'), diff --git a/seminar/views/__init__.py b/seminar/views/__init__.py index 163f2535..f84d99d7 100644 --- a/seminar/views/__init__.py +++ b/seminar/views/__init__.py @@ -3,5 +3,7 @@ from .autocomplete import * from .views_rest import * from .odevzdavatko import * +from .exports import * + # Dočsasné views from .docasne import * diff --git a/seminar/views/exports.py b/seminar/views/exports.py new file mode 100644 index 00000000..6df7d32b --- /dev/null +++ b/seminar/views/exports.py @@ -0,0 +1,15 @@ +import seminar.models as m +from django.core import serializers as ser +from django.http import HttpResponse +def exportSkolView(request): + # Některé fieldy nechceme: Kontaktní osoby, AESOP ID, org poznámky. + fields = ('id', 'izo', 'nazev', 'kratky_nazev', 'ulice', 'mesto', 'psc', 'stat', 'je_zs', 'je_ss') + # TODO: Použít JSONL, aby protistrana mohla číst po řádkách a nesežralo to tunu paměti úplně hned + skoly_json = ser.serialize("json", m.Skola.objects.all(), fields=fields) + response = HttpResponse( + content = skoly_json, + content_type = 'text/json', + reason = 'Here you go', # :-) + ) + return(response) +