forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
842 lines (777 loc) · 34.5 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# Copyright 2014 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""URL routing definitions, and some basic error/warmup handlers."""
from __future__ import absolute_import # pylint: disable=import-only-modules
from __future__ import unicode_literals # pylint: disable=import-only-modules
import logging
from constants import constants
from core.controllers import acl_decorators
from core.controllers import admin
from core.controllers import base
from core.controllers import classifier
from core.controllers import classroom
from core.controllers import collection_editor
from core.controllers import collection_viewer
from core.controllers import concept_card_viewer
from core.controllers import contributor_dashboard
from core.controllers import creator_dashboard
from core.controllers import custom_landing_pages
from core.controllers import editor
from core.controllers import email_dashboard
from core.controllers import features
from core.controllers import feedback
from core.controllers import improvements
from core.controllers import learner_dashboard
from core.controllers import learner_playlist
from core.controllers import library
from core.controllers import moderator
from core.controllers import pages
from core.controllers import practice_sessions
from core.controllers import profile
from core.controllers import question_editor
from core.controllers import questions_list
from core.controllers import reader
from core.controllers import recent_commits
from core.controllers import resources
from core.controllers import review_tests
from core.controllers import skill_editor
from core.controllers import skill_mastery
from core.controllers import story_editor
from core.controllers import story_viewer
from core.controllers import subscriptions
from core.controllers import subtopic_viewer
from core.controllers import suggestion
from core.controllers import topic_editor
from core.controllers import topic_viewer
from core.controllers import topics_and_skills_dashboard
from core.controllers import voice_artist
from core.domain import user_services
from core.platform import models
import feconf
from mapreduce import main as mapreduce_main
from mapreduce import parameters as mapreduce_parameters
import webapp2
from webapp2_extras import routes
current_user_services = models.Registry.import_current_user_services()
transaction_services = models.Registry.import_transaction_services()
class FrontendErrorHandler(base.BaseHandler):
"""Handles errors arising from the frontend."""
REQUIRE_PAYLOAD_CSRF_CHECK = False
@acl_decorators.open_access
def post(self):
"""Records errors reported by the frontend."""
logging.error('Frontend error: %s' % self.payload.get('error'))
self.render_json(self.values)
class WarmupPage(base.BaseHandler):
"""Handles warmup requests."""
@acl_decorators.open_access
def get(self):
"""Handles GET warmup requests."""
pass
class HomePageRedirectPage(base.BaseHandler):
"""When a request is made to '/', check the user's login status, and
redirect them appropriately.
"""
@acl_decorators.open_access
def get(self):
if self.user_id and user_services.has_fully_registered_account(
self.user_id):
user_settings = user_services.get_user_settings(
self.user_id)
default_dashboard = user_settings.default_dashboard
if default_dashboard == constants.DASHBOARD_TYPE_CREATOR:
self.redirect(feconf.CREATOR_DASHBOARD_URL)
else:
self.redirect(feconf.LEARNER_DASHBOARD_URL)
else:
self.render_template('splash-page.mainpage.html')
class SplashRedirectPage(base.BaseHandler):
"""Redirect the old splash URL, '/splash' to the new one, '/'."""
@acl_decorators.open_access
def get(self):
self.redirect('/')
def get_redirect_route(regex_route, handler, defaults=None):
"""Returns a route that redirects /foo/ to /foo.
Warning: this method strips off parameters after the trailing slash. URLs
with parameters should be formulated without the trailing slash.
Args:
regex_route: unicode. A raw string representing a route.
handler: BaseHandler. A callable to handle the route.
defaults: dict. Optional defaults parameter to be passed
into the RedirectRoute object.
Returns:
RedirectRoute. A RedirectRoute object for redirects.
"""
if defaults is None:
defaults = {}
name = regex_route.replace('/', '_')
return routes.RedirectRoute(
regex_route, handler, name, strict_slash=True, defaults=defaults)
def authorization_wrapper(self, *args, **kwargs):
"""This request handler wrapper only admits internal requests from
taskqueue workers. If the request is invalid, it leads to a 403 Error page.
"""
# Internal requests should have an "X-AppEngine-TaskName" header
# (see cloud.google.com/appengine/docs/standard/python/taskqueue/push/).
if 'X-AppEngine-TaskName' not in self.request.headers:
self.response.out.write('Forbidden')
self.response.set_status(403)
return
self.real_dispatch(*args, **kwargs)
def ui_access_wrapper(self, *args, **kwargs):
"""This request handler wrapper directly serves UI pages
for MapReduce dashboards.
"""
self.real_dispatch(*args, **kwargs)
MAPREDUCE_HANDLERS = []
for path, handler_class in mapreduce_main.create_handlers_map():
if path.startswith('.*/pipeline'):
if 'pipeline/rpc/' in path or path == '.*/pipeline(/.+)':
path = path.replace('.*/pipeline', '/mapreduce/ui/pipeline')
else:
path = path.replace('.*/pipeline', '/mapreduce/worker/pipeline')
else:
if '_callback' in path:
path = path.replace('.*', '/mapreduce/worker', 1)
elif '/list_configs' in path:
continue
else:
path = path.replace('.*', '/mapreduce/ui', 1)
if '/ui/' in path or path.endswith('/ui'):
if (hasattr(handler_class, 'dispatch') and
not hasattr(handler_class, 'real_dispatch')):
handler_class.real_dispatch = handler_class.dispatch
handler_class.dispatch = ui_access_wrapper
MAPREDUCE_HANDLERS.append((path, handler_class))
else:
if (hasattr(handler_class, 'dispatch') and
not hasattr(handler_class, 'real_dispatch')):
handler_class.real_dispatch = handler_class.dispatch
handler_class.dispatch = authorization_wrapper
MAPREDUCE_HANDLERS.append((path, handler_class))
# Tell map/reduce internals that this is now the base path to use.
mapreduce_parameters.config.BASE_PATH = '/mapreduce/worker'
# Register the URLs with the classes responsible for handling them.
URLS = MAPREDUCE_HANDLERS + [
get_redirect_route(r'/_ah/warmup', WarmupPage),
get_redirect_route(r'/', HomePageRedirectPage),
get_redirect_route(r'/splash', SplashRedirectPage),
get_redirect_route(r'/foundation', pages.FoundationRedirectPage),
get_redirect_route(r'/credits', pages.AboutRedirectPage),
get_redirect_route(r'/participate', pages.TeachRedirectPage),
get_redirect_route(r'/site_guidelines', pages.TeachRedirectPage),
get_redirect_route(r'/console_errors', pages.ConsoleErrorPage),
get_redirect_route(r'/forum', pages.ForumRedirectPage),
get_redirect_route(r'%s' % feconf.ADMIN_URL, admin.AdminPage),
get_redirect_route(r'/adminhandler', admin.AdminHandler),
get_redirect_route(r'/adminrolehandler', admin.AdminRoleHandler),
get_redirect_route(
r'/explorationslatexsvghandler', admin.ExplorationsLatexSvgHandler),
get_redirect_route(
r'/suggestionslatexsvghandler', admin.SuggestionsLatexSvgHandler),
get_redirect_route(r'/adminjoboutput', admin.AdminJobOutputHandler),
get_redirect_route(
r'/admintopicscsvdownloadhandler',
admin.AdminTopicsCsvFileDownloader),
get_redirect_route(
r'/addcontributionreviewerhandler',
admin.AddContributionReviewerHandler),
get_redirect_route(
r'/removecontributionreviewerhandler',
admin.RemoveContributionReviewerHandler),
get_redirect_route(
r'/getcontributionreviewershandler',
admin.ContributionReviewersListHandler),
get_redirect_route(
r'/contributionreviewerrightsdatahandler',
admin.ContributionReviewerRightsDataHandler),
get_redirect_route(
r'%s' % feconf.CONTRIBUTOR_DASHBOARD_URL,
contributor_dashboard.ContributorDashboardPage),
get_redirect_route(
'/notifications_dashboard',
creator_dashboard.OldNotificationsDashboardRedirectPage),
get_redirect_route(
'/contributor_dashboard',
creator_dashboard.OldContributorDashboardRedirectPage),
get_redirect_route(
feconf.NOTIFICATIONS_DASHBOARD_URL,
creator_dashboard.NotificationsDashboardPage),
get_redirect_route(
r'/notificationsdashboardhandler/data',
creator_dashboard.NotificationsDashboardHandler),
get_redirect_route(
r'/notificationshandler', creator_dashboard.NotificationsHandler),
get_redirect_route(
'/creator_dashboard',
creator_dashboard.OldCreatorDashboardRedirectPage),
get_redirect_route(
r'%s' % feconf.CREATOR_DASHBOARD_URL,
creator_dashboard.CreatorDashboardPage),
get_redirect_route(
r'%s' % feconf.CREATOR_DASHBOARD_DATA_URL,
creator_dashboard.CreatorDashboardHandler),
get_redirect_route(
r'%s' % feconf.NEW_EXPLORATION_URL,
creator_dashboard.NewExplorationHandler),
get_redirect_route(
r'%s' % feconf.NEW_COLLECTION_URL,
creator_dashboard.NewCollectionHandler),
get_redirect_route(
r'%s' % feconf.FRACTIONS_LANDING_PAGE_URL,
custom_landing_pages.FractionLandingRedirectPage),
get_redirect_route(
r'/learn/maths/<topic>', custom_landing_pages.TopicLandingRedirectPage),
get_redirect_route(
r'%s/<opportunity_type>' % feconf.CONTRIBUTOR_OPPORTUNITIES_DATA_URL,
contributor_dashboard.ContributionOpportunitiesHandler),
get_redirect_route(
r'/gettranslatabletexthandler',
contributor_dashboard.TranslatableTextHandler),
get_redirect_route(
r'/usercontributionrightsdatahandler',
contributor_dashboard.UserContributionRightsDataHandler),
get_redirect_route(
r'/retrivefeaturedtranslationlanguages',
contributor_dashboard.FeaturedTranslationLanguagesHandler),
get_redirect_route(
r'%s' % feconf.NEW_SKILL_URL,
topics_and_skills_dashboard.NewSkillHandler),
get_redirect_route(
r'%s' % feconf.NEW_QUESTION_URL,
question_editor.QuestionCreationHandler),
get_redirect_route(
r'%s/<comma_separated_skill_ids>' % feconf.QUESTIONS_LIST_URL_PREFIX,
questions_list.QuestionsListHandler),
get_redirect_route(
r'%s/<comma_separated_skill_ids>' % feconf.QUESTION_COUNT_URL_PREFIX,
questions_list.QuestionCountDataHandler),
get_redirect_route(
r'%s/practice/session' % feconf.TOPIC_VIEWER_URL_PREFIX,
practice_sessions.PracticeSessionsPage),
get_redirect_route(
r'%s/<classroom_url_fragment>/<topic_url_fragment>' %
feconf.PRACTICE_SESSION_DATA_URL_PREFIX,
practice_sessions.PracticeSessionsPageDataHandler),
get_redirect_route(
r'%s/<classroom_url_fragment>/<topic_url_fragment>'
r'/<story_url_fragment>' % feconf.REVIEW_TEST_DATA_URL_PREFIX,
review_tests.ReviewTestsPageDataHandler),
get_redirect_route(
r'%s/review-test/<story_url_fragment>'
% feconf.TOPIC_VIEWER_URL_PREFIX,
review_tests.ReviewTestsPage),
get_redirect_route(
r'%s/<classroom_url_fragment>/<topic_url_fragment>'
r'/<story_url_fragment>' % feconf.STORY_DATA_HANDLER,
story_viewer.StoryPageDataHandler),
get_redirect_route(
r'%s/<story_url_fragment>' % feconf.STORY_URL_FRAGMENT_HANDLER,
story_editor.StoryUrlFragmentHandler),
get_redirect_route(
r'%s/<topic_name>' % feconf.TOPIC_NAME_HANDLER,
topic_editor.TopicNameHandler),
get_redirect_route(
r'%s/<topic_url_fragment>' % feconf.TOPIC_URL_FRAGMENT_HANDLER,
topic_editor.TopicUrlFragmentHandler),
get_redirect_route(
r'%s/story' % feconf.TOPIC_VIEWER_URL_PREFIX,
topic_viewer.TopicViewerPage),
get_redirect_route(
r'%s/story/<story_url_fragment>' % feconf.TOPIC_VIEWER_URL_PREFIX,
story_viewer.StoryPage),
get_redirect_route(
r'%s/<classroom_url_fragment>/<topic_url_fragment>'
r'/<story_url_fragment>/<node_id>' % feconf.STORY_PROGRESS_URL_PREFIX,
story_viewer.StoryProgressHandler),
get_redirect_route(
r'%s/<classroom_url_fragment>/<topic_url_fragment>'
r'/<subtopic_url_fragment>' % feconf.SUBTOPIC_DATA_HANDLER,
subtopic_viewer.SubtopicPageDataHandler),
get_redirect_route(
r'%s/revision' % feconf.TOPIC_VIEWER_URL_PREFIX,
topic_viewer.TopicViewerPage),
get_redirect_route(
r'%s/revision/<subtopic_url_fragment>' %
feconf.TOPIC_VIEWER_URL_PREFIX, subtopic_viewer.SubtopicViewerPage),
get_redirect_route(
r'%s/<topic_id>' % feconf.TOPIC_EDITOR_STORY_URL,
topic_editor.TopicEditorStoryHandler),
get_redirect_route(
r'%s' % feconf.TOPIC_VIEWER_URL_PREFIX,
topic_viewer.TopicViewerPage),
get_redirect_route(
r'%s/practice' % feconf.TOPIC_VIEWER_URL_PREFIX,
topic_viewer.TopicViewerPage),
get_redirect_route(
r'%s/<classroom_url_fragment>/<topic_url_fragment>'
% feconf.TOPIC_DATA_HANDLER,
topic_viewer.TopicPageDataHandler),
get_redirect_route(
r'%s/<classroom_url_fragment>' % feconf.CLASSROOM_DATA_HANDLER,
classroom.ClassroomDataHandler),
get_redirect_route(
r'%s' % feconf.NEW_TOPIC_URL,
topics_and_skills_dashboard.NewTopicHandler),
get_redirect_route(
r'%s' % feconf.UPLOAD_EXPLORATION_URL,
creator_dashboard.UploadExplorationHandler),
get_redirect_route(
'/learner_dashboard',
learner_dashboard.OldLearnerDashboardRedirectPage),
get_redirect_route(
r'%s' % feconf.LEARNER_DASHBOARD_URL,
learner_dashboard.LearnerDashboardPage),
get_redirect_route(
r'%s' % feconf.LEARNER_DASHBOARD_DATA_URL,
learner_dashboard.LearnerDashboardHandler),
get_redirect_route(
r'%s' % feconf.LEARNER_DASHBOARD_IDS_DATA_URL,
learner_dashboard.LearnerDashboardIdsHandler),
get_redirect_route(
r'%s/<thread_id>' %
feconf.LEARNER_DASHBOARD_FEEDBACK_THREAD_DATA_URL,
learner_dashboard.LearnerDashboardFeedbackThreadHandler),
get_redirect_route(
r'%s' % feconf.TOPICS_AND_SKILLS_DASHBOARD_URL,
topics_and_skills_dashboard.TopicsAndSkillsDashboardPage),
get_redirect_route(
r'%s' % feconf.MERGE_SKILLS_URL,
topics_and_skills_dashboard.MergeSkillHandler),
get_redirect_route(
r'%s' % feconf.TOPICS_AND_SKILLS_DASHBOARD_DATA_URL,
topics_and_skills_dashboard.TopicsAndSkillsDashboardPageDataHandler),
get_redirect_route(
r'%s/<skill_id>' % feconf.UNASSIGN_SKILL_DATA_HANDLER_URL,
topics_and_skills_dashboard.TopicAssignmentsHandler),
get_redirect_route(
r'%s' % feconf.SKILL_DASHBOARD_DATA_URL,
topics_and_skills_dashboard.SkillsDashboardPageDataHandler),
get_redirect_route(
r'%s/<activity_type>/<activity_id>' %
feconf.LEARNER_INCOMPLETE_ACTIVITY_DATA_URL,
reader.LearnerIncompleteActivityHandler),
get_redirect_route(
r'%s/<activity_type>/<activity_id>' % feconf.LEARNER_PLAYLIST_DATA_URL,
learner_playlist.LearnerPlaylistHandler),
get_redirect_route(
r'/assetsdevhandler/<page_context>/<page_identifier>/'
'assets/<asset_type:(image|audio|thumbnail)>/<encoded_filename>',
resources.AssetDevHandler),
get_redirect_route(
r'/value_generator_handler/<generator_id>',
resources.ValueGeneratorHandler),
get_redirect_route(r'/promo_bar_handler', resources.PromoBarHandler),
get_redirect_route(
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.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('/library', library.OldLibraryRedirectPage),
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),
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_DATA_URL, library.SearchHandler),
get_redirect_route(r'/gallery', library.LibraryRedirectPage),
get_redirect_route(r'/contribute', library.LibraryRedirectPage),
get_redirect_route(r'/learn', library.LibraryRedirectPage),
get_redirect_route(r'/playtest', library.LibraryRedirectPage),
get_redirect_route(
feconf.EXPLORATION_SUMMARIES_DATA_URL,
library.ExplorationSummariesHandler),
get_redirect_route(
feconf.COLLECTION_SUMMARIES_DATA_URL,
library.CollectionSummariesHandler),
get_redirect_route(r'/profile/<username>', profile.ProfilePage),
get_redirect_route(
r'/profilehandler/data/<username>', profile.ProfileHandler),
get_redirect_route(feconf.PREFERENCES_URL, profile.PreferencesPage),
get_redirect_route(
feconf.PREFERENCES_DATA_URL, profile.PreferencesHandler),
get_redirect_route(
r'/preferenceshandler/profile_picture', profile.ProfilePictureHandler),
get_redirect_route(
r'/preferenceshandler/profile_picture_by_username/<username>',
profile.ProfilePictureHandlerByUsernameHandler),
get_redirect_route(r'%s' % feconf.SIGNUP_URL, profile.SignupPage),
get_redirect_route(r'%s' % feconf.SIGNUP_DATA_URL, profile.SignupHandler),
get_redirect_route(feconf.DELETE_ACCOUNT_URL, profile.DeleteAccountPage),
get_redirect_route(
feconf.DELETE_ACCOUNT_HANDLER_URL, profile.DeleteAccountHandler),
get_redirect_route(
feconf.EXPORT_ACCOUNT_HANDLER_URL, profile.ExportAccountHandler),
get_redirect_route(
feconf.PENDING_ACCOUNT_DELETION_URL,
profile.PendingAccountDeletionPage),
get_redirect_route(
r'%s' % feconf.USERNAME_CHECK_DATA_URL, profile.UsernameCheckHandler),
get_redirect_route(
r'%s' % feconf.SITE_LANGUAGE_DATA_URL, profile.SiteLanguageHandler),
get_redirect_route(r'/userinfohandler', profile.UserInfoHandler),
get_redirect_route(r'/url_handler', profile.UrlHandler),
get_redirect_route(r'/moderator', moderator.ModeratorPage),
get_redirect_route(
r'/moderatorhandler/featured', moderator.FeaturedActivitiesHandler),
get_redirect_route(
r'/moderatorhandler/email_draft', moderator.EmailDraftHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_URL_PREFIX,
reader.ExplorationPage),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_URL_EMBED_PREFIX,
reader.ExplorationEmbedPage),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_INIT_URL_PREFIX,
reader.ExplorationHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_PRETESTS_URL_PREFIX,
reader.PretestHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_FEATURES_PREFIX,
features.ExplorationFeaturesHandler),
get_redirect_route(
'/explorehandler/exploration_start_event/<exploration_id>',
reader.ExplorationStartEventHandler),
get_redirect_route(
'/explorehandler/exploration_actual_start_event/<exploration_id>',
reader.ExplorationActualStartEventHandler),
get_redirect_route(
'/explorehandler/solution_hit_event/<exploration_id>',
reader.SolutionHitEventHandler),
get_redirect_route(
r'/explorehandler/state_hit_event/<exploration_id>',
reader.StateHitEventHandler),
get_redirect_route(
r'/explorehandler/state_complete_event/<exploration_id>',
reader.StateCompleteEventHandler),
get_redirect_route(
r'/explorehandler/leave_for_refresher_exp_event/<exploration_id>',
reader.LeaveForRefresherExpEventHandler),
get_redirect_route(
r'/explorehandler/answer_submitted_event/<exploration_id>',
reader.AnswerSubmittedEventHandler),
get_redirect_route(
r'/explorehandler/give_feedback/<exploration_id>',
reader.ReaderFeedbackHandler),
get_redirect_route(
r'/explorehandler/exploration_complete_event/<exploration_id>',
reader.ExplorationCompleteEventHandler),
get_redirect_route(
r'/explorehandler/exploration_maybe_leave_event/<exploration_id>',
reader.ExplorationMaybeLeaveHandler),
get_redirect_route(
r'/explorehandler/stats_events/<exploration_id>',
reader.StatsEventsHandler),
get_redirect_route(
r'/explorehandler/store_playthrough/<exploration_id>',
reader.StorePlaythroughHandler),
get_redirect_route(
r'/explorehandler/rating/<exploration_id>', reader.RatingHandler),
get_redirect_route(
r'/explorehandler/recommendations/<exploration_id>',
reader.RecommendationsHandler),
get_redirect_route(
r'%s/<entity_type>/<entity_id>' % (
feconf.LEARNER_ANSWER_DETAILS_SUBMIT_URL),
reader.LearnerAnswerDetailsSubmissionHandler),
get_redirect_route(
r'%s/<question_id>' % feconf.QUESTION_EDITOR_DATA_URL_PREFIX,
question_editor.EditableQuestionDataHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EDITOR_URL_PREFIX,
editor.ExplorationPage),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_DATA_PREFIX,
editor.ExplorationHandler),
get_redirect_route(
r'/createhandler/download/<exploration_id>',
editor.ExplorationFileDownloader),
get_redirect_route(
r'/createhandler/imageupload/<entity_type>/<entity_id>',
editor.ImageUploadHandler),
get_redirect_route(
r'/createhandler/audioupload/<exploration_id>',
voice_artist.AudioUploadHandler),
get_redirect_route(
r'/createhandler/state_yaml/<exploration_id>',
editor.StateYamlHandler),
get_redirect_route(
r'/createhandler/revert/<exploration_id>',
editor.ExplorationRevertHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_RIGHTS_PREFIX,
editor.ExplorationRightsHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.USER_PERMISSIONS_URL_PREFIX,
editor.UserExplorationPermissionsHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_STATUS_PREFIX,
editor.ExplorationStatusHandler),
get_redirect_route(
r'/createhandler/moderatorrights/<exploration_id>',
editor.ExplorationModeratorRightsHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.USER_EXPLORATION_EMAILS_PREFIX,
editor.UserExplorationEmailsHandler),
get_redirect_route(
r'/createhandler/snapshots/<exploration_id>',
editor.ExplorationSnapshotsHandler),
get_redirect_route(
r'/createhandler/statistics/<exploration_id>',
editor.ExplorationStatisticsHandler),
get_redirect_route(
r'/createhandler/state_interaction_stats/<exploration_id>/<escaped_state_name>', # pylint: disable=line-too-long
editor.StateInteractionStatsHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.EXPLORATION_STATE_ANSWER_STATS_PREFIX,
editor.StateAnswerStatisticsHandler),
get_redirect_route(
r'/createhandler/started_tutorial_event/<exploration_id>',
editor.StartedTutorialEventHandler),
get_redirect_route(
r'/createhandler/started_translation_tutorial_event/<exploration_id>',
voice_artist.StartedTranslationTutorialEventHandler),
get_redirect_route(
r'/createhandler/autosave_draft/<exploration_id>',
editor.EditorAutosaveHandler),
get_redirect_route(
r'/createhandler/get_top_unresolved_answers/<exploration_id>',
editor.TopUnresolvedAnswersHandler),
get_redirect_route(
r'%s/<entity_type>/<entity_id>' %
feconf.LEARNER_ANSWER_INFO_HANDLER_URL,
editor.LearnerAnswerInfoHandler),
get_redirect_route(
r'%s' % feconf.RECENT_COMMITS_DATA_URL,
recent_commits.RecentCommitsHandler),
get_redirect_route(
r'%s' % feconf.RECENT_FEEDBACK_MESSAGES_DATA_URL,
feedback.RecentFeedbackMessagesHandler),
get_redirect_route(
r'%s/<thread_id>' % feconf.FEEDBACK_THREAD_VIEW_EVENT_URL,
feedback.FeedbackThreadViewEventHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.FEEDBACK_THREADLIST_URL_PREFIX,
feedback.ThreadListHandler),
get_redirect_route(
r'%s/<topic_id>' % feconf.FEEDBACK_THREADLIST_URL_PREFIX_FOR_TOPICS,
feedback.ThreadListHandlerForTopicsHandler),
get_redirect_route(
r'%s/<thread_id>' % feconf.FEEDBACK_THREAD_URL_PREFIX,
feedback.ThreadHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.FEEDBACK_STATS_URL_PREFIX,
feedback.FeedbackStatsHandler),
get_redirect_route(
r'%s/' % feconf.SUGGESTION_URL_PREFIX,
suggestion.SuggestionHandler),
get_redirect_route(
r'%s' % feconf.QUESTIONS_URL_PREFIX,
reader.QuestionPlayerHandler),
get_redirect_route(
r'%s/exploration/<target_id>/<suggestion_id>' %
feconf.SUGGESTION_ACTION_URL_PREFIX,
suggestion.SuggestionToExplorationActionHandler),
get_redirect_route(
r'%s/resubmit/<suggestion_id>' % feconf.SUGGESTION_ACTION_URL_PREFIX,
suggestion.ResubmitSuggestionHandler),
get_redirect_route(
r'%s/skill/<target_id>/<suggestion_id>' %
feconf.SUGGESTION_ACTION_URL_PREFIX,
suggestion.SuggestionToSkillActionHandler),
get_redirect_route(
r'%s' % feconf.SUGGESTION_LIST_URL_PREFIX,
suggestion.SuggestionListHandler),
get_redirect_route(
r'/getreviewablesuggestions/<target_type>/<suggestion_type>',
suggestion.ReviewableSuggestionsHandler),
get_redirect_route(
r'/getsubmittedsuggestions/<target_type>/<suggestion_type>',
suggestion.UserSubmittedSuggestionsHandler),
get_redirect_route(
r'%s' % feconf.SUBSCRIBE_URL_PREFIX,
subscriptions.SubscribeHandler),
get_redirect_route(
r'%s' % feconf.UNSUBSCRIBE_URL_PREFIX,
subscriptions.UnsubscribeHandler),
get_redirect_route(
r'%s/<exploration_id>' % feconf.FLAG_EXPLORATION_URL_PREFIX,
reader.FlagExplorationHandler),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_URL_PREFIX,
collection_viewer.CollectionPage),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_DATA_URL_PREFIX,
collection_viewer.CollectionDataHandler),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_EDITOR_URL_PREFIX,
collection_editor.CollectionEditorPage),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_EDITOR_DATA_URL_PREFIX,
collection_editor.EditableCollectionDataHandler),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_RIGHTS_PREFIX,
collection_editor.CollectionRightsHandler),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_PUBLISH_PREFIX,
collection_editor.CollectionPublishHandler),
get_redirect_route(
r'%s/<collection_id>' % feconf.COLLECTION_UNPUBLISH_PREFIX,
collection_editor.CollectionUnpublishHandler),
get_redirect_route(
r'%s/<topic_id>' % feconf.TOPIC_EDITOR_URL_PREFIX,
topic_editor.TopicEditorPage),
get_redirect_route(
r'%s/<topic_id>' % feconf.TOPIC_EDITOR_DATA_URL_PREFIX,
topic_editor.EditableTopicDataHandler),
get_redirect_route(
r'%s/<topic_id>/<subtopic_id>' %
feconf.SUBTOPIC_PAGE_EDITOR_DATA_URL_PREFIX,
topic_editor.EditableSubtopicPageDataHandler),
get_redirect_route(
r'%s/<topic_id>' % feconf.TOPIC_RIGHTS_URL_PREFIX,
topic_editor.TopicRightsHandler),
get_redirect_route(
r'%s/<topic_id>' % feconf.TOPIC_STATUS_URL_PREFIX,
topic_editor.TopicPublishHandler),
get_redirect_route(
r'%s/<topic_id>' % feconf.TOPIC_SEND_MAIL_URL_PREFIX,
topic_editor.TopicPublishSendMailHandler),
get_redirect_route(
r'%s/<comma_separated_skill_ids>' % feconf.CONCEPT_CARD_DATA_URL_PREFIX,
concept_card_viewer.ConceptCardDataHandler),
get_redirect_route(
r'%s/<question_id>' % feconf.QUESTION_SKILL_LINK_URL_PREFIX,
question_editor.QuestionSkillLinkHandler),
get_redirect_route(
r'%s/<comma_separated_skill_ids>' % feconf.SKILL_DATA_URL_PREFIX,
skill_editor.SkillDataHandler),
get_redirect_route(
r'%s' % feconf.FETCH_SKILLS_URL_PREFIX,
skill_editor.FetchSkillsHandler),
get_redirect_route(
r'%s/<skill_id>' % feconf.SKILL_EDITOR_URL_PREFIX,
skill_editor.SkillEditorPage),
get_redirect_route(
r'%s/<skill_id>' % feconf.SKILL_EDITOR_DATA_URL_PREFIX,
skill_editor.EditableSkillDataHandler),
get_redirect_route(
r'%s' % feconf.SKILL_MASTERY_DATA_URL,
skill_mastery.SkillMasteryDataHandler),
get_redirect_route(
r'%s/<skill_id>' % feconf.SKILL_RIGHTS_URL_PREFIX,
skill_editor.SkillRightsHandler),
get_redirect_route(
r'%s/<story_id>' % feconf.STORY_EDITOR_URL_PREFIX,
story_editor.StoryEditorPage),
get_redirect_route(
r'%s/<story_id>' % feconf.STORY_EDITOR_DATA_URL_PREFIX,
story_editor.EditableStoryDataHandler),
get_redirect_route(
r'%s/<story_id>' % feconf.STORY_PUBLISH_HANDLER,
story_editor.StoryPublishHandler),
get_redirect_route(
r'%s/<story_id>' %
feconf.VALIDATE_STORY_EXPLORATIONS_URL_PREFIX,
story_editor.ValidateExplorationsHandler),
get_redirect_route(
'/classroom_page_status_handler', classroom.ClassroomPageStatusHandler),
get_redirect_route(r'/emaildashboard', email_dashboard.EmailDashboardPage),
get_redirect_route(
r'/emaildashboarddatahandler',
email_dashboard.EmailDashboardDataHandler),
get_redirect_route(
r'/querystatuscheck', email_dashboard.QueryStatusCheckHandler),
get_redirect_route(
r'/emaildashboardresult/<query_id>',
email_dashboard.EmailDashboardResultPage),
get_redirect_route(
r'/emaildashboardcancelresult/<query_id>',
email_dashboard.EmailDashboardCancelEmailHandler),
get_redirect_route(
r'/emaildashboardtestbulkemailhandler/<query_id>',
email_dashboard.EmailDashboardTestBulkEmailHandler),
get_redirect_route(
r'%s' % feconf.EXPLORATION_METADATA_SEARCH_URL,
collection_editor.ExplorationMetadataSearchHandler),
get_redirect_route(
r'/explorationdataextractionhandler', admin.DataExtractionQueryHandler),
get_redirect_route(
r'/senddummymailtoadminhandler', admin.SendDummyMailToAdminHandler),
get_redirect_route(r'/updateusernamehandler', admin.UpdateUsernameHandler),
get_redirect_route(r'/frontend_errors', FrontendErrorHandler),
get_redirect_route(r'/logout', base.LogoutPage),
get_redirect_route(
r'%s/%s/<exploration_id>' % (
feconf.IMPROVEMENTS_URL_PREFIX,
constants.TASK_ENTITY_TYPE_EXPLORATION),
improvements.ExplorationImprovementsHandler),
get_redirect_route(
r'%s/%s/<exploration_id>' % (
feconf.IMPROVEMENTS_HISTORY_URL_PREFIX,
constants.TASK_ENTITY_TYPE_EXPLORATION),
improvements.ExplorationImprovementsHistoryHandler),
get_redirect_route(
r'%s/%s/<exploration_id>' % (
feconf.IMPROVEMENTS_CONFIG_URL_PREFIX,
constants.TASK_ENTITY_TYPE_EXPLORATION),
improvements.ExplorationImprovementsConfigHandler),
get_redirect_route(
r'/issuesdatahandler/<exploration_id>', editor.FetchIssuesHandler),
get_redirect_route(
r'/ml/trainedclassifierhandler', classifier.TrainedClassifierHandler),
get_redirect_route(
r'/ml/nextjobhandler', classifier.NextJobHandler),
get_redirect_route(
r'/playthroughdatahandler/<exploration_id>/<playthrough_id>',
editor.FetchPlaythroughHandler),
get_redirect_route(
r'/resolveissuehandler/<exploration_id>', editor.ResolveIssueHandler),
get_redirect_route(
r'%s' % feconf.CSRF_HANDLER_URL, base.CsrfTokenHandler),
get_redirect_route(
r'/learn/<classroom_url_fragment>', classroom.ClassroomPage),
]
# Adding redirects for topic landing pages.
for subject in feconf.AVAILABLE_LANDING_PAGES:
for topic in feconf.AVAILABLE_LANDING_PAGES[subject]:
URLS.append(
get_redirect_route(
r'/%s/%s' % (subject, topic),
custom_landing_pages.TopicLandingPage))
# 404 error handler (Needs to be at the end of the URLS list).
URLS.append(get_redirect_route(r'/<:.*>', base.Error404Handler))
app = transaction_services.toplevel_wrapper( # pylint: disable=invalid-name
webapp2.WSGIApplication(URLS, debug=feconf.DEBUG))