Skip to content

Commit

Permalink
Wiki: Remove c.page_obj
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-d committed Sep 13, 2012
1 parent 7522c7c commit 1eaa38f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions r2/r2/controllers/validator/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ def run(self, page):
except AbortWikiError:
return

# TODO: MAKE NOT REQUIRED
c.wiki_page_obj = wp
c.wiki_may_revise = this_may_revise(wp)

return wp

Expand Down Expand Up @@ -283,7 +282,7 @@ def run(self, page, previous=None):
return
if not wp:
return self.set_error('INVALID_PAGE', code=404)
if not this_may_revise(wp):
if not c.wiki_may_revise:
return self.set_error('MAY_NOT_REVISE', code=403)
if previous:
try:
Expand Down Expand Up @@ -320,7 +319,7 @@ def run(self, page):
c.error = {'reason': 'PAGE_NAME_MAX_SEPARATORS', 'MAX_SEPARATORS': MAX_SEPARATORS}
elif len(page) > MAX_PAGE_NAME_LENGTH:
c.error = {'reason': 'PAGE_NAME_LENGTH', 'max_length': MAX_PAGE_NAME_LENGTH}
return this_may_revise()
return c.wiki_may_revise

def param_docs(self):
return {
Expand Down
5 changes: 2 additions & 3 deletions r2/r2/lib/pages/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def __init__(self, content, edit_by, edit_date, diff=None):
self.edit_by = edit_by
self.edit_date = edit_date
self.base_url = c.wiki_base_url
self.may_revise = this_may_revise(c.wiki_page_obj)
Templated.__init__(self)

class WikiPageListing(Templated):
Expand Down Expand Up @@ -69,7 +68,7 @@ def __init__(self, content, actionless=False, alert=None, **context):
if not actionless and c.wiki_page:
title = '%s - %s' % (title, c.wiki_page)
pageactions += [(c.wiki_page, _("view"), False)]
if this_may_revise(c.wiki_page_obj):
if c.wiki_may_revise:
pageactions += [('edit', _("edit"), True)]
pageactions += [('revisions/%s' % c.wiki_page, _("history"), False)]
pageactions += [('discussions', _("talk"), True)]
Expand All @@ -90,7 +89,7 @@ def __init__(self, content, actionless=False, alert=None, **context):
class WikiPageView(WikiBase):
def __init__(self, content, diff=None, **context):
if not content and not context.get('alert'):
if this_may_revise(c.wiki_page_obj):
if c.wiki_may_revise:
context['alert'] = _("this page is empty, edit it to add some content.")
content = WikiView(content, context.get('edit_by'), context.get('edit_date'), diff=diff)
WikiBase.__init__(self, content, **context)
Expand Down

3 comments on commit 1eaa38f

@chromakode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this_may_revise and may_revise? Does anything else use may_revise?

@andre-d
Copy link
Owner Author

@andre-d andre-d commented on 1eaa38f Sep 17, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chromakode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks.

Please sign in to comment.