def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = {"user_bundle": self.user_bundle} self.response.headers[ 'Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0'
def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) if type(self.request) == webapp2.Request: trace_context.request = self.request self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } self.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' self.response.headers['Vary'] = 'Accept-Encoding' self.response.headers['X-Robots-Tag'] = 'noindex'
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } self.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, target_url="/"): if not self.user_bundle.user: return self.redirect( self.user_bundle.create_login_url(target_url), abort=True ) def _require_registration(self, target_url="/"): if not self.user_bundle.account.registered: return self.redirect( target_url, abort=True )
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = {"user_bundle": self.user_bundle} self.response.headers[ 'Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, target_url="/"): if not self.user_bundle.user: return self.redirect(self.user_bundle.create_login_url(target_url), abort=True) def _require_registration(self, target_url="/"): if not self.user_bundle.account.registered: return self.redirect(target_url, abort=True)
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } self.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' self.response.headers['Vary'] = 'Accept-Encoding' def _get_login_url(self, target_url): return self.user_bundle.create_login_url(target_url) def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, redirect_url=None): import urllib if not self.user_bundle.user: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect( '/account/login_required?redirect={}'.format(urllib.quote(redirect_url)), abort=True ) def _require_permission(self, permission): self._require_registration() if permission not in self.user_bundle.account.permissions: return self.redirect( "/", abort=True ) def _require_registration(self, redirect_url=None): import urllib self._require_login() if not self.user_bundle.account.registered: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect( '/account/register?redirect={}'.format(urllib.quote(redirect_url)), abort=True )
def createMatchVideoSuggestion(self): user_bundle = UserBundle() match = Match.query().fetch(1)[0] #probably a cleaner way to do this suggestion = Suggestion(author=user_bundle.account.key, target_key=match.key_name, target_model="match") suggestion.contents = {"youtube_videos": [self.YOUTUBE_ID]} suggestion.put()
def createTeamMediaSuggestion(self): user_bundle = UserBundle() team = Team.query().fetch(1)[0] SuggestionCreator.createTeamMediaSuggestion( author_account_key=user_bundle.account.key, media_url=self.YOUTUBE_URL, team_key=team.key_name, year_str="2016")
def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } self.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0'
def createEventWebcastSuggestion(self): user_bundle = UserBundle() event = Event.query().fetch(1)[0] suggestion = Suggestion( author=user_bundle.account.key, target_key=event.key_name, target_model="event", ) suggestion.contents = {"webcast_url": self.YOUTUBE_URL} suggestion.put()
def __init__(self, *args, **kw): super(CacheableHandler, self).__init__(*args, **kw) self._cache_expiration = 0 self._last_modified = None # A datetime object self._user_bundle = UserBundle() self._is_admin = self._user_bundle.is_current_user_admin if not hasattr(self, '_partial_cache_key'): self._partial_cache_key = self.CACHE_KEY_FORMAT self.template_values = {} if self.response: self.response.headers['Vary'] = 'Accept-Encoding'
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = {"user_bundle": self.user_bundle} self.response.headers[ 'Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' self.response.headers['Vary'] = 'Accept-Encoding' def _get_login_url(self, target_url): return self.user_bundle.create_login_url(target_url) def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, redirect_url=None): import urllib if not self.user_bundle.user: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect('/account/login_required?redirect={}'.format( urllib.quote(redirect_url)), abort=True) def _require_permission(self, permission): self._require_registration() if permission not in self.user_bundle.account.permissions: return self.redirect("/", abort=True) def _require_registration(self, redirect_url=None): import urllib self._require_login() if not self.user_bundle.account.registered: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect('/account/register?redirect={}'.format( urllib.quote(redirect_url)), abort=True)
def __init__(self, *args, **kw): super(CacheableHandler, self).__init__(*args, **kw) if type(self.request) == webapp2.Request: trace_context.request = self.request with TraceContext(sendTrace=False) as root: with root.span("CacheableHandler.__init__"): self._cache_expiration = 0 self._last_modified = None # A datetime object self._user_bundle = UserBundle() self._is_admin = self._user_bundle.is_current_user_admin if not hasattr(self, '_partial_cache_key'): self._partial_cache_key = self.CACHE_KEY_FORMAT self.template_values = {} if self.response: self.response.headers['Vary'] = 'Accept-Encoding'
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = {"user_bundle": self.user_bundle} def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, target_url="/"): if not self.user_bundle.user: return self.redirect(self.user_bundle.create_login_url(target_url), abort=True)
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, target_url="/"): if not self.user_bundle.user: return self.redirect( self.user_bundle.create_login_url(target_url), abort=True )
def __init__(self, *args, **kw): super(ApiTrustedBaseController, self).__init__(*args, **kw) self.response.headers[ 'content-type'] = 'application/json; charset="utf-8"' self.response.headers['Access-Control-Allow-Origin'] = '*' self._user_bundle = UserBundle()
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) if type(self.request) == webapp2.Request: trace_context.request = self.request self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } self.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' self.response.headers['Vary'] = 'Accept-Encoding' self.response.headers['X-Robots-Tag'] = 'noindex' def _get_login_url(self, target_url): return self.user_bundle.create_login_url(target_url) def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, redirect_url=None): import urllib if not self.user_bundle.user: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect( '/account/login_required?redirect={}'.format(urllib.quote(redirect_url)), abort=True ) def _require_permission(self, permission): self._require_registration() if permission not in self.user_bundle.account.permissions: return self.redirect( "/", abort=True ) def _require_registration(self, redirect_url=None): import urllib self._require_login() if not self.user_bundle.account.registered: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect( '/account/register?redirect={}'.format(urllib.quote(redirect_url)), abort=True ) def _require_team_admin_access(self, team_number, redirect_url=None): self._require_login(redirect_url) if self.user_bundle.is_current_user_admin: # Admins have this granted return user = self.user_bundle.account.key now = datetime.datetime.now() existing_access = existing_access = TeamAdminAccess.query( TeamAdminAccess.account == user, TeamAdminAccess.team_number == team_number, TeamAdminAccess.expiration > now).fetch() if not existing_access: return self.abort(403) def _require_request_user_is_bundle_user(self): current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if not target_account_id: return self.abort(403) if target_account_id != current_user_account_id: return self.abort(403)
class LoggedInHandler(webapp2.RequestHandler): """ Provides a base set of functionality for pages that need logins. Currently does not support caching as easily as CacheableHandler. """ def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) if type(self.request) == webapp2.Request: trace_context.request = self.request self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle } self.response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' self.response.headers['Pragma'] = 'no-cache' self.response.headers['Expires'] = '0' self.response.headers['Vary'] = 'Accept-Encoding' self.response.headers['X-Robots-Tag'] = 'noindex' def _get_login_url(self, target_url): return self.user_bundle.create_login_url(target_url) def _require_admin(self): self._require_login() if not self.user_bundle.is_current_user_admin: return self.redirect(self.user_bundle.login_url, abort=True) def _require_login(self, redirect_url=None): import urllib if not self.user_bundle.user: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect( '/account/login_required?redirect={}'.format(urllib.quote(redirect_url)), abort=True ) def _require_permission(self, permission): self._require_registration() if permission not in self.user_bundle.account.permissions: return self.redirect( "/", abort=True ) def _require_registration(self, redirect_url=None): import urllib self._require_login() if not self.user_bundle.account.registered: if not redirect_url: redirect_url = self.request.get('redirect') if not redirect_url: redirect_url = self.request.url return self.redirect( '/account/register?redirect={}'.format(urllib.quote(redirect_url)), abort=True ) def _require_team_admin_access(self, team_number, redirect_url=None): self._require_login(redirect_url) if self.user_bundle.is_current_user_admin: # Admins have this granted return user = self.user_bundle.account.key now = datetime.datetime.now() existing_access = existing_access = TeamAdminAccess.query( TeamAdminAccess.account == user, TeamAdminAccess.team_number == team_number, TeamAdminAccess.expiration > now).fetch() if not existing_access: return self.abort(403)
def __init__(self, *args, **kw): super(BaseHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle }
def __init__(self, *args, **kw): super(LoggedInHandler, self).__init__(*args, **kw) self.user_bundle = UserBundle() self.template_values = { "user_bundle": self.user_bundle }