Browse files

removed unneeded imports

removed unneeded manager
  • Loading branch information...
1 parent 7d4418f commit d675a615e4d190bc0c5583af3641e491848f0c5e Jonas Obrist committed Dec 31, 2010
Showing with 0 additions and 71 deletions.
  1. +0 −67 cms/plugins/text/managers.py
  2. +0 −4 cms/plugins/text/models.py
View
67 cms/plugins/text/managers.py
@@ -1,67 +0,0 @@
-from django.db import models
-from django.conf import settings
-
-class ContentManager(models.Manager):
-
- def sanitize(self, content):
- """
- Sanitize the content to avoid XSS and so
- """
- import html5lib
- from html5lib import sanitizer
- p = html5lib.HTMLParser(tokenizer=sanitizer.HTMLSanitizer)
- # we need to remove <html><head/><body>...</body></html>
- return p.parse(content).toxml()[19:-14]
-
- def set_or_create_content(self, page, language, cnttype, body):
- """
- set or create a content for a particular page and language
- """
- if settings.CMS_SANITIZE_USER_INPUT:
- body = self.sanitize(body)
- try:
- content = self.filter(page=page, language=language,
- type=cnttype).latest('creation_date')
- content.body = body
- except self.model.DoesNotExist:
- content = self.model(page=page, language=language, body=body,
- type=cnttype)
- content.save()
- return content
-
-
- # TODO: probably not used anymore after django-revision integration
- def create_content_if_changed(self, page, language, cnttype, body):
- """
- set or create a content for a particular page and language
- """
- if settings.CMS_SANITIZE_USER_INPUT:
- body = self.sanitize(body)
- try:
- content = self.filter(page=page, language=language,
- type=cnttype).latest('creation_date')
- if content.body == body:
- return content
- except self.model.DoesNotExist:
- pass
- content = self.create(page=page, language=language, body=body, type=cnttype)
-
- def get_content(self, page, language, cnttype, language_fallback=False,
- latest_by='creation_date'):
- """
- Gets the latest content for a particular page and language. Falls back
- to another language if wanted.
- """
- try:
- content = self.filter(language=language, page=page,
- type=cnttype).latest(latest_by)
- return content.body
- except self.model.DoesNotExist:
- pass
- if language_fallback:
- try:
- content = self.filter(page=page, type=cnttype).latest(latest_by)
- return content.body
- except self.model.DoesNotExist:
- pass
- return None
View
4 cms/plugins/text/models.py
@@ -1,15 +1,11 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from cms.models import CMSPlugin
-from django.conf import settings
from django.utils.html import strip_tags
from django.utils.text import truncate_words
from cms.plugins.text.utils import plugin_admin_html_to_tags,\
plugin_tags_to_admin_html, plugin_tags_to_id_list,\
replace_plugin_tags
-from cms.models.pluginmodel import PluginModelBase
-from cms.plugin_base import PluginMediaDefiningClass
-from django.db.models.base import ModelBase
_old_tree_cache = {}

0 comments on commit d675a61

Please sign in to comment.