Test coverage report: hero_slider.views

# hero_slider.views: 14 total statements, 100.0% covered

Generated: Thu 2013-04-18 14:15 SGT

Source file: /Users/martin/Repos/django-hero-slider/hero_slider/views.py

Stats: 10 executed, 0 missed, 4 excluded, 8 ignored

1. `"""Views for the ``hero_slider`` app."""`
2. `import json`
3. ``
4. `from django.contrib.contenttypes.models import ContentType`
5. `from django.views.generic import View`
6. `from django.http import Http404, HttpResponse`
7. ``
8. ``
9. `class GetCTypeDetails(View):`
10. `"""Returns the app name for a given content type PK as a JSON response."""`
11. `def get(self, request, *args, **kwargs):`
12. `try:`
13. `ctype = ContentType.objects.get(pk=request.GET.get('pk'))`
14. `except ContentType.DoesNotExist:`
15. `raise Http404`
16. `context = {`
17. `'app_label': ctype.app_label,`
18. `'model': ctype.model,`
19. `}`
20. `response_kwargs = {}`
21. `response_kwargs['content_type'] = 'application/json'`
22. `return HttpResponse(json.dumps(context), **response_kwargs)`