Пример #1
0
 def test_available_allowed_types(self):
     constraints = ISelectableConstrainTypes(self.institution)
     self.login_as_manager()
     self.assertListEqual(["Folder", "Meeting"], constraints.getLocallyAllowedTypes())
     self.login_as_test()
     self.assertListEqual([], constraints.getLocallyAllowedTypes())
     self.login_as_institution_manager()
     self.assertListEqual([], constraints.getLocallyAllowedTypes())
Пример #2
0
def to_1500(context):
    """ This upgrade handles that a type "Bando" is now  addmitted by default
    inside the folder "Documenti e Dati".
    This method just ADD THE CONTENT TYPE to the current list of types that you
    can add inside that folder only if it's not already there.
    tp#17807
    """

    doc_brains = api.content.find(portal_type="Document")
    doc_e_dati_list = [x for x in doc_brains if x.Title == "Documenti e dati"]
    if len(doc_e_dati_list) == 1:
        doc_e_dati = doc_e_dati_list[0].getObject()

        constraints = ISelectableConstrainTypes(doc_e_dati)
        allowed_types = constraints.getLocallyAllowedTypes()
        if "Bando" not in allowed_types:
            allowed_types.append("Bando")
            constraints.setLocallyAllowedTypes(allowed_types)

            logger.info("Enabled 'Bando' inside 'Ducumenti e dati' folder.")
        else:
            logger.info("'Bando' already enabled in 'Ducumenti e dati' folder,"
                        " not changes needed.")
    else:
        logger.warning("More than one Document with title 'Documenti e dati'. "
                       "Type 'Bando' inside 'Ducumenti e dati' folder not "
                       "enabled.")
Пример #3
0
class FormContentAdapter(object):

    def __init__(self, context):
        self.context = ISelectableConstrainTypes(context)

    @property
    def constrain_types_mode(self):
        return self.context.getConstrainTypesMode()

    @property
    def allowed_types(self):
        return self.context.getLocallyAllowedTypes()

    @property
    def secondary_types(self):
        immediately_addable = self.context.getImmediatelyAddableTypes()
        return [t for t in self.context.getLocallyAllowedTypes()
                if t not in immediately_addable]
Пример #4
0
class FormContentAdapter(object):

    def __init__(self, context):
        self.context = ISelectableConstrainTypes(context)

    @property
    def constrain_types_mode(self):
        return self.context.getConstrainTypesMode()

    @property
    def allowed_types(self):
        return self.context.getLocallyAllowedTypes()

    @property
    def secondary_types(self):
        immediately_addable = self.context.getImmediatelyAddableTypes()
        return [t for t in self.context.getLocallyAllowedTypes()
                if t not in immediately_addable]
Пример #5
0
    def can_add(self, folder, type_id):
        constraints = ISelectableConstrainTypes(folder, None)
        addable = None
        if constraints is not None:
            addable = constraints.getLocallyAllowedTypes()

        if addable is None:
            addable = [t.getId() for t in folder.allowedContentTypes()]

        if type_id not in addable:
            return False
        return True