Commit d7df0af4 by benjaoming

pep8 cleanup

parent ed9d853e
...@@ -23,7 +23,10 @@ _cache = {} ...@@ -23,7 +23,10 @@ _cache = {}
@register.assignment_tag(takes_context=True) @register.assignment_tag(takes_context=True)
def article_for_object(context, obj): def article_for_object(context, obj):
if not isinstance(obj, Model): 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) content_type = ContentType.objects.get_for_model(obj)
...@@ -37,6 +40,7 @@ def article_for_object(context, obj): ...@@ -37,6 +40,7 @@ def article_for_object(context, obj):
_cache[obj] = article _cache[obj] = article
return _cache[obj] return _cache[obj]
@register.inclusion_tag('wiki/includes/render.html', takes_context=True) @register.inclusion_tag('wiki/includes/render.html', takes_context=True)
def wiki_render(context, article, preview_content=None): def wiki_render(context, article, preview_content=None):
...@@ -54,6 +58,7 @@ def wiki_render(context, article, preview_content=None): ...@@ -54,6 +58,7 @@ def wiki_render(context, article, preview_content=None):
}) })
return context return context
@register.inclusion_tag('wiki/includes/form.html', takes_context=True) @register.inclusion_tag('wiki/includes/form.html', takes_context=True)
def wiki_form(context, form_obj): def wiki_form(context, form_obj):
if not isinstance(form_obj, BaseForm): if not isinstance(form_obj, BaseForm):
...@@ -61,6 +66,7 @@ def wiki_form(context, form_obj): ...@@ -61,6 +66,7 @@ def wiki_form(context, form_obj):
context.update({'form': form_obj}) context.update({'form': form_obj})
return context return context
@register.filter @register.filter
def get_content_snippet(content, keyword, max_words=30): def get_content_snippet(content, keyword, max_words=30):
max_words = int(max_words) max_words = int(max_words)
...@@ -81,26 +87,31 @@ def get_content_snippet(content, keyword, max_words=30): ...@@ -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]) html = " ".join(filter(lambda x: x!="", striptags(content).replace("\n", " ").split(" "))[:max_words])
return html return html
@register.filter @register.filter
def can_read(obj, user): def can_read(obj, user):
"""Articles and plugins have a can_read method...""" """Articles and plugins have a can_read method..."""
return obj.can_read(user) return obj.can_read(user)
@register.filter @register.filter
def can_write(obj, user): def can_write(obj, user):
"""Articles and plugins have a can_write method...""" """Articles and plugins have a can_write method..."""
return obj.can_write(user) return obj.can_write(user)
@register.filter @register.filter
def can_delete(obj, user): def can_delete(obj, user):
"""Articles and plugins have a can_delete method...""" """Articles and plugins have a can_delete method..."""
return obj.can_delete(user) return obj.can_delete(user)
@register.filter @register.filter
def can_moderate(obj, user): def can_moderate(obj, user):
"""Articles and plugins have a can_moderate method...""" """Articles and plugins have a can_moderate method..."""
return obj.can_moderate(user) return obj.can_moderate(user)
@register.filter @register.filter
def is_locked(obj): def is_locked(obj):
"""Articles and plugins have a can_delete method...""" """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