Exemple #1
0
    def _get_user_nav(self):
        current_action = self.request.get('action')
        nav_mappings = [('welcome', 'Welcome'), ('courses', 'Courses'),
                        ('settings', 'Settings'), ('perf', 'Metrics'),
                        ('deployment', 'Deployment')]
        if DIRECT_CODE_EXECUTION_UI_ENABLED:
            nav_mappings.append(('console', 'Console'))
        nav = safe_dom.NodeList()
        for action, title in nav_mappings:
            if action == current_action:
                elt = safe_dom.Element('a',
                                       href='/admin?action=%s' % action,
                                       className='selected')
            else:
                elt = safe_dom.Element('a', href='/admin?action=%s' % action)
            elt.add_text(title)
            nav.append(elt).append(safe_dom.Text(' '))

        if appengine_config.gcb_appstats_enabled():
            nav.append(
                safe_dom.Element(
                    'a', target='_blank',
                    href='/admin/stats/').add_text('Appstats')).append(
                        safe_dom.Text(' '))

        if appengine_config.PRODUCTION_MODE:
            app_id = app.get_application_id()
            nav.append(
                safe_dom.Element('a',
                                 target='_blank',
                                 href=('https://appengine.google.com/'
                                       'dashboard?app_id=s~%s' %
                                       app_id)).add_text('Google App Engine'))
        else:
            nav.append(
                safe_dom.Element('a',
                                 target='_blank',
                                 href='http://localhost:8000/').add_text(
                                     'Google App Engine')).append(
                                         safe_dom.Text(' '))

        nav.append(
            safe_dom.Element(
                'a',
                target='_blank',
                href='https://code.google.com/p/course-builder/wiki/AdminPage'
            ).add_text('Help'))

        nav.append(
            safe_dom.Element(
                'a',
                href=('https://groups.google.com/forum/'
                      '?fromgroups#!forum/course-builder-announce'),
                target='_blank').add_text('News'))

        return nav
    def _get_user_nav(self):
        current_action = self.request.get('action')
        nav_mappings = [
            ('welcome', 'Welcome'),
            ('courses', 'Courses'),
            ('settings', 'Settings'),
            ('perf', 'Metrics'),
            ('deployment', 'Deployment')]
        if DIRECT_CODE_EXECUTION_UI_ENABLED:
            nav_mappings.append(('console', 'Console'))
        nav = safe_dom.NodeList()
        for action, title in nav_mappings:
            if action == current_action:
                elt = safe_dom.Element(
                    'a', href='/admin?action=%s' % action,
                    className='selected')
            else:
                elt = safe_dom.Element('a', href='/admin?action=%s' % action)
            elt.add_text(title)
            nav.append(elt).append(safe_dom.Text(' '))

        if appengine_config.gcb_appstats_enabled():
            nav.append(safe_dom.Element(
                'a', target='_blank', href='/admin/stats/'
            ).add_text('Appstats')).append(safe_dom.Text(' '))

        if appengine_config.PRODUCTION_MODE:
            app_id = app.get_application_id()
            nav.append(safe_dom.Element(
                'a', target='_blank',
                href=(
                    'https://appengine.google.com/'
                    'dashboard?app_id=s~%s' % app_id)
            ).add_text('Google App Engine'))
        else:
            nav.append(safe_dom.Element(
                'a', target='_blank', href='http://localhost:8000/'
            ).add_text('Google App Engine')).append(safe_dom.Text(' '))

        nav.append(safe_dom.Element(
            'a', target='_blank',
            href='https://code.google.com/p/course-builder/wiki/AdminPage'
        ).add_text('Help'))

        nav.append(safe_dom.Element(
            'a',
            href=(
                'https://groups.google.com/forum/'
                '?fromgroups#!forum/course-builder-announce'),
            target='_blank'
        ).add_text('News'))

        return nav
Exemple #3
0
    def make_site_menu(cls, root_menu_group, placement):

        group = menus.MenuGroup(
            'admin', 'Site admin', group=root_menu_group, placement=placement)

        def bind(key, label, handler, href=None):
            if href:
                target = '_blank'
            else:
                target = None
                href = "{}?action={}".format(cls.LINK_URL, key)

            def can_view(app_context):
                return can_view_admin_action(key)

            menu_item = menus.MenuItem(
                key, label, action=key, can_view=can_view, group=group,
                href=href, target=target)

            if handler:
                cls.get_actions.append(key)
                cls.actions_to_menu_items[key] = menu_item

        bind('courses', 'Courses', cls.get_courses)
        bind('settings', 'Site settings', cls.get_settings)
        bind('perf', 'Metrics', cls.get_perf)
        bind('deployment', 'Deployment', cls.get_deployment)

        if DIRECT_CODE_EXECUTION_UI_ENABLED:
            bind('console', 'Console', cls.get_console)

        if appengine_config.gcb_appstats_enabled():
            bind('stats', 'Appstats', None, href='/admin/stats/')

        if appengine_config.PRODUCTION_MODE:
            app_id = app.get_application_id()
            href = (
                'https://appengine.google.com/'
                'dashboard?app_id=s~%s' % app_id)
            bind('gae', 'Google App Engine', None, href=href)
        else:
            bind(
                 'gae', 'Google App Engine', None,
                 href='http://localhost:8000/')
        bind('welcome', 'Welcome', None, href='/admin/welcome')
        bind(
             'help', 'Site help', None,
             href='https://code.google.com/p/course-builder/wiki/AdminPage')
        bind(
             'news', 'News', None,
             href=(
                'https://groups.google.com/forum/'
                '?fromgroups#!forum/course-builder-announce'))
Exemple #4
0
    def make_site_menu(cls, root_menu_group, placement):

        group = menus.MenuGroup(
            'admin', 'Site admin', group=root_menu_group, placement=placement)

        def bind(key, label, handler, href=None):
            if href:
                target = '_blank'
            else:
                target = None
                href = "{}?action={}".format(cls.LINK_URL, key)

            def can_view(app_context):
                return can_view_admin_action(key)

            menu_item = menus.MenuItem(
                key, label, action=key, can_view=can_view, group=group,
                href=href, target=target)

            if handler:
                cls.get_actions.append(key)
                cls.actions_to_menu_items[key] = menu_item

        bind('courses', 'Courses', cls.get_courses)
        bind('settings', 'Site settings', cls.get_settings)
        bind('perf', 'Metrics', cls.get_perf)
        bind('deployment', 'Deployment', cls.get_deployment)

        if DIRECT_CODE_EXECUTION_UI_ENABLED:
            bind('console', 'Console', cls.get_console)

        if appengine_config.gcb_appstats_enabled():
            bind('stats', 'Appstats', None, href='/admin/stats/')

        if appengine_config.PRODUCTION_MODE:
            app_id = app.get_application_id()
            href = (
                'https://appengine.google.com/'
                'dashboard?app_id=s~%s' % app_id)
            bind('gae', 'Google App Engine', None, href=href)
        else:
            bind(
                 'gae', 'Google App Engine', None,
                 href='http://localhost:8000/')
        bind('welcome', 'Welcome', None, href='/admin/welcome')
        bind(
             'help', 'Site help', None,
             href='https://code.google.com/p/course-builder/wiki/AdminPage')
        bind(
             'news', 'News', None,
             href=(
                'https://groups.google.com/forum/'
                '?fromgroups#!forum/course-builder-announce'))
Exemple #5
0
    def bind_tabs(cls):
        def bind(key, label, handler, href=None):
            if href:
                target = '_blank'
            else:
                href = 'admin?action=admin&tab=%s' % key
                target = None

            tabs.Registry.register(cls.ACTION,
                                   key,
                                   label,
                                   contents=handler,
                                   href=href,
                                   target=target)

        bind('courses', 'Courses', cls.get_courses)
        bind('settings', 'Site Settings', cls.get_settings)
        bind('perf', 'Metrics', cls.get_perf)
        bind('deployment', 'Deployment', cls.get_deployment)

        if DIRECT_CODE_EXECUTION_UI_ENABLED:
            bind('console', 'Console', cls.get_console)

        if appengine_config.gcb_appstats_enabled():
            bind('stats', 'Appstats', None, href='/admin/stats/')

        if appengine_config.PRODUCTION_MODE:
            app_id = app.get_application_id()
            href = ('https://appengine.google.com/'
                    'dashboard?app_id=s~%s' % app_id)
            bind('gae', 'Google App Engine', None, href=href)
        else:
            bind('gae',
                 'Google App Engine',
                 None,
                 href='http://localhost:8000/')
        bind('welcome', 'Welcome', None, href='/admin/welcome')
        bind('help',
             'Site Help',
             None,
             href='https://code.google.com/p/course-builder/wiki/AdminPage')
        bind('news',
             'News',
             None,
             href=('https://groups.google.com/forum/'
                   '?fromgroups#!forum/course-builder-announce'))
Exemple #6
0
    def bind_tabs(cls):

        def bind(key, label, handler, href=None):
            if href:
                target = '_blank'
            else:
                href = 'admin?action=admin&tab=%s' % key
                target = None

            tabs.Registry.register(
                cls.ACTION, key, label, contents=handler, href=href,
                target=target)

        bind('courses', 'Courses', cls.get_courses)
        bind('settings', 'Site Settings', cls.get_settings)
        bind('perf', 'Metrics', cls.get_perf)
        bind('deployment', 'Deployment', cls.get_deployment)

        if DIRECT_CODE_EXECUTION_UI_ENABLED:
            bind('console', 'Console', cls.get_console)

        if appengine_config.gcb_appstats_enabled():
            bind('stats', 'Appstats', None, href='/admin/stats/')

        if appengine_config.PRODUCTION_MODE:
            app_id = app.get_application_id()
            href = (
                'https://appengine.google.com/'
                'dashboard?app_id=s~%s' % app_id)
            bind('gae', 'Google App Engine', None, href=href)
        else:
            bind(
                 'gae', 'Google App Engine', None,
                 href='http://localhost:8000/')
        bind('welcome', 'Welcome', None, href='/admin/welcome')
        bind(
             'help', 'Site Help', None,
             href='https://code.google.com/p/course-builder/wiki/AdminPage')
        bind(
             'news', 'News', None,
             href=(
                'https://groups.google.com/forum/'
                '?fromgroups#!forum/course-builder-announce'))
Exemple #7
0
    analytics.get_global_handlers(),
    analytics.get_namespaced_handlers() +
    data_sources.get_namespaced_handlers() +
    student_labels.get_namespaced_handlers()
    ).enable()

# Collect routes (URL-matching regexes -> handler classes) for modules.
global_routes, namespaced_routes = custom_modules.Registry.get_all_routes()

# Configure routes available at '/%namespace%/' context paths
sites.ApplicationRequestHandler.bind(namespaced_routes)
app_routes = [(r'(.*)', sites.ApplicationRequestHandler)]

# enable Appstats handlers if requested
appstats_routes = []
if appengine_config.gcb_appstats_enabled():
    # pylint: disable-msg=g-import-not-at-top
    import google.appengine.ext.appstats.ui as appstats_ui
    # pylint: enable-msg=g-import-not-at-top

    # add all Appstats URL's to /admin/stats basepath
    for path, handler in appstats_ui.URLMAP:
        assert '.*' == path[:2]
        appstats_routes.append(('/admin/stats/%s' % path[3:], handler))

# i18n configuration for jinja2
webapp2_i18n_config = {'translations_path': os.path.join(
    appengine_config.BUNDLE_ROOT, 'modules/i18n/resources/locale')}

rosebotics_routes = [('/', main_handler.HomePage),
                     ('/courses', main_handler.CoursesPage),
        appengine_config.CORE_MODULE_NAME] = (
            models.StudentProfileDAO.unregister_user)

# Routes used by App Engine internals.
lifecycle_routes = [('/_ah/start', utils.NoopInstanceLifecycleRequestHandler)]

# Collect routes (URL-matching regexes -> handler classes) for modules.
global_routes, namespaced_routes = custom_modules.Registry.get_all_routes()

# Configure routes available at '/%namespace%/' context paths
sites.ApplicationRequestHandler.bind(namespaced_routes)
app_routes = [(r'(.*)', sites.ApplicationRequestHandler)]

# enable Appstats handlers if requested
appstats_routes = []
if appengine_config.gcb_appstats_enabled():
    import google.appengine.ext.appstats.ui as appstats_ui

    # add all Appstats URL's to /admin/stats basepath
    for path, handler in appstats_ui.URLMAP:
        assert '.*' == path[:2]
        appstats_routes.append(('/admin/stats/%s' % path[3:], handler))

# i18n configuration for jinja2
webapp2_i18n_config = {'translations_path': os.path.join(
    appengine_config.BUNDLE_ROOT, 'modules/i18n/resources/locale')}

# init application
app = users.AuthInterceptorWSGIApplication(
    None,
    config={'webapp2_extras.i18n': webapp2_i18n_config},
Exemple #9
0
 def can_view_appstats(app_context):
     return appengine_config.gcb_appstats_enabled()
Exemple #10
0
 def can_view_appstats(app_context):
     return appengine_config.gcb_appstats_enabled()