Commit d7df0af4 by benjaoming

pep8 cleanup

parent ed9d853e
......@@ -23,7 +23,10 @@ _cache = {}
@register.assignment_tag(takes_context=True)
def article_for_object(context, obj):
if not isinstance(obj, Model):
raise TypeError("A Wiki article can only be associated to a Django Model instance, not %s" % type(obj))
raise TypeError(
"A Wiki article can only be associated to a Django Model "
"instance, not %s" % type(obj)
)
content_type = ContentType.objects.get_for_model(obj)
......@@ -37,6 +40,7 @@ def article_for_object(context, obj):
_cache[obj] = article
return _cache[obj]
@register.inclusion_tag('wiki/includes/render.html', takes_context=True)
def wiki_render(context, article, preview_content=None):
......@@ -54,6 +58,7 @@ def wiki_render(context, article, preview_content=None):
})
return context
@register.inclusion_tag('wiki/includes/form.html', takes_context=True)
def wiki_form(context, form_obj):
if not isinstance(form_obj, BaseForm):
......@@ -61,6 +66,7 @@ def wiki_form(context, form_obj):
context.update({'form': form_obj})
return context
@register.filter
def get_content_snippet(content, keyword, max_words=30):
max_words = int(max_words)
......@@ -81,26 +87,31 @@ def get_content_snippet(content, keyword, max_words=30):
html = " ".join(filter(lambda x: x!="", striptags(content).replace("\n", " ").split(" "))[:max_words])
return html
@register.filter
def can_read(obj, user):
"""Articles and plugins have a can_read method..."""
return obj.can_read(user)
@register.filter
def can_write(obj, user):
"""Articles and plugins have a can_write method..."""
return obj.can_write(user)
@register.filter
def can_delete(obj, user):
"""Articles and plugins have a can_delete method..."""
return obj.can_delete(user)
@register.filter
def can_moderate(obj, user):
"""Articles and plugins have a can_moderate method..."""
return obj.can_moderate(user)
@register.filter
def is_locked(obj):
"""Articles and plugins have a can_delete method..."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment