def _get_config_form_items(self):
        # Styles for use in the form.select() macro.
        styles = [{
            'text': 'Default',
            'value': '/base/css/main.css'
        }, {
            'text': 'Red',
            'value': '/base/css/red.css'
        }, {
            'text': 'Green',
            'value': '/base/css/green.css'
        }, {
            'text': 'Maroon',
            'value': '/base/css/maroon.css'
        }, {
            'text': 'Fuchsia',
            'value': '/base/css/fuchsia.css'
        }]

        items = [
            {
                'name': 'ckan.site_title',
                'control': 'input',
                'label': _('Site Title'),
                'placeholder': ''
            },
            #{'name': 'ckan.site_description', 'control': 'input', 'label': _('Site Tag Line'), 'placeholder': ''},
            {
                'name': 'ckan.site_logo',
                'control': 'input',
                'label': _('Site Tag Logo'),
                'placeholder': ''
            },
            {
                'name': 'ckanext.danepubliczne.maintenance_flash',
                'control': 'input',
                'label': _('Maintenance alert'),
                'placeholder': _('Fill if there is planned maintenance break')
            },
        ]

        for locale in h.get_available_locales():
            lang = locale.language
            items += [{
                'name': 'ckan.site_about-' + lang,
                'control': 'markdown',
                'label': _('About') + ' ' + lang.upper(),
                'placeholder': _('About page text')
            }]

        for locale in h.get_available_locales():
            lang = locale.language
            items += [{
                'name': 'ckan.site_intro_text-' + lang,
                'control': 'markdown',
                'label': _('Intro Text') + ' ' + lang.upper(),
                'placeholder': _('Text on home page')
            }]

        return items
Esempio n. 2
0
    def update_config(self, config):
        toolkit.add_template_directory(config, 'templates')
        toolkit.add_public_directory(config, 'public')
        toolkit.add_resource('fanstatic', 'dane_publiczne')
        toolkit.add_resource('fanstatic', 'ckanext-reclineview')

        mimetypes.add_type('application/json', '.geojson')

        # TODO ckan-dev load all properties from SystemInfo at load, instead of using app_globals.auto_update:
        # TODO ckan-dev def get_globals_key(key):   should allow ckanext.
        app_globals.auto_update += [
            'ckanext.danepubliczne.maintenance_flash',
        ]
        for locale in h.get_available_locales():
            lang = locale.language
            app_globals.auto_update += ['ckan.site_intro_text-' + lang, 'ckan.site_about-' + lang]


        # don't show user names in activity stream
        def get_snippet_actor_org(activity, detail):
            return literal('''<span class="actor">%s</span>'''
            % (linked_org_for(activity['user_id'], 0, 30))
            )

        activity_streams.activity_snippet_functions['actor'] = get_snippet_actor_org
Esempio n. 3
0
    def update_config(self, config):
        toolkit.add_template_directory(config, 'templates')
        toolkit.add_public_directory(config, 'public')
        toolkit.add_resource('fanstatic', 'dane_publiczne')
        toolkit.add_resource('fanstatic', 'ckanext-reclineview')

        mimetypes.add_type('application/json', '.geojson')

        # TODO ckan-dev load all properties from SystemInfo at load, instead of using app_globals.auto_update:
        # TODO ckan-dev def get_globals_key(key):   should allow ckanext.
        app_globals.auto_update += [
            'ckanext.danepubliczne.maintenance_flash',
        ]
        for locale in h.get_available_locales():
            lang = locale.language
            app_globals.auto_update += [
                'ckan.site_intro_text-' + lang, 'ckan.site_about-' + lang
            ]

        # don't show user names in activity stream
        def get_snippet_actor_org(activity, detail):
            return literal('''<span class="actor">%s</span>''' %
                           (linked_org_for(activity['user_id'], 0, 30)))

        activity_streams.activity_snippet_functions[
            'actor'] = get_snippet_actor_org
Esempio n. 4
0
def fluent_form_languages(field=None, entity_type=None, object_type=None,
        schema=None):
    """
    Return a list of language codes for this form (or form field)

    1. return field['form_languages'] if it is defined
    2. return schema['form_languages'] if it is defined
    3. get schema from entity_type + object_type then
       return schema['form_languages'] if they are defined
    4. return languages from site configuration
    """
    if field and 'form_languages' in field:
        return field['form_languages']
    if schema and 'form_languages' in schema:
        return schema['form_languages']
    if entity_type and object_type:
        # late import for compatibility with older ckanext-scheming
        from ckanext.scheming.helpers import scheming_get_schema
        schema = scheming_get_schema(entity_type, object_type)
        if schema and 'form_languages' in schema:
            return schema['form_languages']

    langs = []
    for l in get_available_locales():
        if l.language not in langs:
            langs.append(l.language)
    return langs
Esempio n. 5
0
def orgportals_get_country_short_name(current_locale):
    locales = []

    if toolkit.check_ckan_version(min_version='2.5.0', max_version='2.5.3'):
        locales = lib_helpers.get_available_locales()
    else:
        locales = i18n.get_available_locales()

    for locale in locales:
        if current_locale == str(locale):
            return locale.english_name[:3]
Esempio n. 6
0
def orgdashboards_get_available_languages():
    ''' Read the languages listed in a json file '''

    languages = []

    for locale in h.get_available_locales():
        languages.append({'value': locale, 'text': locale.english_name})

    languages.sort()

    languages.insert(0, {'value': 'none', 'text': 'None'})

    return languages
Esempio n. 7
0
    def _get_config_form_items(self):
        # Styles for use in the form.select() macro.
        styles = [{'text': 'Default', 'value': '/base/css/main.css'},
                  {'text': 'Red', 'value': '/base/css/red.css'},
                  {'text': 'Green', 'value': '/base/css/green.css'},
                  {'text': 'Maroon', 'value': '/base/css/maroon.css'},
                  {'text': 'Fuchsia', 'value': '/base/css/fuchsia.css'}]

        items = [
            {'name': 'ckan.site_title', 'control': 'input', 'label': _('Site Title'), 'placeholder': ''},
            #{'name': 'ckan.site_description', 'control': 'input', 'label': _('Site Tag Line'), 'placeholder': ''},
            {'name': 'ckan.site_logo', 'control': 'input', 'label': _('Site Tag Logo'), 'placeholder': ''},
            {'name': 'ckanext.danepubliczne.maintenance_flash', 'control': 'input', 'label': _('Maintenance alert'), 'placeholder': _('Fill if there is planned maintenance break')},
        ]

        for locale in h.get_available_locales():
            lang = locale.language
            items += [{'name': 'ckan.site_about-' + lang, 'control': 'markdown', 'label': _('About') + ' ' + lang.upper(), 'placeholder': _('About page text')}]

        for locale in h.get_available_locales():
            lang = locale.language
            items += [{'name': 'ckan.site_intro_text-' + lang, 'control': 'markdown', 'label': _('Intro Text') + ' ' + lang.upper(), 'placeholder': _('Text on home page')}]

        return items
Esempio n. 8
0
def orgportals_get_available_languages():
    languages = []
    locales = []

    if toolkit.check_ckan_version(min_version='2.5.0', max_version='2.5.3'):
        locales = lib_helpers.get_available_locales()
    else:
        locales = i18n.get_available_locales()

    for locale in locales:
        languages.append({'value': locale, 'text': locale.english_name})

    languages.sort()

    languages.insert(0, {'value': 'none', 'text': 'None'})

    return languages
Esempio n. 9
0
def fluent_form_languages(schema, field=None):
    """
    Return a list of language codes for this form (or form field)

    1. return field['form_languages'] if it is defined
    2. return schema['form_languages'] if it is defined
    3. return languages from site configuration
    """
    if 'form_languages' in field:
        return field['form_languages']
    if 'form_languages' in schema:
        return schema['form_languages']

    langs = []
    for l in get_available_locales():
        if l.language not in langs:
            langs.append(l.language)
    return langs
Esempio n. 10
0
 def h_default_locale(self):
     return h.get_available_locales()[0].language
Esempio n. 11
0
def orgdashboards_get_country_short_name(current_locale):
    for locale in h.get_available_locales():
        if current_locale == str(locale):
            return locale.english_name[:3]
Esempio n. 12
0
File: tools.py Progetto: haphut/ytp
def get_locales():
    """ Return all available locales strings. """
    return [locale.language for locale in helpers.get_available_locales()]
Esempio n. 13
0
 def h_default_locale(self):
     return h.get_available_locales()[0].language
Esempio n. 14
0
 def h_fluent_form_languages(self, arg1, arg2):
     langs = []
     for l in h.get_available_locales():
         if l.language not in langs:
             langs.append(l.language)
     return langs