mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
pedagogy: support json response from search API
This commit is contained in:
parent
e11d45b51e
commit
2cbef2babc
@ -31,8 +31,10 @@ from django.views.generic import (
|
|||||||
FormView,
|
FormView,
|
||||||
View,
|
View,
|
||||||
)
|
)
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core import serializers
|
||||||
from django.utils import html
|
from django.utils import html
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.core.urlresolvers import reverse_lazy
|
||||||
|
|
||||||
from core.views import (
|
from core.views import (
|
||||||
DetailFormView,
|
DetailFormView,
|
||||||
@ -147,6 +149,17 @@ class UVListView(CanViewMixin, CanCreateUVFunctionMixin, ListView):
|
|||||||
ordering = ["code"]
|
ordering = ["code"]
|
||||||
template_name = "pedagogy/guide.jinja"
|
template_name = "pedagogy/guide.jinja"
|
||||||
|
|
||||||
|
def get(self, *args, **kwargs):
|
||||||
|
if not self.request.GET.get("json", None):
|
||||||
|
# Return normal full template response
|
||||||
|
return super(UVListView, self).get(*args, **kwargs)
|
||||||
|
|
||||||
|
# Return serialized response
|
||||||
|
return HttpResponse(
|
||||||
|
serializers.serialize("json", self.get_queryset()),
|
||||||
|
content_type="application/json",
|
||||||
|
)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
query = self.request.GET.get("query", None)
|
query = self.request.GET.get("query", None)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user