How to use the indico.core.config.config function in indico

To help you get started, weโ€™ve selected a few indico examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indico / indico / indico / cli / shell.py View on Github external
except ImportError:
        click.echo(cformat('%{red!}You need to `pip install ipython` to use the Indico shell'))
        sys.exit(1)

    current_app.config['REPL'] = True  # disables e.g. memoize_request
    request_stats_request_started()
    context, info = _make_shell_context()
    banner = cformat('%{yellow!}Indico v{} is ready for your commands').format(indico.__version__)
    if verbose:
        banner = '\n'.join(info + ['', banner])
    ctx = current_app.make_shell_context()
    ctx.update(context)
    clearCache()
    stack = ExitStack()
    if with_req_context:
        stack.enter_context(current_app.test_request_context(base_url=config.BASE_URL))
    with stack:
        ipython_app = TerminalIPythonApp.instance(user_ns=ctx, display_banner=False)
        ipython_app.initialize(argv=[])
        ipython_app.shell.show_banner(banner)
        ipython_app.start()
github indico / indico / indico / legacy / common / mail.py View on Github external
def _send(msgData):
        server = smtplib.SMTP(*config.SMTP_SERVER)
        if config.SMTP_USE_TLS:
            server.ehlo()
            (code, errormsg) = server.starttls()
            if code != 220:
                raise Exception('Cannot start secure connection to SMTP server: {}, {}'.format(code, errormsg))
        if config.SMTP_LOGIN:
            login = config.SMTP_LOGIN
            password = config.SMTP_PASSWORD
            (code, errormsg) = server.login(login, password)
            if code != 235:
                raise Exception('Cannot login on SMTP server: {}, {}'.format(code, errormsg))

        to_addrs = msgData['toList'] | msgData['ccList'] | msgData['bccList']
        try:
            Logger.get('mail').info('Sending email: To: {} / CC: {} / BCC: {}'.format(
                ', '.join(msgData['toList']) or 'None',
github indico / indico / indico / web / flask / session.py View on Github external
def save_session(self, app, session, response):
        domain = self.get_cookie_domain(app)
        secure = self.get_cookie_secure(app)
        refresh_sid = self.should_refresh_sid(app, session)
        if not session and not session.new:
            # empty session, delete it from storage and cookie
            self.storage.delete(session.sid)
            response.delete_cookie(app.session_cookie_name, domain=domain)
            return

        if not refresh_sid and not session.modified and not self.should_refresh_session(app, session):
            # If the session has not been modified we only store if it needs to be refreshed
            return

        if config.SESSION_LIFETIME > 0:
            # Setting session.permanent marks the session as modified so we only set it when we
            # are saving the session anyway!
            session.permanent = True

        storage_ttl = self.get_storage_lifetime(app, session)
        cookie_lifetime = self.get_expiration_time(app, session)
        session['_expires'] = datetime.now() + storage_ttl

        if refresh_sid:
            self.storage.delete(session.sid)
            session.sid = self.generate_sid()

        session['_secure'] = request.is_secure
        self.storage.set(session.sid, self.serializer.dumps(dict(session)), storage_ttl)
        response.set_cookie(app.session_cookie_name, session.sid, expires=cookie_lifetime, httponly=True,
                            secure=secure)
github indico / indico / indico / web / assets / bundles.py View on Github external
def configure_pyscss(environment):
    base_url_path = urlparse(config.BASE_URL).path
    environment.config['PYSCSS_STYLE'] = 'compact'
    environment.config['PYSCSS_DEBUG_INFO'] = False
    environment.config['PYSCSS_STATIC_URL'] = '{0}/static/'.format(base_url_path)
    environment.config['PYSCSS_LOAD_PATHS'] = [
        os.path.join(_get_client_path(), 'sass')
    ]
github indico / indico / indico / modules / events / abstracts / controllers / boa.py View on Github external
def _process(self):
        if not config.LATEX_ENABLED:
            raise NotFound
        return send_file('book-of-abstracts.pdf', create_boa(self.event), 'application/pdf')
github indico / indico / indico / legacy / webinterface / pages / conferences.py View on Github external
def getVars(self):
        v = wcomponents.WTemplated.getVars( self )
        v['site_name'] = core_settings.get('site_title')
        v['social'] = social_settings.get_all()

        event = self._conf.as_event
        v['image'] = event.logo_url if event.has_logo else (config.IMAGES_BASE_URL + '/logo_indico.png')
        v['description'] = strip_ml_tags(self._conf.as_event.description[:500].encode('utf-8'))
        return v
github indico / indico / indico / modules / cephalopod / util.py View on Github external
def _get_url():
    return url_join(config.COMMUNITY_HUB_URL, 'api/instance/')
github indico / indico / indico / core / plugins / __init__.py View on Github external
def _setup_assets(self):
        url_base_path = urlparse(config.BASE_URL).path
        output_dir = os.path.join(config.ASSETS_DIR, 'plugin-{}'.format(self.name))
        output_url = '{}/static/assets/plugin-{}'.format(url_base_path, self.name)
        static_dir = os.path.join(self.root_path, 'static')
        static_url = '{}/static/plugins/{}'.format(url_base_path, self.name)
        self.assets = LazyCacheEnvironment(output_dir, output_url, debug=config.DEBUG,
                                           cache=get_webassets_cache_dir(self.name))
        self.assets.append_path(output_dir, output_url)
        self.assets.append_path(static_dir, static_url)
        configure_pyscss(self.assets)
        self.register_assets()
github indico / indico / indico / modules / auth / controllers.py View on Github external
def moderate_registrations(self):
        return config.LOCAL_MODERATION
github indico / indico / indico / modules / rb / util.py View on Github external
def is_booking_start_within_grace_period(start_dt, user, allow_admin=False):
    from indico.modules.rb import rb_settings

    if allow_admin and rb_is_admin(user):
        return True

    default_tz = pytz.timezone(config.DEFAULT_TIMEZONE)
    start_dt_localized = default_tz.localize(start_dt)
    grace_period = rb_settings.get('grace_period')
    if grace_period is None:
        today = server_to_utc(datetime.now()).astimezone(default_tz).date()
        return start_dt_localized.date() >= today

    start_dt_utc = start_dt_localized.astimezone(pytz.utc)
    grace_period = timedelta(hours=grace_period)
    return start_dt_utc >= now_utc() - grace_period