Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5466: Added check to enforce that all name of controllers end with "Handler" or "Page" #5878

Merged
merged 12 commits into from
Nov 28, 2018
Merged
Prev Previous commit
Merge branch 'develop' into new_base
  • Loading branch information
Rishav Chakraborty authored Nov 27, 2018
commit af4b4e1dc6f2495ac3cf0593280f19188dbb4e78
40 changes: 0 additions & 40 deletions core/controllers/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,43 +86,3 @@ def get(self, exploration_id, asset_type, encoded_filename):
self.response.write(raw)
except:
raise self.PageNotFoundException


class AudioDevHandler(base.BaseHandler):
"""Handles audio retrievals (only in dev -- in production, audio files are
served from GCS).
"""

_AUDIO_PATH_PREFIX = 'audio'
GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON

@acl_decorators.open_access
def get(self, exploration_id, encoded_filename):
"""Returns an audio file.

Args:
encoded_filename: a string representing the audio filename. This
string is encoded in the frontend using encodeURIComponent().
"""
if not constants.DEV_MODE:
raise self.PageNotFoundException

filename = urllib.unquote(encoded_filename)
file_format = filename[(filename.rfind('.') + 1):]
# If the following is not cast to str, an error occurs in the wsgi
# library because unicode gets used.
self.response.headers['Content-Type'] = str(
'audio/%s' % file_format)

fs = fs_domain.AbstractFileSystem(
fs_domain.ExplorationFileSystem('exploration/%s' % exploration_id))

try:
raw = fs.get('%s/%s' % (self._AUDIO_PATH_PREFIX, filename))
except:
raise self.PageNotFoundException

self.response.cache_control.no_cache = None
self.response.cache_control.public = True
self.response.cache_control.max_age = 600
self.response.write(raw)
30 changes: 21 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,27 +281,39 @@ def ui_access_wrapper(self, *args, **kwargs):
get_redirect_route(
r'/value_generator_handler/<generator_id>',
resources.ValueGeneratorHandler),

get_redirect_route(
r'%s' % feconf.FRACTIONS_LANDING_PAGE_URL,
custom_landing_pages.FractionLandingPage),
get_redirect_route(
r'%s' % feconf.LIBRARY_INDEX_URL,
library.LibraryPage),
r'%s' % feconf.CUSTOM_PARENTS_LANDING_PAGE_URL,
custom_landing_pages.StewardsLandingPage),
get_redirect_route(
r'%s' % feconf.CUSTOM_PARTNERS_LANDING_PAGE_URL,
custom_landing_pages.StewardsLandingPage),
get_redirect_route(
r'%s' % feconf.CUSTOM_NONPROFITS_LANDING_PAGE_URL,
custom_landing_pages.StewardsLandingPage),
get_redirect_route(
r'%s' % feconf.LIBRARY_INDEX_DATA_URL,
library.LibraryIndexHandler),
r'%s' % feconf.CUSTOM_TEACHERS_LANDING_PAGE_URL,
custom_landing_pages.StewardsLandingPage),
get_redirect_route(
r'%s' % feconf.CUSTOM_VOLUNTEERS_LANDING_PAGE_URL,
custom_landing_pages.StewardsLandingPage),

get_redirect_route(
r'%s' % feconf.LIBRARY_INDEX_URL, library.LibraryPage),
get_redirect_route(
r'%s' % feconf.LIBRARY_INDEX_DATA_URL, library.LibraryIndexHandler),
get_redirect_route(
r'%s' % feconf.LIBRARY_RECENTLY_PUBLISHED_URL,
library.LibraryGroupPage),
get_redirect_route(
r'%s' % feconf.LIBRARY_TOP_RATED_URL,
library.LibraryGroupPage),
r'%s' % feconf.LIBRARY_TOP_RATED_URL, library.LibraryGroupPage),
get_redirect_route(
r'%s' % feconf.LIBRARY_GROUP_DATA_URL,
library.LibraryGroupIndexHandler),
get_redirect_route(
r'%s' % feconf.LIBRARY_SEARCH_URL,
library.LibraryPage),
get_redirect_route(r'%s' % feconf.LIBRARY_SEARCH_URL, library.LibraryPage),
get_redirect_route(
r'%s' % feconf.LIBRARY_SEARCH_DATA_URL, library.SearchHandler),
get_redirect_route(r'/gallery', library.LibraryRedirectPage),
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.