Skip to content

Commit

Permalink
Update markdown_extensions.py
Browse files Browse the repository at this point in the history
django-wiki#292 fixed
We shouldn't change permission workflow, it's better to put AnonymousUser instead of None in case of unowned article.
Not tested, but should work.

@shoeki, you can try this commit for test
  • Loading branch information
clincher committed Jul 26, 2014
1 parent ba21cc0 commit e5fbd6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wiki/plugins/attachments/markdown_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.core.urlresolvers import reverse
from django.template.context import Context
from django.template.loader import render_to_string
from django.contrib.auth.models import AnonymousUser
from wiki.core.permissions import can_read

ATTACHMENT_RE = re.compile(r'(?P<before>.*)(\[attachment\:(?P<id>\d+)\])(?P<after>.*)', re.IGNORECASE)
Expand Down Expand Up @@ -42,8 +43,12 @@ def run(self, lines):
# I.e. do not insert attachments in other articles that
# the original uploader cannot read, that would be out
# of scope!
attachment_can_read = can_read( self.markdown.article,
attachment.article.owner)
article_owner = attachment.article.owner
if not article_owner:
article_owner = AnonymousUser()

attachment_can_read = can_read(
self.markdown.article, article_owner)
html = render_to_string(
"wiki/plugins/attachments/render.html",
Context({
Expand Down

0 comments on commit e5fbd6b

Please sign in to comment.