Example #1
0
def render_session_bar(protected_object=None, local_tz=None, force_local_tz=False):
    protection_disclaimers = {
        'network': legal_settings.get('network_protected_disclaimer'),
        'restricted': legal_settings.get('restricted_disclaimer')
    }
    default_tz = config.DEFAULT_TIMEZONE
    if session.user:
        user_tz = session.user.settings.get('timezone', default_tz)
        if session.timezone == 'LOCAL':
            tz_mode = 'local'
        elif session.timezone == user_tz:
            tz_mode = 'user'
        else:
            tz_mode = 'custom'
    else:
        user_tz = None
        tz_mode = 'local' if session.timezone == 'LOCAL' else 'custom'
    active_tz = _get_timezone_display(local_tz, session.timezone, force_local_tz)
    timezones = common_timezones
    if active_tz not in common_timezones_set:
        timezones = list(common_timezones) + [active_tz]
    timezone_data = {
        'disabled': force_local_tz,
        'user_tz': user_tz,
        'active_tz': active_tz,
        'tz_mode': tz_mode,
        'timezones': timezones,
    }
    tpl = get_template_module('_session_bar.html')
    rv = tpl.render_session_bar(protected_object=protected_object,
                                protection_disclaimers=protection_disclaimers,
                                timezone_data=timezone_data,
                                languages=get_all_locales())
    return Markup(rv)
Example #2
0
def render_session_bar(protected_object=None, local_tz=None, force_local_tz=False):
    protection_disclaimers = {
        'network': legal_settings.get('network_protected_disclaimer'),
        'restricted': legal_settings.get('restricted_disclaimer')
    }
    default_tz = config.DEFAULT_TIMEZONE
    if session.user:
        user_tz = session.user.settings.get('timezone', default_tz)
        if session.timezone == 'LOCAL':
            tz_mode = 'local'
        elif session.timezone == user_tz:
            tz_mode = 'user'
        else:
            tz_mode = 'custom'
    else:
        user_tz = None
        tz_mode = 'local' if session.timezone == 'LOCAL' else 'custom'
    active_tz = _get_timezone_display(local_tz, session.timezone, force_local_tz)
    timezones = common_timezones
    if active_tz not in common_timezones_set:
        timezones = list(common_timezones) + [active_tz]
    timezone_data = {
        'disabled': force_local_tz,
        'user_tz': user_tz,
        'active_tz': active_tz,
        'tz_mode': tz_mode,
        'timezones': timezones,
    }
    tpl = get_template_module('_session_bar.html')
    rv = tpl.render_session_bar(protected_object=protected_object,
                                protection_disclaimers=protection_disclaimers,
                                timezone_data=timezone_data,
                                languages=get_all_locales())
    return Markup(rv)
Example #3
0
File: user.py Project: NIIF/indico
 def _getAnswer(self):
     if self._lang and self._lang in get_all_locales():
         self._target.setLang(self._lang)
         set_session_lang(self._lang)
         return True
     else:
         return False
Example #4
0
    def getVars(self):
        vars = WTemplated.getVars(self)

        vars["currentUser"] = self._currentuser

        config = Config.getInstance()
        imgLogin = config.getSystemIconURL("login")

        vars["imgLogin"] = imgLogin
        vars["isFrontPage"] = self._isFrontPage
        vars["currentCategory"] = self.__currentCategory
        vars['prot_obj'] = self._prot_obj

        current_locale = get_current_locale()
        vars["ActiveTimezone"] = session.timezone
        """
            Get the timezone for displaying on top of the page.
            1. If the user has "LOCAL" timezone then show the timezone
            of the event/category. If that's not possible just show the
            standard timezone.
            2. If the user has a custom timezone display that one.
        """
        vars["ActiveTimezoneDisplay"] = self._getTimezoneDisplay(
            vars["ActiveTimezone"])

        vars["SelectedLanguage"] = str(current_locale)
        vars["SelectedLanguageName"] = current_locale.language_name
        vars["Languages"] = get_all_locales()

        if DBMgr.getInstance().isConnected():
            vars["title"] = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getTitle()
            vars["organization"] = info.HelperMaKaCInfo.getMaKaCInfoInstance(
            ).getOrganisation()
        else:
            vars["title"] = "Indico"
            vars["organization"] = ""

        vars['roomBooking'] = Config.getInstance().getIsRoomBookingActive()
        vars['protectionDisclaimerProtected'] = legal_settings.get(
            'network_protected_disclaimer')
        vars['protectionDisclaimerRestricted'] = legal_settings.get(
            'restricted_disclaimer')
        #Build a list of items for the administration menu
        adminItemList = []
        if session.user and session.user.is_admin:
            adminItemList.append({
                'id': 'serverAdmin',
                'url': urlHandlers.UHAdminArea.getURL(),
                'text': _("Server admin")
            })

        vars["adminItemList"] = adminItemList
        vars['extra_items'] = HeaderMenuEntry.group(
            values_from_signal(signals.indico_menu.send()))
        vars["getProtection"] = self._getProtection

        vars["show_contact"] = config.getPublicSupportEmail() is not None

        return vars
Example #5
0
def _get_i18n_locale(locale_name, react=False):
    """Retrieve a locale in a Jed-compatible format."""

    # Ensure we have a valid locale. en_GB is our source locale and thus always considered
    # valid, even if it doesn't exist (dev setup where the user did not compile any locales)
    # since otherwise we'd have no valid locales at all and get a redirect loop
    all_locales = get_all_locales()
    if locale_name not in all_locales and locale_name != 'en_GB':
        fallback = config.DEFAULT_LOCALE if config.DEFAULT_LOCALE in all_locales else 'en_GB'
        return redirect(url_for(request.endpoint, locale_name=fallback))

    react_suffix = '-react' if react else ''
    try:
        cache_file = os.path.join(config.CACHE_DIR, 'assets_i18n_{}{}_{}_{}.js'.format(
            locale_name, react_suffix, indico.__version__, config.hash))
    except UnicodeEncodeError:
        raise NotFound

    if config.DEBUG or not os.path.exists(cache_file):
        i18n_data = generate_i18n_file(locale_name, react=react)
        if i18n_data is None:
            raise NotFound
        with open(cache_file, 'w') as f:
            f.write("window.{} = {};".format('REACT_TRANSLATIONS' if react else 'TRANSLATIONS', i18n_data))

    return send_file(f'{locale_name}{react_suffix}.js', cache_file, mimetype='application/javascript',
                     conditional=True)
Example #6
0
def render_session_bar(protected_object=None,
                       local_tz=None,
                       force_local_tz=False):
    protection_disclaimers = {
        'network': legal_settings.get('network_protected_disclaimer'),
        'restricted': legal_settings.get('restricted_disclaimer')
    }
    timezone_data = {
        'active_tz':
        session.timezone,
        'active_tz_display':
        _get_timezone_display(local_tz, session.timezone, force_local_tz),
        'user_tz':
        session.avatar.getTimezone() if session.user else None,
        'user_tz_display_mode':
        session.avatar.getDisplayTZMode() if session.user else None,
        'disabled':
        force_local_tz
    }
    tpl = get_template_module('_session_bar.html')
    rv = tpl.render_session_bar(protected_object=protected_object,
                                protection_disclaimers=protection_disclaimers,
                                timezone_data=timezone_data,
                                languages=get_all_locales())
    return Markup(rv)
Example #7
0
 def _process(self):
     language = request.form['lang']
     if language not in get_all_locales():
         raise UserValueError('Invalid language')
     session.lang = language
     if session.user:
         session.user.settings.set('lang', language)
     return '', 204
Example #8
0
 def __init__(self, *args, **kwargs):
     super(UserPreferencesForm, self).__init__(*args, **kwargs)
     self.lang.choices = sorted(get_all_locales().items(),
                                key=itemgetter(1))
     self.timezone.choices = zip(common_timezones, common_timezones)
     if self.timezone.object_data and self.timezone.object_data not in common_timezones_set:
         self.timezone.choices.append(
             (self.timezone.object_data, self.timezone.object_data))
Example #9
0
 def _process(self):
     language = request.form['lang']
     if language not in get_all_locales():
         raise UserValueError('Invalid language')
     session.lang = language
     if session.user:
         session.user.settings.set('lang', language)
     return '', 204
Example #10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        locales = [(code, f'{name} ({territory})' if territory else name)
                   for code, (name, territory, __) in get_all_locales().items()]
        self.lang.choices = sorted(locales, key=itemgetter(1))
        self.timezone.choices = list(zip(common_timezones, common_timezones))
        if self.timezone.object_data and self.timezone.object_data not in common_timezones_set:
            self.timezone.choices.append((self.timezone.object_data, self.timezone.object_data))
Example #11
0
 def _process_GET(self):
     if User.query.filter_by(is_system=False).has_rows():
         return redirect(url_for_index())
     return render_template('bootstrap/bootstrap.html',
                            form=BootstrapForm(),
                            timezone=Config.getInstance().getDefaultTimezone(),
                            languages=get_all_locales(),
                            indico_version=indico.__version__,
                            python_version=python_version())
Example #12
0
File: forms.py Project: wdbm/indico
    def __init__(self, *args, **kwargs):
        super(UserPreferencesForm, self).__init__(*args, **kwargs)

        locales = [(code, '{} ({})'.format(name, territory) if territory else name)
                   for code, (name, territory) in get_all_locales().iteritems()]
        self.lang.choices = sorted(locales, key=itemgetter(1))
        self.timezone.choices = zip(common_timezones, common_timezones)
        if self.timezone.object_data and self.timezone.object_data not in common_timezones_set:
            self.timezone.choices.append((self.timezone.object_data, self.timezone.object_data))
Example #13
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     genInfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     vars["title"] = genInfo.getTitle()
     vars["organisation"] = genInfo.getOrganisation()
     vars["city"] = genInfo.getCity()
     vars["country"] = genInfo.getCountry()
     vars["language"] = Config.getInstance().getDefaultLocale()
     vars["language_list"] = get_all_locales()
     return vars
Example #14
0
 def _process_GET(self):
     if User.has_rows():
         return redirect(url_for('misc.index'))
     return render_template('bootstrap/bootstrap.html',
                            selected_lang_name=parse_locale(get_current_locale()).language_name,
                            language_options=sorted(get_all_locales().items(), key=itemgetter(1)),
                            form=BootstrapForm(language=session.lang),
                            timezone=Config.getInstance().getDefaultTimezone(),
                            indico_version=MaKaC.__version__,
                            python_version=python_version())
Example #15
0
def make_app(testing=False, config_override=None):
    # If you are reading this code and wonder how to access the app:
    # >>> from flask import current_app as app
    # This only works while inside an application context but you really shouldn't have any
    # reason to access it outside this method without being inside an application context.

    if _app_ctx_stack.top:
        Logger.get('flask').warning(
            'make_app called within app context, using existing app')
        return _app_ctx_stack.top.app
    app = IndicoFlask('indico',
                      static_folder='web/static',
                      static_url_path='/',
                      template_folder='web/templates')
    app.config['TESTING'] = testing
    app.config['INDICO'] = load_config(only_defaults=testing,
                                       override=config_override)
    configure_app(app)

    with app.app_context():
        if not testing:
            Logger.init(app)
            init_sentry(app)
        celery.init_app(app)
        cache.init_app(app)
        babel.init_app(app)
        if config.DEFAULT_LOCALE not in get_all_locales():
            Logger.get('i18n').error(
                f'Configured DEFAULT_LOCALE ({config.DEFAULT_LOCALE}) does not exist'
            )
        multipass.init_app(app)
        setup_oauth_provider(app)
        webpack.init_app(app)
        setup_jinja(app)
        configure_db(app)
        mm.init_app(app)  # must be called after `configure_db`!
        limiter.init_app(app)
        extend_url_map(app)
        add_handlers(app)
        setup_request_stats(app)
        add_blueprints(app)
        plugin_engine.init_app(app, Logger.get('plugins'))
        if not plugin_engine.load_plugins(app):
            raise Exception('Could not load some plugins: {}'.format(', '.join(
                plugin_engine.get_failed_plugins(app))))
        setup_jinja_customization(app)
        # Below this points plugins are available, i.e. sending signals makes sense
        add_plugin_blueprints(app)
        # themes can be provided by plugins
        signals.core.app_created.send(app)
        config.validate()
        check_db()

    return app
Example #16
0
 def _process_GET(self):
     if User.query.filter_by(is_system=False).has_rows():
         return redirect(url_for_index())
     return render_template('bootstrap/bootstrap.html',
                            form=BootstrapForm(),
                            timezone=config.DEFAULT_TIMEZONE,
                            languages=get_all_locales(),
                            operating_system=get_os(),
                            postgres_version=get_postgres_version(),
                            indico_version=indico.__version__,
                            python_version=python_version())
Example #17
0
 def _process_GET(self):
     if User.query.filter_by(is_system=False).has_rows():
         return redirect(url_for_index())
     return render_template('bootstrap/bootstrap.html',
                            form=BootstrapForm(),
                            timezone=config.DEFAULT_TIMEZONE,
                            languages=get_all_locales(),
                            operating_system=get_os(),
                            postgres_version=get_postgres_version(),
                            indico_version=indico.__version__,
                            python_version=python_version())
Example #18
0
 def _process_GET(self):
     if User.has_rows():
         return redirect(url_for('misc.index'))
     return render_template(
         'bootstrap/bootstrap.html',
         selected_lang_name=parse_locale(
             get_current_locale()).language_name,
         language_options=sorted(get_all_locales().items(),
                                 key=itemgetter(1)),
         form=BootstrapForm(language=session.lang),
         timezone=Config.getInstance().getDefaultTimezone(),
         indico_version=MaKaC.__version__,
         python_version=python_version())
Example #19
0
    def getVars( self ):
        vars = WTemplated.getVars(self)

        vars["currentUser"] = self._currentuser

        config =  Config.getInstance()
        imgLogin = config.getSystemIconURL("login")

        vars["imgLogin"] = imgLogin
        vars["isFrontPage"] = self._isFrontPage
        vars["currentCategory"] = self.__currentCategory
        vars['prot_obj'] = self._prot_obj

        current_locale = get_current_locale()
        vars["ActiveTimezone"] = session.timezone
        """
            Get the timezone for displaying on top of the page.
            1. If the user has "LOCAL" timezone then show the timezone
            of the event/category. If that's not possible just show the
            standard timezone.
            2. If the user has a custom timezone display that one.
        """
        vars["ActiveTimezoneDisplay"] = self._getTimezoneDisplay(vars["ActiveTimezone"])

        vars["SelectedLanguage"] = str(current_locale)
        vars["SelectedLanguageName"] = current_locale.language_name
        vars["Languages"] = get_all_locales()

        if DBMgr.getInstance().isConnected():
            vars["title"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTitle()
            vars["organization"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getOrganisation()
        else:
            vars["title"] = "Indico"
            vars["organization"] = ""

        vars['roomBooking'] = Config.getInstance().getIsRoomBookingActive()
        vars['protectionDisclaimerProtected'] = legal_settings.get('network_protected_disclaimer')
        vars['protectionDisclaimerRestricted'] = legal_settings.get('restricted_disclaimer')
        #Build a list of items for the administration menu
        adminItemList = []
        if session.user and session.user.is_admin:
            adminItemList.append({'id': 'serverAdmin', 'url': urlHandlers.UHAdminArea.getURL(),
                                  'text': _("Server admin")})

        vars["adminItemList"] = adminItemList
        vars['extra_items'] = HeaderMenuEntry.group(values_from_signal(signals.indico_menu.send()))
        vars["getProtection"] = self._getProtection

        vars["show_contact"] = config.getPublicSupportEmail() is not None

        return vars
Example #20
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     genInfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     vars["title"] = genInfo.getTitle()
     vars["organisation"] = genInfo.getOrganisation()
     vars["city"] = genInfo.getCity()
     vars["country"] = genInfo.getCountry()
     try:
         selected_tz = genInfo.getTimezone()
     except:
         selected_tz = 'UTC'
     vars["timezone"] = TimezoneRegistry.getShortSelectItemsHTML(selected_tz)
     vars["language"] = genInfo.getLang()
     vars["language_list"] = get_all_locales()
     return vars
Example #21
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     genInfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     vars["title"] = genInfo.getTitle()
     vars["organisation"] = genInfo.getOrganisation()
     vars["city"] = genInfo.getCity()
     vars["country"] = genInfo.getCountry()
     try:
         selected_tz = genInfo.getTimezone()
     except:
         selected_tz = 'UTC'
     vars["timezone"] = TimezoneRegistry.getShortSelectItemsHTML(
         selected_tz)
     vars["language"] = genInfo.getLang()
     vars["language_list"] = get_all_locales()
     return vars
Example #22
0
    def _process(self):
        if User.query.filter_by(is_system=False).has_rows():
            return redirect(url_for_index())

        form = BootstrapForm()
        if form.validate_on_submit():
            return self._handle_submit(form)

        return render_template(
            'bootstrap/bootstrap.html',
            form=form,
            timezone=config.DEFAULT_TIMEZONE,
            languages=get_all_locales(),
            operating_system=get_os(),
            postgres_version=get_postgres_version(),
            indico_version=indico.__version__,
            python_version=python_version(),
            show_local_warning=(config.DEBUG
                                or is_private_url(request.url_root)))
Example #23
0
 def _process(self):
     tos_url = legal_settings.get('tos_url')
     tos_html = sanitize_html(legal_settings.get('tos')) or None
     privacy_policy_url = legal_settings.get('privacy_policy_url')
     privacy_policy_html = sanitize_html(legal_settings.get('privacy_policy')) or None
     if tos_url:
         tos_html = None
     if privacy_policy_url:
         privacy_policy_html = None
     return jsonify(rooms_sprite_token=unicode(_cache.get('rooms-sprite-token', '')),
                    languages=get_all_locales(),
                    tileserver_url=rb_settings.get('tileserver_url'),
                    grace_period=rb_settings.get('grace_period'),
                    managers_edit_rooms=rb_settings.get('managers_edit_rooms'),
                    help_url=config.HELP_URL,
                    contact_email=config.PUBLIC_SUPPORT_EMAIL,
                    has_tos=bool(tos_url or tos_html),
                    tos_html=tos_html,
                    has_privacy_policy=bool(privacy_policy_url or privacy_policy_html),
                    privacy_policy_html=privacy_policy_html)
Example #24
0
def generate_i18n_file(locale_name, react=False):
    if locale_name not in get_all_locales():
        return None
    root_path = os.path.join(current_app.root_path, 'translations')
    i18n_data = get_locale_data(root_path, locale_name, 'indico', react=react)
    if not i18n_data:
        # Dummy data, not having the indico domain would cause lots of failures
        i18n_data = {'indico': {'': {'domain': 'indico', 'lang': locale_name}}}

    for pid, plugin in plugin_engine.get_active_plugins().items():
        data = {}
        if plugin.translation_path:
            data = get_locale_data(plugin.translation_path,
                                   locale_name,
                                   pid,
                                   react=react)
        if not data:
            # Dummy entry so we can still load the domain
            data = {pid: {'': {'domain': pid, 'lang': locale_name}}}
        i18n_data.update(data)
    return json.dumps(i18n_data)
Example #25
0
 def __init__(self, *args, **kwargs):
     super(UserPreferencesForm, self).__init__(*args, **kwargs)
     self.lang.choices = sorted(get_all_locales().items(), key=itemgetter(1))
     self.timezone.choices = zip(common_timezones, common_timezones)
     if self.timezone.object_data and self.timezone.object_data not in common_timezones_set:
         self.timezone.choices.append((self.timezone.object_data, self.timezone.object_data))
Example #26
0
 def __init__(self, *args, **kwargs):
     super(UserPreferencesForm, self).__init__(*args, **kwargs)
     self.lang.choices = sorted(get_all_locales().items(),
                                key=itemgetter(1))
     self.timezone.choices = zip(all_timezones, all_timezones)
Example #27
0
File: users.py Project: fph/indico
def _get_all_locales():
    return set(get_all_locales())
Example #28
0
 def _process(self):
     return jsonify(rooms_sprite_token=unicode(
         _cache.get('rooms-sprite-token', '')),
                    languages=get_all_locales(),
                    tileserver_url=rb_settings.get('tileserver_url'))
Example #29
0
 def __init__(self, *args, **kwargs):
     super(UserPreferencesForm, self).__init__(*args, **kwargs)
     self.lang.choices = sorted(get_all_locales().items(), key=itemgetter(1))
     self.timezone.choices = zip(all_timezones, all_timezones)
Example #30
0
 def __init__(self, *args, **kwargs):
     super(BootstrapForm, self).__init__(*args, **kwargs)
     self.language.choices = sorted(get_all_locales().items(), key=itemgetter(1))
Example #31
0
def generate_global_file():
    locations = Location.find_all() if config.ENABLE_ROOMBOOKING else []
    location_names = {loc.name: loc.name for loc in locations}
    default_location = next((loc.name for loc in locations if loc.is_default),
                            None)
    ext_auths = [{
        'name': auth.name,
        'title': auth.title,
        'supports_groups': auth.supports_groups
    } for auth in multipass.identity_providers.itervalues()
                 if auth.supports_search]

    indico_vars = {
        'Urls': {
            'Base':
            config.BASE_URL,
            'BasePath':
            url_parse(config.BASE_URL).path.rstrip('/'),
            'JsonRpcService':
            url_for('api.jsonrpc'),
            'ExportAPIBase':
            url_for('api.httpapi', prefix='export'),
            'APIBase':
            url_for('api.httpapi', prefix='api'),
            'ImagesBase':
            config.IMAGES_BASE_URL,
            'Login':
            url_for_login(),
            'Favorites':
            url_for('users.user_favorites'),
            'FavoriteUserAdd':
            url_for('users.user_favorites_users_add'),
            'FavoriteUserRemove':
            url_rule_to_js('users.user_favorites_user_remove'),
            'AttachmentManager':
            url_rule_to_js('attachments.management'),
            'ManagementAttachmentInfoColumn':
            url_rule_to_js('attachments.management_info_column'),
            'RoomBookingBookRoom':
            url_rule_to_js('rooms.room_book'),
            'RoomBookingBook':
            url_rule_to_js('rooms.book'),
            'RoomBookingDetails':
            url_rule_to_js('rooms.roomBooking-roomDetails'),
            'RoomBookingCloneBooking':
            url_rule_to_js('rooms.roomBooking-cloneBooking'),
            'APIKeyCreate':
            url_for('api.key_create'),
            'APIKeyTogglePersistent':
            url_for('api.key_toggle_persistent'),
            'FontSassBundle':
            current_app.manifest['fonts.css']._paths,
            'EventCreation':
            url_rule_to_js('events.create'),
            'PermissionsDialog':
            url_rule_to_js('event_management.permissions_dialog'),
            'RegistrationForm': {
                'section': {
                    'add':
                    url_rule_to_angular('event_registration.add_section'),
                    'modify':
                    url_rule_to_angular('event_registration.modify_section'),
                    'toggle':
                    url_rule_to_angular('event_registration.toggle_section'),
                    'move':
                    url_rule_to_angular('event_registration.move_section')
                },
                'field': {
                    'add':
                    url_rule_to_angular('event_registration.add_field'),
                    'modify':
                    url_rule_to_angular('event_registration.modify_field'),
                    'toggle':
                    url_rule_to_angular('event_registration.toggle_field'),
                    'move':
                    url_rule_to_angular('event_registration.move_field')
                },
                'text': {
                    'add': url_rule_to_angular('event_registration.add_text'),
                    'modify':
                    url_rule_to_angular('event_registration.modify_text'),
                    'toggle':
                    url_rule_to_angular('event_registration.toggle_text'),
                    'move': url_rule_to_angular('event_registration.move_text')
                }
            },
            'Timetable': {
                'management': url_rule_to_js('timetable.management'),
                'default_pdf': url_rule_to_js('timetable.export_default_pdf'),
                'pdf': url_rule_to_js('timetable.export_pdf'),
                'reschedule': url_rule_to_js('timetable.reschedule'),
                'breaks': {
                    'add': url_rule_to_js('timetable.add_break')
                },
                'contributions': {
                    'add':
                    url_rule_to_js('timetable.add_contribution'),
                    'notScheduled':
                    url_rule_to_js('timetable.not_scheduled'),
                    'schedule':
                    url_rule_to_js('timetable.schedule'),
                    'protection':
                    url_rule_to_js('contributions.manage_contrib_protection'),
                    'clone':
                    url_rule_to_js('timetable.clone_contribution')
                },
                'sessionBlocks': {
                    'add': url_rule_to_js('timetable.add_session_block'),
                    'fit': url_rule_to_js('timetable.fit_session_block')
                },
                'sessions': {
                    'add': url_rule_to_js('timetable.add_session')
                },
                'entries': {
                    'delete': url_rule_to_js('timetable.delete_entry'),
                    'edit': url_rule_to_js('timetable.edit_entry'),
                    'editDatetime':
                    url_rule_to_js('timetable.edit_entry_datetime'),
                    'editTime': url_rule_to_js('timetable.edit_entry_time'),
                    'move': url_rule_to_js('timetable.move_entry'),
                    'shift': url_rule_to_js('timetable.shift_entries'),
                    'swap': url_rule_to_js('timetable.swap_entries'),
                    'info': {
                        'display': url_rule_to_js('timetable.entry_info'),
                        'manage':
                        url_rule_to_js('timetable.entry_info_manage'),
                    },
                }
            },
            'Contributions': {
                'display_contribution':
                url_rule_to_js('contributions.display_contribution')
            },
            'Sessions': {
                'display_session': url_rule_to_js('sessions.display_session')
            },
            'Categories': {
                'info': url_rule_to_js('categories.info'),
                'infoFrom': url_rule_to_js('categories.info_from'),
                'search': url_rule_to_js('categories.search')
            }
        },
        'Data': {
            'WeekDays': [
                'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
                'Friday', 'Saturday'
            ],
            'DefaultLocation':
            default_location,
            'Locations':
            location_names
        },
        'Settings': {
            'ExtAuthenticators': ext_auths,
            'RoomBookingModuleActive': config.ENABLE_ROOMBOOKING,
            'Languages': get_all_locales(),
        },
        'FileRestrictions': {
            'MaxUploadFilesTotalSize': config.MAX_UPLOAD_FILES_TOTAL_SIZE,
            'MaxUploadFileSize': config.MAX_UPLOAD_FILE_SIZE
        }
    }

    return render_template('assets/vars_globals.js',
                           indico_vars=indico_vars,
                           config=config)
Example #32
0
File: misc.py Project: jas01/indico
 def _process(self):
     return jsonify(rooms_sprite_token=unicode(_cache.get('rooms-sprite-token', '')),
                    languages=get_all_locales(),
                    tileserver_url=rb_settings.get('tileserver_url'))
Example #33
0
File: user.py Project: NIIF/indico
 def _getAnswer(self):
     return list(get_all_locales().iteritems())
Example #34
0
 def _get_all_locales():
     # We need babel linked to a Flask app to get the list of locales
     babel.init_app(Flask('indico'))
     return get_all_locales()
Example #35
0
def _get_all_locales():
    return set(get_all_locales())
Example #36
0
 def __init__(self, *args, **kwargs):
     super(BootstrapForm, self).__init__(*args, **kwargs)
     self.language.choices = sorted(get_all_locales().items(),
                                    key=itemgetter(1))