Example #1
0
    def languages(self):
        languages_info = super(gwLanguageSelectorForRoot, self).languages()
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path
                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url(),
                    **query_extras
                )
            else: # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Example #2
0
    def languages(self):
        languages_info = super(gwLanguageSelectorForRoot, self).languages()
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path
                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url(),
                    **query_extras
                )
            else:  # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Example #3
0
    def languages(self):
        languages_info = super(gwLanguageSelectorViewlet, self).languages()

        google_translated = self.get_google_translated_langs()
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        uuid = IUUID(self.context)
        if uuid is None:
            uuid = 'nouuid'

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            # if google_translated.get(data['code']):
            #     data['google_translated'] = True
            #     google_query_string = dict(sl=self.tool.getPreferredLanguage(),
            #                                tl=data['code'],
            #                                u=quote(self.context.absolute_url())
            #                                )

            #     data['url'] = 'http://translate.google.com/translate?hl={sl}&sl={sl}&tl={tl}&u={u}'.format(**google_query_string)
            # else:
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path

                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url().rstrip("/") +
                    "/@@goto/%s/%s" % (
                        uuid,
                        lang_info['code']
                    ),
                    **query_extras
                )
            else: # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Example #4
0
    def languages(self):
        languages_info = super(gwLanguageSelectorViewlet, self).languages()

        google_translated = self.get_google_translated_langs()  # noqa
        idiomes_publicats = genweb_config().idiomes_publicats
        redirect_to_root = genweb_config().languages_link_to_root

        user_has_permission_at_root = havePermissionAtRoot()
        results = []

        uuid = IUUID(self.context)
        if uuid is None:
            uuid = 'nouuid'

        filtered_languages = [lang_info for lang_info in languages_info if user_has_permission_at_root or lang_info['code'] in idiomes_publicats]

        for lang_info in filtered_languages:
            # Avoid to modify the original language dict
            data = lang_info.copy()
            data['translated'] = True
            # if google_translated.get(data['code']):
            #     data['google_translated'] = True
            #     google_query_string = dict(sl=self.tool.getPreferredLanguage(),
            #                                tl=data['code'],
            #                                u=quote(self.context.absolute_url())
            #                                )

            #     data['url'] = 'http://translate.google.com/translate?hl={sl}&sl={sl}&tl={tl}&u={u}'.format(**google_query_string)
            # else:
            query_extras = {
                'set_language': data['code'],
            }
            if not redirect_to_root:
                post_path = getPostPath(self.context, self.request)
                if post_path:
                    query_extras['post_path'] = post_path

                data['url'] = addQuery(
                    self.request,
                    self.context.absolute_url().rstrip('/') +
                    '/@@goto/%s/%s' % (
                        uuid,
                        lang_info['code']
                    ),
                    **query_extras
                )
            else:  # Redirect to root when make a language click
                data['url'] = self.portal_url() + '?set_language=' + data['code']

            results.append(data)

        return results
Example #5
0
 def canSeeToolLink(self):
     """Torna la funcio dels utils"""
     return havePermissionAtRoot(self)
Example #6
0
 def showRootFolderLink(self):
     return havePermissionAtRoot()
Example #7
0
 def showRootFolderLink(self):
     return havePermissionAtRoot()