def __before__(self, event): RedditController.__before__(self) if event: try: c.liveupdate_event = LiveUpdateEvent._byID(event) except tdb_cassandra.NotFound: pass if not c.liveupdate_event: self.abort404() if c.user_is_loggedin: c.liveupdate_permissions = \ c.liveupdate_event.get_permissions(c.user) # revoke some permissions from everyone after closing if c.liveupdate_event.state != "live": c.liveupdate_permissions = (c.liveupdate_permissions .without("update") .without("close") ) if c.user_is_admin: c.liveupdate_permissions = ContributorPermissionSet.SUPERUSER else: c.liveupdate_permissions = ContributorPermissionSet.NONE
def __before__(self): try: c.error_page = True RedditController.__before__(self) except (HTTPMovedPermanently, HTTPFound): # ignore an attempt to redirect from an error page pass except: handle_awful_failure("Error occurred in ErrorController.__before__")
def __before__(self): try: c.error_page = True RedditController.__before__(self) except (HTTPMovedPermanently, HTTPFound): # ignore an attempt to redirect from an error page pass except Exception as e: handle_awful_failure("ErrorController.__before__: %r" % e)
def __before__(self): try: c.error_page = True RedditController.__before__(self) except (HTTPMovedPermanently, HTTPFound): # ignore an attempt to redirect from an error page pass except Exception as e: handle_awful_failure("ErrorController.__before__: %r" % e) # c.error_page is special-cased in a couple places to bypass # c.site checks. We shouldn't allow the user to get here other # than through `middleware.py:error_mapper`. if not request.environ.get('pylons.error_call'): abort(403, "direct access to error controller disallowed")
def __before__(self, event): RedditController.__before__(self) if event: try: c.liveupdate_event = LiveUpdateEvent._byID(event) except tdb_cassandra.NotFound: pass if not c.liveupdate_event: self.abort404() c.liveupdate_can_manage = (c.liveupdate_event.state == "live" and (c.user_is_loggedin and c.user_is_admin)) c.liveupdate_can_edit = (c.liveupdate_event.state == "live" and (c.user_is_loggedin and (c.liveupdate_event.is_editor(c.user) or c.user_is_admin)))
def __before__(self, event): RedditController.__before__(self) if event: try: c.liveupdate_event = LiveUpdateEvent._byID(event) except tdb_cassandra.NotFound: pass if not c.liveupdate_event: self.abort404() if c.user_is_loggedin: c.liveupdate_permissions = \ c.liveupdate_event.get_permissions(c.user) # revoke some permissions from everyone after closing if c.liveupdate_event.state != "live": c.liveupdate_permissions = (c.liveupdate_permissions .without("update") .without("close") ) if c.user_is_admin: c.liveupdate_permissions = ContributorPermissionSet.SUPERUSER else: c.liveupdate_permissions = ContributorPermissionSet.NONE if c.liveupdate_event.banned and not c.liveupdate_permissions: error_page = RedditError( title=_("this thread has been banned"), message="", image="subreddit-banned.png", ) request.environ["usable_error_content"] = error_page.render() self.abort403() if (c.liveupdate_event.nsfw and not c.over18 and request.host != g.media_domain and # embeds are special c.render_style == "html"): return self.intermediate_redirect("/over18", sr_path=False)