Esempio n. 1
0
    def _message_params(self, **extra_params):
        """
        Retrieve message formating parameters.
        """
        params = {'module': self.module, 'module_title': self.module.title()}
        if self.identifier:
            params['identifier'] = self.identifier

        if self.user:
            for key, val in self.user.__dict__.iteritems():
                params["user_%s" % key.lower()] = val

        if self.provider_details:
            for key, val in self.provider_details.iteritems():
                params["provider_%s" % key.lower()] = val

            if 'info' in self.provider_details:
                if isinstance(self.provider_details['info'], basestring):
                    self.provider_details['info'] = \
                        json.loads(self.provider_details['info'])
                for key, val in self.provider_details['info'].iteritems():
                    params['provider_info_%s' % key.lower()] = val

        # resolve username, handle unexisting defined username key
        if self.user and self.username_key in params:
            params['username'] = params[self.username_key]
        else:
            params['username'] = self.identifier

        branding_params = dict(
            map(lambda k: (k[0].lower(), k[1]),
                branding_utils.get_branding_dict().iteritems()))
        params.update(branding_params)

        if not self.message_tpls_compiled:
            for key, message_tpl in self.message_tpls.iteritems():
                msg = self.messages.get(key, self.message_tpls.get(key))
                override_in_settings = self.get_setting(key)
                if override_in_settings is not None:
                    msg = override_in_settings
                try:
                    tpl = smart_unicode(msg)
                    self.message_tpls_compiled[key] = tpl.format(**params)
                    params.update(self.message_tpls_compiled)
                except KeyError, e:
                    continue
Esempio n. 2
0
    def _message_params(self, **extra_params):
        """
        Retrieve message formating parameters.
        """
        params = {'module': self.module, 'module_title': self.module.title()}
        if self.identifier:
            params['identifier'] = self.identifier

        if self.user:
            for key, val in self.user.__dict__.iteritems():
                params["user_%s" % key.lower()] = val

        if self.provider_details:
            for key, val in self.provider_details.iteritems():
                params["provider_%s" % key.lower()] = val

            if 'info' in self.provider_details:
                if isinstance(self.provider_details['info'], basestring):
                    self.provider_details['info'] = \
                        json.loads(self.provider_details['info'])
                for key, val in self.provider_details['info'].iteritems():
                    params['provider_info_%s' % key.lower()] = val

        # resolve username, handle unexisting defined username key
        if self.user and self.username_key in params:
            params['username'] = params[self.username_key]
        else:
            params['username'] = self.identifier

        branding_params = dict(
            map(lambda k: (k[0].lower(), k[1]),
                branding_utils.get_branding_dict().iteritems()))
        params.update(branding_params)

        if not self.message_tpls_compiled:
            for key, message_tpl in self.message_tpls.iteritems():
                msg = self.messages.get(key, self.message_tpls.get(key))
                override_in_settings = self.get_setting(key)
                if override_in_settings is not None:
                    msg = override_in_settings
                try:
                    tpl = smart_unicode(msg)
                    self.message_tpls_compiled[key] = tpl.format(**params)
                    params.update(self.message_tpls_compiled)
                except KeyError, e:
                    continue
Esempio n. 3
0
def index(request):
    branding_settings = get_branding_dict("")
    urls_config = copy.deepcopy(URLS_CONFIG)

    for key, value in urls_config.iteritems():
        urls_config[key] = json.dumps(value)

    for key, value in branding_settings.iteritems():
        branding_settings[key] = json.dumps(value)

    return direct_to_template(
        request, 'pithos_webclient/index.html', {
            'settings': settings,
            'MEDIA_URL': MEDIA_URL,
            'CLIENT_VERSION': __version__,
            'PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE':
            settings.CLOUDBAR_ACTIVE_SERVICE,
            'branding_settings': branding_settings,
            'urls_config': URLS_CONFIG
        })
Esempio n. 4
0
def app(request, path):
    app_settings = {
        'branding': get_branding_dict(),
        'token': ui_settings.AUTH_METHOD,
        'auth_url': ui_settings.AUTH_URL,
        'messages': ui_settings.USER_NOTIFICATIONS
    }

    if ui_settings.ASTAKOS_ACCOUNT_PROXY_PATH:
        app_settings['proxy'] = {
            'astakosAccount': ui_settings.ASTAKOS_ACCOUNT_PROXY_PATH
        }

    context = {
        'app_settings': json.dumps(app_settings),
        'UI_MEDIA_URL': ui_settings.UI_MEDIA_URL,
        'UI_BASE_URL': ui_settings.BASE_URL
    }
    return direct_to_template(request, "snf_ui_index.html",
                              extra_context=context)
Esempio n. 5
0
def app(request, path):
    app_settings = {
        'branding': get_branding_dict(),
        'token': ui_settings.AUTH_METHOD,
        'auth_url': ui_settings.AUTH_URL,
        'messages': ui_settings.USER_NOTIFICATIONS
    }

    if ui_settings.ASTAKOS_ACCOUNT_PROXY_PATH:
        app_settings['proxy'] = {
            'astakosAccount': ui_settings.ASTAKOS_ACCOUNT_PROXY_PATH
        }

    context = {
        'app_settings': json.dumps(app_settings),
        'UI_MEDIA_URL': ui_settings.UI_MEDIA_URL,
        'UI_BASE_URL': ui_settings.BASE_URL
    }
    return direct_to_template(request,
                              "snf_ui_index.html",
                              extra_context=context)
Esempio n. 6
0
def branding(request):
    return utils.get_branding_dict("BRANDING")
Esempio n. 7
0
def branding(request):
	return utils.get_branding_dict("BRANDING")
Esempio n. 8
0
    def _message_params(self, **extra_params):
        """
        Retrieve message formating parameters.
        """
        params = {'module': self.module, 'module_title': self.module.title()}
        if self.identifier:
            params['identifier'] = self.identifier

        if self.user:
            for key, val in self.user.__dict__.iteritems():
                params["user_%s" % key.lower()] = val

        if self.provider_details:
            for key, val in self.provider_details.iteritems():
                params["provider_%s" % key.lower()] = val

            if 'info' in self.provider_details:
                if isinstance(self.provider_details['info'], basestring):
                    self.provider_details['info'] = \
                        json.loads(self.provider_details['info'])
                for key, val in self.provider_details['info'].iteritems():
                    params['provider_info_%s' % key.lower()] = val

        # resolve username, handle unexisting defined username key
        if self.user and self.username_key in params:
            params['username'] = params[self.username_key]
        else:
            params['username'] = self.identifier

        branding_params = dict(
            map(lambda k: (k[0].lower(), k[1]),
                branding_utils.get_branding_dict().iteritems()))
        params.update(branding_params)

        if not self.message_tpls_compiled:
            for key, message_tpl in self.message_tpls.iteritems():
                msg = self.messages.get(key, self.message_tpls.get(key))
                override_in_settings = self.get_setting(key)
                if override_in_settings is not None:
                    msg = override_in_settings
                try:
                    tpl = smart_unicode(msg)
                    self.message_tpls_compiled[key] = tpl.format(**params)
                    params.update(self.message_tpls_compiled)
                except KeyError:
                    continue
        else:
            params.update(self.message_tpls_compiled)

        for key, value in self.urls.iteritems():
            params['%s_url' % key] = value

        if self.user and self.resolve_available_methods:
            available_providers = self.user.get_enabled_auth_providers()
            for p in available_providers:
                p.resolve_available_methods = False
                if p.module == self.module and p.identifier == self.identifier:
                    available_providers.remove(p)

            get_msg = lambda p: p.get_method_prompt_msg
            params['available_methods'] = \
                ','.join(map(get_msg, available_providers))

            get_msg = lambda p: "<a href='%s'>%s</a>" % \
                (p.get_login_url, p.get_method_prompt_msg)

            params['available_methods_links'] = \
                ','.join(map(get_msg, available_providers))

        params.update(extra_params)
        return params
Esempio n. 9
0
    def _message_params(self, **extra_params):
        """
        Retrieve message formating parameters.
        """
        params = {'module': self.module, 'module_title': self.module.title()}
        if self.identifier:
            params['identifier'] = self.identifier

        if self.user:
            for key, val in self.user.__dict__.iteritems():
                params["user_%s" % key.lower()] = val

        if self.provider_details:
            for key, val in self.provider_details.iteritems():
                params["provider_%s" % key.lower()] = val

            if 'info' in self.provider_details:
                if isinstance(self.provider_details['info'], basestring):
                    self.provider_details['info'] = \
                        json.loads(self.provider_details['info'])
                for key, val in self.provider_details['info'].iteritems():
                    params['provider_info_%s' % key.lower()] = val

        # resolve username, handle unexisting defined username key
        if self.user and self.username_key in params:
            params['username'] = params[self.username_key]
        else:
            params['username'] = self.identifier

        branding_params = dict(
            map(lambda k: (k[0].lower(), k[1]),
                branding_utils.get_branding_dict().iteritems()))
        params.update(branding_params)

        if not self.message_tpls_compiled:
            for key, message_tpl in self.message_tpls.iteritems():
                msg = self.messages.get(key, self.message_tpls.get(key))
                override_in_settings = self.get_setting(key)
                if override_in_settings is not None:
                    msg = override_in_settings
                try:
                    tpl = smart_unicode(msg)
                    self.message_tpls_compiled[key] = tpl.format(**params)
                    params.update(self.message_tpls_compiled)
                except KeyError:
                    continue
        else:
            params.update(self.message_tpls_compiled)

        for key, value in self.urls.iteritems():
            params['%s_url' % key] = value

        if self.user and self.resolve_available_methods:
            available_providers = self.user.get_enabled_auth_providers()
            for p in available_providers:
                p.resolve_available_methods = False
                if p.module == self.module and p.identifier == self.identifier:
                    available_providers.remove(p)

            get_msg = lambda p: p.get_method_prompt_msg
            params['available_methods'] = \
                ','.join(map(get_msg, available_providers))

            get_msg = lambda p: "<a href='%s'>%s</a>" % \
                (p.get_login_url, p.get_method_prompt_msg)

            params['available_methods_links'] = \
                ','.join(map(get_msg, available_providers))

        params.update(extra_params)
        return params