Generated: Tue 2013-05-21 16:43 CEST
Source file: /home/dkaufhold/projects/django-hero-slider/src/hero_slider/views.py
Stats: 10 executed, 0 missed, 4 excluded, 8 ignored
"""Views for the ``hero_slider`` app."""import jsonfrom django.contrib.contenttypes.models import ContentTypefrom django.views.generic import Viewfrom django.http import Http404, HttpResponseclass GetCTypeDetails(View): """Returns the app name for a given content type PK as a JSON response.""" def get(self, request, *args, **kwargs): try: ctype = ContentType.objects.get(pk=request.GET.get('pk')) except ContentType.DoesNotExist: raise Http404 context = { 'app_label': ctype.app_label, 'model': ctype.model, } response_kwargs = {} response_kwargs['content_type'] = 'application/json' return HttpResponse(json.dumps(context), **response_kwargs)