コード例 #1
0
ファイル: vocabularies.py プロジェクト: EU-OSHA/osha.oira
    def __call__(self, context):
        countries = {}
        if ISectorContainer.providedBy(context):
            for country in context.values():
                if not ICountry.providedBy(country):
                    continue
                countries.update({
                    utils.getRegionTitle(context.REQUEST, country.id, country.title).encode('utf-8'):
                    country.id
                })
        elif ICountry.providedBy(context):
            countries.update({
                utils.getRegionTitle(context.REQUEST, context.id, context.title).encode('utf-8'):
                context.id
            })
        elif ISector.providedBy(context) or ISurveyGroup.providedBy(context):
            if ISector.providedBy(context):
                country = aq_parent(context)
            elif ISurveyGroup.providedBy(context):
                country = aq_parent(aq_parent(context))

            if ICountry.providedBy(country):
                countries.update({
                    utils.getRegionTitle(context.REQUEST, country.id, country.title).encode('utf-8'):
                    country.id
                })
        return SimpleVocabulary.fromItems(sorted(countries.items()))
コード例 #2
0
ファイル: vocabularies.py プロジェクト: garbas/osha.oira
    def __call__(self, context):
        countries = {}
        if ISectorContainer.providedBy(context):
            for country in context.values():
                if not ICountry.providedBy(country):
                    continue
                countries.update({
                    utils.getRegionTitle(context.REQUEST,
                                         country.id,
                                         country.title).encode('utf-8'):
                    country.id
                })
        elif ICountry.providedBy(context):
            countries.update({
                utils.getRegionTitle(
                    context.REQUEST,
                    context.id,
                    context.title).encode('utf-8'): context.id
            })
        elif ISector.providedBy(context) or ISurveyGroup.providedBy(context):
            if ISector.providedBy(context):
                country = aq_parent(context)
            elif ISurveyGroup.providedBy(context):
                country = aq_parent(aq_parent(context))

            if ICountry.providedBy(country):
                countries.update({
                    utils.getRegionTitle(
                        context.REQUEST,
                        country.id,
                        country.title).encode('utf-8'): country.id
                })
        return SimpleVocabulary.fromItems(sorted(countries.items()))
コード例 #3
0
ファイル: vocabularies.py プロジェクト: euphorie/osha.oira
 def __call__(self, context):
     t = lambda txt: translate(txt, context=api.portal.get().REQUEST)
     types = {t(_("OiRA Tool")).encode("utf-8"): "tool"}
     if ISectorContainer.providedBy(context):
         types.update({t(_("EU-OSHA Overview")).encode("utf-8"): "overview", t(_("Country")): "country"})
     elif ICountry.providedBy(context):
         types.update({t(_("Country")).encode("utf-8"): "country"})
     return SimpleVocabulary.fromItems(types.items())
コード例 #4
0
ファイル: vocabularies.py プロジェクト: EU-OSHA/osha.oira
 def __call__(self, context):
     t = lambda txt: translate(txt, context=api.portal.get().REQUEST)
     types = {t(_('OiRA Tool')).encode('utf-8'): 'tool'}
     if ISectorContainer.providedBy(context):
         types.update({
             t(_('EU-OSHA Overview')).encode('utf-8'): 'overview',
             t(_('Country')): 'country'
         })
     elif ICountry.providedBy(context):
         types.update({t(_('Country')).encode('utf-8'): 'country'})
     return SimpleVocabulary.fromItems(types.items())
コード例 #5
0
ファイル: vocabularies.py プロジェクト: garbas/osha.oira
 def __call__(self, context):
     t = lambda txt: translate(txt, context=api.portal.get().REQUEST)
     types = {t(_('Survey')).encode('utf-8'): 'tool'}
     if ISectorContainer.providedBy(context):
         types.update({
             t(_('EU-OSHA Overview')).encode('utf-8'): 'overview',
             t(_('Country')): 'country'
         })
     elif ICountry.providedBy(context):
         types.update({t(_('Country')).encode('utf-8'): 'country'})
     return SimpleVocabulary.fromItems(types.items())
コード例 #6
0
ファイル: vocabularies.py プロジェクト: EU-OSHA/osha.oira
 def __call__(self, context):
     tools = []
     if ISectorContainer.providedBy(context):
         for country in context.values():
             if not ICountry.providedBy(country):
                 continue
             tools += self.getToolsInCountry(country)
     elif ICountry.providedBy(context):
         tools += self.getToolsInCountry(context)
     elif ISector.providedBy(context):
         tools += self.getToolsInSector(context)
     elif ISurveyGroup.providedBy(context):
         tools += self.getToolsInSector(aq_parent(context))
     return SimpleVocabulary.fromValues(tools)
コード例 #7
0
ファイル: vocabularies.py プロジェクト: euphorie/osha.oira
 def __call__(self, context):
     tools = []
     if ISectorContainer.providedBy(context):
         for country in context.values():
             if not ICountry.providedBy(country):
                 continue
             tools += self.getToolsInCountry(country)
     elif ICountry.providedBy(context):
         tools += self.getToolsInCountry(context)
     elif ISector.providedBy(context):
         tools += self.getToolsInSector(context)
     elif ISurveyGroup.providedBy(context):
         tools += self.getToolsInSector(aq_parent(context))
     return SimpleVocabulary.fromValues(tools)