Generalize the Javascript menu rendering into an API for templates that only refresh the menu when there are changes. Closes GitLab issue #511. Thanks to Daniel Carrico @daniel1113 for the report.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -4,7 +4,8 @@ from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from rest_framework import generics
|
||||
|
||||
from .serializers import ContentTypeSerializer
|
||||
from .classes import Template
|
||||
from .serializers import ContentTypeSerializer, TemplateSerializer
|
||||
|
||||
|
||||
class APIContentTypeList(generics.ListAPIView):
|
||||
@@ -13,3 +14,14 @@ class APIContentTypeList(generics.ListAPIView):
|
||||
"""
|
||||
serializer_class = ContentTypeSerializer
|
||||
queryset = ContentType.objects.order_by('app_label', 'model')
|
||||
|
||||
|
||||
class APITemplateView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Returns the selected partial template details.
|
||||
get: Retrieve the details of the partial template.
|
||||
"""
|
||||
serializer_class = TemplateSerializer
|
||||
|
||||
def get_object(self):
|
||||
return Template.get(self.kwargs['name']).render(request=self.request)
|
||||
|
||||
Reference in New Issue
Block a user