mirror of
https://github.com/ae-utbm/sith.git
synced 2024-10-31 19:38:04 +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,
|
||||
View,
|
||||
)
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.core import serializers
|
||||
from django.utils import html
|
||||
from django.http import HttpResponse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
|
||||
from core.views import (
|
||||
DetailFormView,
|
||||
@ -147,6 +149,17 @@ class UVListView(CanViewMixin, CanCreateUVFunctionMixin, ListView):
|
||||
ordering = ["code"]
|
||||
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):
|
||||
query = self.request.GET.get("query", None)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user