Permalink
Browse files

remove TemplateMimeTypeView mixin since TemplateView handle the conte…

…nt_type in paramaters
  • Loading branch information...
1 parent 115d180 commit 5ec7e57ba314c38ed0dfc2e90126df94575b6a91 @Fantomas42 committed Mar 16, 2013
Showing with 9 additions and 45 deletions.
  1. +0 −10 zinnia/tests/mixins.py
  2. +6 −6 zinnia/views/capabilities.py
  3. +0 −26 zinnia/views/mixins/mimetypes.py
  4. +3 −3 zinnia/views/trackback.py
View
@@ -10,7 +10,6 @@
from zinnia.models.category import Category
from zinnia.managers import PUBLISHED
from zinnia.tests.utils import datetime
-from zinnia.views.mixins.mimetypes import MimeTypeMixin
from zinnia.views.mixins.archives import PreviousNextPublishedMixin
from zinnia.views.mixins.callable_queryset import CallableQuerysetMixin
from zinnia.views.mixins.prefetch_related import PrefetchRelatedMixin
@@ -36,15 +35,6 @@ def qs():
self.assertEquals(instance.get_queryset(),
[])
- def test_mimetype_mixin(self):
- instance = MimeTypeMixin()
- self.assertRaises(ImproperlyConfigured,
- instance.get_mimetype)
-
- instance.mimetype = 'mimetype'
- self.assertEquals(instance.get_mimetype(),
- 'mimetype')
-
def test_entry_queryset_template_response_mixin(self):
instance = EntryQuerysetTemplateResponseMixin()
self.assertRaises(ImproperlyConfigured,
@@ -1,13 +1,13 @@
"""Views for Zinnia capabilities"""
from django.contrib.sites.models import Site
+from django.views.generic.base import TemplateView
from zinnia.settings import PROTOCOL
from zinnia.settings import COPYRIGHT
from zinnia.settings import FEEDS_FORMAT
-from zinnia.views.mixins.mimetypes import TemplateMimeTypeView
-class CapabilityView(TemplateMimeTypeView):
+class CapabilityView(TemplateView):
"""Base view for the weblog capabilities"""
def get_context_data(self, **kwargs):
@@ -25,29 +25,29 @@ class HumansTxt(CapabilityView):
"""
http://humanstxt.org/
"""
- mimetype = 'text/plain'
+ content_type = 'text/plain'
template_name = 'zinnia/humans.txt'
class RsdXml(CapabilityView):
"""
http://en.wikipedia.org/wiki/Really_Simple_Discovery
"""
- mimetype = 'application/rsd+xml'
+ content_type = 'application/rsd+xml'
template_name = 'zinnia/rsd.xml'
class WLWManifestXml(CapabilityView):
"""
http://msdn.microsoft.com/en-us/library/bb463260.aspx
"""
- mimetype = 'application/wlwmanifest+xml'
+ content_type = 'application/wlwmanifest+xml'
template_name = 'zinnia/wlwmanifest.xml'
class OpenSearchXml(CapabilityView):
"""
http://www.opensearch.org/
"""
+ content_type = 'application/opensearchdescription+xml'
template_name = 'zinnia/opensearch.xml'
- mimetype = 'application/opensearchdescription+xml'
@@ -1,26 +0,0 @@
-"""MimeType mixins for Zinnia views"""
-from django.views.generic.base import TemplateView
-from django.core.exceptions import ImproperlyConfigured
-
-
-class MimeTypeMixin(object):
- """Mixin for handling the mimetype parameter"""
- mimetype = None
-
- def get_mimetype(self):
- """Return the mimetype of the response"""
- if self.mimetype is None:
- raise ImproperlyConfigured(
- u"%s requires either a definition of "
- "'mimetype' or an implementation of 'get_mimetype()'" %
- self.__class__.__name__)
- return self.mimetype
-
-
-class TemplateMimeTypeView(MimeTypeMixin, TemplateView):
- """TemplateView with a configurable mimetype"""
-
- def render_to_response(self, context, **kwargs):
- """Render the view with a custom mimetype"""
- return super(TemplateMimeTypeView, self).render_to_response(
- context, mimetype=self.get_mimetype(), **kwargs)
@@ -2,6 +2,7 @@
from django.contrib import comments
from django.contrib.sites.models import Site
from django.shortcuts import get_object_or_404
+from django.views.generic.base import TemplateView
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
from django.http import HttpResponsePermanentRedirect
@@ -11,12 +12,11 @@
from zinnia.flags import TRACKBACK
from zinnia.flags import get_user_flagger
from zinnia.signals import trackback_was_posted
-from zinnia.views.mixins.mimetypes import TemplateMimeTypeView
-class EntryTrackback(TemplateMimeTypeView):
+class EntryTrackback(TemplateView):
"""View for handling trackbacks on the entries"""
- mimetype = 'text/xml'
+ content_type = 'text/xml'
template_name = 'zinnia/entry_trackback.xml'
@method_decorator(csrf_exempt)

0 comments on commit 5ec7e57

Please sign in to comment.