Example #1
0
 def keywords_of_section(self, section, kwfilter):
     """Valid keywords under the given section.
     """
     pcat = getToolByName(section, 'portal_catalog')
     cat = pcat._catalog
     path_idx = cat.indexes[self.path_index]
     tags_idx = cat.indexes[self.keyword_index]
     result = []
     # query all oids of path - low level
     pquery = {
         self.path_index: {
             'query': '/'.join(section.getPhysicalPath()),
             'depth': -1,
         }
     }
     kwfilter = safe_encode(kwfilter)
     # uses internal zcatalog specific details to quickly get the values.
     path_result, info = path_idx._apply_index(pquery)
     for tag in tags_idx.uniqueValues():
         if kwfilter and kwfilter not in safe_encode(tag):
             continue
         tquery = {self.keyword_index: tag}
         tags_result, info = tags_idx._apply_index(tquery)
         if intersection(path_result, tags_result):
             result.append(tag)
     # result should be sorted, because uniqueValues are.
     return safe_simplevocabulary_from_values(result)
Example #2
0
def get_subjects(context):
    """Provides dropdowns for the course subejcts.
    
    Searches the registry for course subjects then filters the results
    based on the department the current logged in user belongs to. Once
    the list is filtered, everything before ``': '`` is removed; thus
    in order to return proper results, the admins MUST enter any new
    subjects in the control panel like so: ``foo: bar`` .

    TL;DR: this is the function that generates the Course Subject drop-down.

    Args:
        context(context): Plone handles this auto-magically.

    Returns:
        collection: (u'item1', u'item2', u'item3', u'etc')
    """
    # get current user
    current_user = api.user.get_current()
    user_dept = current_user.getProperty('department')
    records = api.portal.get_registry_record('york.scheduling.courseSubjects')
    spam = []
    # values = [item.split(': ')[1] for item in records if user_dept.lower() in item.lower()]

    for items in records:
        if user_dept.lower() in items.lower():
            spam.extend(items)
    values = tuple([item.split(': ')[1] for item in spam])
    return safe_simplevocabulary_from_values(values)
Example #3
0
 def keywords_of_section(self, section, kwfilter):
     """Valid keywords under the given section.
     """
     pcat = getToolByName(section, 'portal_catalog')
     cat = pcat._catalog
     path_idx = cat.indexes[self.path_index]
     tags_idx = cat.indexes[self.keyword_index]
     result = []
     # query all oids of path - low level
     pquery = {
         self.path_index: {
             'query': '/'.join(section.getPhysicalPath()),
             'depth': -1,
         }
     }
     kwfilter = safe_encode(kwfilter)
     # uses internal zcatalog specific details to quickly get the values.
     path_result, info = path_idx._apply_index(pquery)
     for tag in tags_idx.uniqueValues():
         if kwfilter and kwfilter not in safe_encode(tag):
             continue
         tquery = {self.keyword_index: tag}
         tags_result, info = tags_idx._apply_index(tquery)
         if intersection(path_result, tags_result):
             result.append(tag)
     # result should be sorted, because uniqueValues are.
     return safe_simplevocabulary_from_values(result)
Example #4
0
def listDonors(context):
    """ Donors list. """
    terms = []
    literals = api.content.find(portal_type="Donor")
    for item in literals:
        terms.append(item.Title)
    return safe_simplevocabulary_from_values(terms)
Example #5
0
def listWOPPrograms(context):
    """ WOP Programs. """
    terms = []
    literals = api.content.find(portal_type="Program")
    for item in literals:
        terms.append(item.Title)
    return safe_simplevocabulary_from_values(terms)
Example #6
0
def outputs(context):
    """ Outputs for the Activity. """
    terms = []
    literals = api.content.find(portal_type="Output", context=context, depth=1)
    for item in literals:
        terms.append(item.Title)
    return safe_simplevocabulary_from_values(terms)
Example #7
0
def contextAreas(context):
    """ Get context areas. """
    terms = []
    literals = api.content.find(portal_type="ImprovementArea", context=context)
    for item in literals:
        terms.append(item.Title)
    return safe_simplevocabulary_from_values(terms)
Example #8
0
def settings_capacity_changes(context):
    """ Capacity changes settings. """
    items = api.content.find(portal_type="OutcomeCCItem")
    terms = []
    for item in items:
        terms.append(item.Title)
    return safe_simplevocabulary_from_values(terms)
Example #9
0
 def all_keywords(self, kwfilter):
     site = getSite()
     self.catalog = getToolByName(site, 'portal_catalog', None)
     if self.catalog is None:
         return SimpleVocabulary([])
     index = self.catalog._catalog.getIndex(self.keyword_index)
     return safe_simplevocabulary_from_values(index._index, query=kwfilter)
Example #10
0
 def all_keywords(self, kwfilter):
     site = getSite()
     self.catalog = getToolByName(site, 'portal_catalog', None)
     if self.catalog is None:
         return SimpleVocabulary([])
     index = self.catalog._catalog.getIndex(self.keyword_index)
     return safe_simplevocabulary_from_values(index._index, query=kwfilter)
Example #11
0
 def __call__(self, context):
     try:
         subscription_channels = api.portal.get_registry_record(
             "subscription_channels",
             interface=IRerUfficiostampaSettings,
         )
     except (KeyError, InvalidParameterError):
         subscription_channels = []
     return safe_simplevocabulary_from_values(subscription_channels)
Example #12
0
    def __call__(self, context):
        """
        return a list of legislature names.
        There are all possible index values sorted on reverse order from
        the registry one (last legislature is the first one).
        """
        try:
            registry_val = json.loads(
                api.portal.get_registry_record(
                    "legislatures", interface=IRerUfficiostampaSettings))
            registry_legislatures = [
                x.get("legislature", "") for x in registry_val
            ]
            registry_legislatures.reverse()
        except (KeyError, InvalidParameterError, TypeError):
            registry_legislatures = []

        pc = api.portal.get_tool(name="portal_catalog")
        catalog_legislatures = pc.uniqueValuesFor("legislature")

        legislatures = [
            x for x in registry_legislatures if x in catalog_legislatures
        ]
        return safe_simplevocabulary_from_values(legislatures)
def PlatformVocabularyFactory(context):
    values = api.portal.get_registry_record('collectiveaddons.available_platforms')
    return safe_simplevocabulary_from_values(values)
Example #14
0
 def __call__(self, context):
     return safe_simplevocabulary_from_values(self.values)
def PaymentOptionsVocabularyFactory(context):
    values = api.portal.get_registry_record(
        'collectiveconference.paymentoptions')
    return safe_simplevocabulary_from_values(values)
def LicenseVocabularyFactory(context):
    values = api.portal.get_registry_record('collectiveconference.license')
    return safe_simplevocabulary_from_values(values)
def TrainingAudienceVocabularyFactory(context):
    values = api.portal.get_registry_record(
        'collectiveconference.trainingsaudience')
    return safe_simplevocabulary_from_values(values)
def WorkshopLengthVocabularyFactory(context):
    values = api.portal.get_registry_record(
        'collectiveconference.workshop_length')
    return safe_simplevocabulary_from_values(values)
 def __call__(self, context):
     values = api.portal.get_registry_record(self.value_name)
     return safe_simplevocabulary_from_values(values)
Example #20
0
def RoomsVocabularyFactory(context):
    values = api.portal.get_registry_record('ploneconf.rooms')
    return safe_simplevocabulary_from_values(values)
def CategoriesVocabularyFactory(context):
    values = api.portal.get_registry_record('collectiveaddons.available_category')
    return safe_simplevocabulary_from_values(values)