当前位置: 首页>>代码示例>>Python>>正文


Python common.HelperMaKaCInfo类代码示例

本文整理汇总了Python中MaKaC.common.HelperMaKaCInfo的典型用法代码示例。如果您正苦于以下问题:Python HelperMaKaCInfo类的具体用法?Python HelperMaKaCInfo怎么用?Python HelperMaKaCInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HelperMaKaCInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_dummy_users

def create_dummy_users():
    """
    Creates a dummy user for testing purposes
    """
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
    ah = AvatarHolder()
    authManager = AuthenticatorMgr()
    avatars = []
    al = minfo.getAdminList()

    avatar = create_user("fake", "dummyuser", authManager)
    ah.add(avatar)
    avatars.append(avatar)
    al.grant(avatar)

    for i in xrange(1, 5):
        avatar = create_user("fake-%d" % i, "fake-%d" % i, authManager)
        avatar.setId("fake-%d" % i)
        ah.add(avatar)
        avatars.append(avatar)

    # since the DB is empty, we have to add dummy user as admin
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()

    dc = DefaultConference()
    HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(dc)
    return avatars
开发者ID:ferhatelmas,项目名称:indico,代码行数:27,代码来源:default_actions.py

示例2: create_dummy_user

def create_dummy_user():
    """
    Creates a dummy user for testing purposes
    """
    avatar = Avatar()

    avatar.setName("fake")
    avatar.setSurName("fake")
    avatar.setOrganisation("fake")
    avatar.setLang("en_GB")
    avatar.setEmail("[email protected]")

    # registering user
    ah = AvatarHolder()
    ah.add(avatar)

    # setting up the login info
    li = LoginInfo("dummyuser", "dummyuser")
    ih = AuthenticatorMgr()
    userid = ih.createIdentity(li, avatar, "Local")
    ih.add(userid)

    # activate the account
    avatar.activateAccount()

    # since the DB is empty, we have to add dummy user as admin
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()

    al = minfo.getAdminList()
    al.grant(avatar)

    dc = DefaultConference()
    HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(dc)
    return avatar
开发者ID:arturodr,项目名称:indico,代码行数:34,代码来源:default_actions.py

示例3: create_dummy_users

def create_dummy_users(dummyuser_has_password=False):
    """
    Creates a dummy user for testing purposes.

    If dummyuser_has_password is set, "dummyuser" and "fake-1" can be used for logging in.
    """
    minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
    ah = AvatarHolder()
    authManager = AuthenticatorMgr()
    avatars = []
    al = minfo.getAdminList()

    avatar = create_user("fake", "dummyuser", authManager, dummyuser_has_password)
    ah.add(avatar)
    avatars.append(avatar)
    al.grant(avatar)

    for i in xrange(1, 5):
        avatar = create_user("fake-%d" % i, "fake-%d" % i, authManager, dummyuser_has_password and i == 1)
        avatar.setId("fake-%d" % i)
        ah.add(avatar)
        avatars.append(avatar)

    HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(DefaultConference())
    return avatars
开发者ID:Json-Andriopoulos,项目名称:indico,代码行数:25,代码来源:default_actions.py

示例4: _create_user

    def _create_user(self, form, handler):
        data = form.data
        existing_user_id = session.get('register_pending_user')
        if existing_user_id:
            # Get pending user and set it as non-pending
            user = User.get(existing_user_id)
            user.is_pending = False
        else:
            user = User(first_name=data['first_name'], last_name=data['last_name'], email=data['email'],
                        address=data.get('address', ''), phone=data.get('phone', ''), affiliation=data['affiliation'])

        identity = handler.create_identity(data)
        user.identities.add(identity)
        user.secondary_emails = handler.extra_emails - {user.email}
        user.favorite_users.add(user)
        db.session.add(user)
        minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
        timezone = session.timezone
        if timezone == 'LOCAL':
            timezone = minfo.getTimezone()
        user.settings.set('timezone', timezone)
        user.settings.set('lang', session.lang or minfo.getLang())
        handler.update_user(user, form)
        db.session.flush()
        login_user(user, identity)
        msg = _('You have sucessfully registered your Indico profile. '
                'Check <a href="{url}">your profile</a> for further details and settings.')
        flash(Markup(msg).format(url=url_for('users.user_profile')), 'success')
        return handler.redirect_success()
开发者ID:marcosmolla,项目名称:indico,代码行数:29,代码来源:controllers.py

示例5: server_to_utc

def server_to_utc(dt):
    """Converts the given datetime in the server's TZ to UTC.

    The given datetime **MUST** be naive but already contain the correct time in the server's TZ.
    """
    server_tz = get_timezone(HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone())
    return server_tz.localize(dt).astimezone(pytz.utc)
开发者ID:sofian86,项目名称:indico-gh-test,代码行数:7,代码来源:date_time.py

示例6: remote_addr

 def remote_addr(self):
     """The remote address of the client."""
     with DBMgr.getInstance().global_connection():
         if HelperMaKaCInfo.getMaKaCInfoInstance().useProxy():
             if self.access_route:
                 return self.access_route[0]
     return super(IndicoRequest, self).remote_addr
开发者ID:NIIF,项目名称:indico,代码行数:7,代码来源:wrappers.py

示例7: _process

 def _process(self):
     minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
     cfg = minfo.getSocialAppConfig()
     if 'socialActive' in self._params:
         cfg['active'] = self._params.get('socialActive') == 'yes'
     if 'facebook_appId' in self._params:
         cfg.setdefault('facebook', PersistentDict())['appId'] = self._params.get('facebook_appId')
     self._redirect( urlHandlers.UHAdminLayoutGeneral.getURL() )
开发者ID:belokop,项目名称:indico_bare,代码行数:8,代码来源:admins.py

示例8: _can_access

def _can_access(cls, obj, user, **kwargs):
    """Grant full access to attachments/folders to certain IPs"""
    from MaKaC.common import HelperMaKaCInfo
    if not has_request_context():
        return
    full_access_ips = HelperMaKaCInfo.getMaKaCInfoInstance().getIPBasedACLMgr().get_full_access_acl()
    if request.remote_addr in full_access_ips:
        return True
开发者ID:hennogous,项目名称:indico,代码行数:8,代码来源:__init__.py

示例9: _checkProtection

 def _checkProtection(self):
     RHProtected._checkProtection(self)
     if not session.user and not self._doProcess:
         return
     self._al = HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
     if not session.user.isAdmin():
         if not self._al.getList():  # XXX can we just fail here instead of pretending the user is an admin?!
             return
         raise AdminError("area")
开发者ID:NIIF,项目名称:indico,代码行数:9,代码来源:admins.py

示例10: _create_home

 def _create_home(self):
     # get default/selected view
     styleMgr = HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
     view = self._rh._target.getDefaultStyle()
     # if no default view was attributed, then get the configuration default
     if view == "" or not styleMgr.existsStyle(view) or view in styleMgr.getXSLStyles():
         view = styleMgr.getDefaultStyleForEventType(self._eventType)
     p = WPTPLStaticConferenceDisplay(self._rh, self._rh._target, view, self._eventType, self._rh._reqParams)
     self._html = p.display(**self._rh._getRequestParams())
开发者ID:MichelCordeiro,项目名称:indico,代码行数:9,代码来源:offlineWebsiteCreator.py

示例11: _getSectionsHTML

    def _getSectionsHTML(self):
        modPay=self._conf.getModPay()
        html=[]
        enabledBulb = Configuration.Config.getInstance().getSystemIconURL( "enabledSection" )
        notEnabledBulb = Configuration.Config.getInstance().getSystemIconURL( "disabledSection" )
        enabledText = _("Click to disable")
        disabledText = _("Click to enable")
        for gs in modPay.getSortedModPay():
                      
            urlStatus = urlHandlers.UHConfModifEPaymentEnableSection.getURL(self._conf)
            urlStatus.addParam("epayment", gs.getId())
            urlModif = gs.getConfModifEPaymentURL(self._conf)
            img = enabledBulb
            text = enabledText
            if not gs.isEnabled():
                img = notEnabledBulb
                text = disabledText

            # CERN Plugin: Just admins can see and modify it
            if gs.getId() == "CERNYellowPay":
                minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
                al = minfo.getAdminList()
                if not al.isAdmin( self._user ):
                    from MaKaC.plugins.EPayment.CERNYellowPay.options import globalOptions
                    endis="enable"
                    departmentName = globalOptions[1][1]["defaultValue"]
                    emailAddress = globalOptions[0][1]["defaultValue"]
                    if gs.isEnabled():
                        endis="disable"
                        emailAddress = minfo.getSupportEmail()
                        departmentName = "Indico support"
                    html.insert(0, """
                        <tr>
                        <td>
                            <img src=%s alt="%s" class="imglink">&nbsp;&nbsp;<b>CERN E-Payment</b> <small>
                            (please, contact <a href="mailto:%s?subject=Indico Epayment - Conference ID: %s">%s</a> to %s 
                            the CERN e-payment module)</small>
                        </td>
                        </tr>
                        """%(img, text, emailAddress, self._conf.getId(), departmentName, endis))
                    continue
            #################################################
            
            selbox = ""
            html.append("""
                        <tr>
                        <td>
                            <a href=%s><img src=%s alt="%s" class="imglink"></a>&nbsp;%s&nbsp;<a href=%s>%s</a>
                        </td>
                        </tr>
                        """%(quoteattr(str(urlStatus)), img, text, selbox, quoteattr(str(urlModif)), gs.getTitle()) )
        html.insert(0, """<a href="" name="sections"></a><input type="hidden" name="oldpos"><table align="left">""")
        html.append("</table>")
        return "".join(html)
开发者ID:lukasnellen,项目名称:indico,代码行数:54,代码来源:epayments.py

示例12: _save_file

 def _save_file(self, srcPath, static_site_id):
     volume = HelperMaKaCInfo.getMaKaCInfoInstance().getArchivingVolume()
     path = os.path.join(Config.getInstance().getOfflineStore(), volume, 'offline', self._conf.getId())
     file_path = os.path.join(path, '{}.zip'.format(static_site_id))
     try:
         os.makedirs(path)
     except OSError as e:
         if e.errno != errno.EEXIST:
             raise
     shutil.copyfile(srcPath, file_path)
     return file_path
开发者ID:MichelCordeiro,项目名称:indico,代码行数:11,代码来源:offlineWebsiteCreator.py

示例13: setup_jinja

def setup_jinja(app):
    config = Config.getInstance()
    # Unicode hack
    app.jinja_env.add_extension(EnsureUnicodeExtension)
    app.add_template_filter(EnsureUnicodeExtension.ensure_unicode)
    # Useful (Python) builtins
    app.add_template_global(dict)
    # Global functions
    app.add_template_global(url_for)
    app.add_template_global(url_for_plugin)
    app.add_template_global(url_rule_to_js)
    app.add_template_global(IndicoConfigWrapper(config), 'indico_config')
    app.add_template_global(config.getSystemIconURL, 'system_icon')
    app.add_template_global(include_css_assets)
    app.add_template_global(include_js_assets)
    app.add_template_global(include_plugin_css_assets)
    app.add_template_global(include_plugin_js_assets)
    app.add_template_global(call_template_hook, 'template_hook')
    app.add_template_global(is_single_line_field, '_is_single_line_field')
    app.add_template_global(render_field, '_render_field')
    app.add_template_global(iter_form_fields, '_iter_form_fields')
    app.add_template_global(format_currency)
    app.add_template_global(get_currency_name)
    app.add_template_global(url_for_login)
    app.add_template_global(url_for_logout)
    app.add_template_global(lambda: unicode(uuid.uuid4()), 'uuid')
    app.add_template_global(icon_from_mimetype)
    # Filters (indico functions returning UTF8)
    app.add_template_filter(EnsureUnicodeExtension.wrap_func(date_time_util.format_date))
    app.add_template_filter(EnsureUnicodeExtension.wrap_func(date_time_util.format_time))
    app.add_template_filter(EnsureUnicodeExtension.wrap_func(date_time_util.format_datetime))
    app.add_template_filter(EnsureUnicodeExtension.wrap_func(date_time_util.format_human_date))
    app.add_template_filter(EnsureUnicodeExtension.wrap_func(date_time_util.format_timedelta))
    # Filters (new ones returning unicode)
    app.add_template_filter(date_time_util.format_human_timedelta)
    app.add_template_filter(lambda d: Markup(html_params(**d)), 'html_params')
    app.add_template_filter(underline)
    app.add_template_filter(markdown)
    app.add_template_filter(dedent)
    app.add_template_filter(natsort)
    app.add_template_filter(groupby)
    app.add_template_filter(any)
    app.add_template_filter(strip_tags)
    app.add_template_filter(alpha_enum)
    # Tests
    app.add_template_test(instanceof)  # only use this test if you really have to!
    app.add_template_test(subclassof)  # only use this test if you really have to!
    # i18n
    app.jinja_env.add_extension('jinja2.ext.i18n')
    app.jinja_env.install_gettext_callables(gettext_context, ngettext_context, True)
    app.add_template_global(lambda: HelperMaKaCInfo.getMaKaCInfoInstance().getLang(), 'get_default_language')
    # webassets
    app.jinja_env.add_extension('webassets.ext.jinja2.AssetsExtension')
    app.jinja_env.assets_environment = core_env
开发者ID:hennogous,项目名称:indico,代码行数:54,代码来源:app.py

示例14: _process

 def _process( self ):
     modPay = self._conf.getModPay().getModPayById(self._epayment)
     if modPay is not None:
         if modPay.getId() == "CERNYellowPay":
             minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
             al = minfo.getAdminList()
             if al.isAdmin( self._getUser() ):
                 modPay.setEnabled(not modPay.isEnabled())
         else:
             modPay.setEnabled(not modPay.isEnabled())
     self._redirect(urlHandlers.UHConfModifEPayment.getURL(self._conf))
开发者ID:lukasnellen,项目名称:indico,代码行数:11,代码来源:ePaymentModif.py

示例15: format_datetime

def format_datetime(dt, format='medium', locale=None, timezone=None, server_tz=False):
    """
    Basically a wrapper around Babel's own format_datetime
    """
    if not locale:
        locale = currentLocale()
    if not timezone and dt.tzinfo:
        timezone = DisplayTZ().getDisplayTZ()
    elif server_tz:
        timezone = HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone()

    return _format_datetime(dt, format=format, locale=locale, tzinfo=timezone).encode('utf-8')
开发者ID:sofian86,项目名称:indico-gh-test,代码行数:12,代码来源:date_time.py


注:本文中的MaKaC.common.HelperMaKaCInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。