def test_a_subdossiers_is_a_dossiertemplate(self, browser):
        self.login(self.administrator, browser=browser)
        browser.open(self.dossiertemplate)

        factoriesmenu.add('Subdossier')
        browser.fill({'Title': 'Template'}).submit()

        self.assertTrue(IDossierTemplateSchema.providedBy(browser.context))
Beispiel #2
0
    def test_a_subdossiers_is_a_dossiertemplate(self, browser):
        dossiertemplate = create(
            Builder('dossiertemplate').within(self.templatefolder))

        browser.login().open(dossiertemplate)

        factoriesmenu.add('Subdossier')
        browser.fill({'Title': 'Template'}).submit()

        self.assertTrue(IDossierTemplateSchema.providedBy(browser.context))
Beispiel #3
0
    def test_a_subdossiers_is_a_dossiertemplate(self, browser):
        dossiertemplate = create(Builder('dossiertemplate')
                                 .within(self.templatedossier))

        browser.login().open(dossiertemplate)

        factoriesmenu.add('Subdossier')
        browser.fill({'Title': 'Template'}).submit()

        self.assertTrue(IDossierTemplateSchema.providedBy(browser.context))
    def is_subdossier_allowed(self):
        if self.is_respect_max_dossier_depth:
            max_dossier_depth = api.portal.get_registry_record(
                'maximum_dossier_depth', interface=IDossierContainerTypes)

            current_levels = len([item for item in self.aq_chain
                                  if IDossierTemplateSchema.providedBy(item)])
            return current_levels <= max_dossier_depth

        return True
Beispiel #5
0
            def update(self):
                """Update the widget-values of the dossier add-form
                with the values of the selected dossiertemplate values.
                """
                super(WrappedForm, self).update()

                if not getSecurityManager().getUser().getId():
                    # this happens during ++widget++ traversal
                    return

                self.is_available()

                template_obj = get_saved_template_obj(self.context)

                if not template_obj:
                    # This happens if the user access the step directly and
                    # the wizard storage was expired or never existent.
                    return self.request.RESPONSE.redirect(
                        '{}/dossier_with_template'.format(
                            self.context.absolute_url()))

                template_values = template_obj.get_schema_values()
                title_help = IDossierTemplateSchema(template_obj).title_help

                for group in self.groups:
                    for widgetname in group.widgets:

                        # Skip not whitelisted template fields.
                        # We don't want to update fields which are not
                        # whitelisted in the template.
                        template_widget_name = self.get_template_widget_name(
                            widgetname)
                        if template_widget_name not in TEMPLATABLE_FIELDS:
                            continue

                        value = template_values.get(template_widget_name)
                        widget = group.widgets.get(widgetname)

                        # If the current field is the title field and the
                        # title_help is set, we remove the input-value and
                        # add a field description with the title_help text
                        # instead.
                        if widget.field == IOpenGeverBase[
                                'title'] and title_help:
                            widget.dynamic_description = title_help
                            value = ''

                        # Set the template value to the dossier add-form widget.
                        widget.value = IDataConverter(widget).toWidgetValue(
                            value)

                        if widgetname == 'IDossier.keywords':
                            self._modify_keyword_widget_according_to_template(
                                widget)
Beispiel #6
0
    def is_subdossier_allowed(self):
        if self.is_respect_max_dossier_depth:
            max_dossier_depth = api.portal.get_registry_record(
                'maximum_dossier_depth', interface=IDossierContainerTypes)

            current_levels = len([
                item for item in self.aq_chain
                if IDossierTemplateSchema.providedBy(item)
            ])
            return current_levels <= max_dossier_depth

        return True
Beispiel #7
0
            def recursive_content_creation(self, template_obj, target_container):
                responsible = IDossier(target_container).responsible

                for child_obj in template_obj.listFolderContents():
                    if IDossierTemplateSchema.providedBy(child_obj):
                        dossier = CreateDossierFromTemplateCommand(
                            target_container, child_obj).execute()

                        IDossier(dossier).responsible = responsible

                        self.recursive_content_creation(child_obj, dossier)
                    else:
                        CreateDocumentFromTemplateCommand(
                            target_container, child_obj, child_obj.title).execute()
Beispiel #8
0
            def recursive_content_creation(self, template_obj,
                                           target_container):
                responsible = IDossier(target_container).responsible

                for child_obj in template_obj.listFolderContents():
                    if IDossierTemplateSchema.providedBy(child_obj):
                        dossier = CreateDossierFromTemplateCommand(
                            target_container, child_obj).execute()

                        IDossier(dossier).responsible = responsible

                        self.recursive_content_creation(child_obj, dossier)
                    else:
                        CreateDocumentFromTemplateCommand(
                            target_container, child_obj,
                            child_obj.title).execute()
Beispiel #9
0
 def test_dossiertemplate_provides_the_IDossierTemplate_behavior(self):
     dossiertemplate = create(Builder('dossiertemplate'))
     self.assertTrue(IDossierTemplateSchema.providedBy(dossiertemplate))
Beispiel #10
0
 def test_dossiertemplate_provides_the_IDossierTemplate_behavior(self):
     dossiertemplate = create(Builder('dossiertemplate'))
     self.assertTrue(IDossierTemplateSchema.providedBy(dossiertemplate))
 def label(self):
     if IDossierTemplateSchema.providedBy(aq_parent(aq_inner(self.context))):
         return _(u'Edit Subdossier')
     return super(DossierTemplateEditForm, self).label
 def label(self):
     if IDossierTemplateSchema.providedBy(self.context):
         return _(u'Add Subdossier')
     return super(DossierTemplateAddForm, self).label
 def is_subdossier(self):
     parent = aq_parent(aq_inner(self))
     return bool(IDossierTemplateSchema.providedBy(parent))
    def test_dossiertemplate_provides_the_IDossierTemplate_behavior(self):
        self.login(self.administrator)

        self.assertTrue(IDossierTemplateSchema.providedBy(self.dossiertemplate))
Beispiel #15
0
 def label(self):
     if IDossierTemplateSchema.providedBy(aq_parent(aq_inner(
             self.context))):
         return _(u'Edit Subdossier')
     return super(DossierTemplateEditForm, self).label
Beispiel #16
0
 def label(self):
     if IDossierTemplateSchema.providedBy(self.context):
         return _(u'Add Subdossier')
     return super(DossierTemplateAddForm, self).label
Beispiel #17
0
 def is_subdossier(self):
     parent = aq_parent(aq_inner(self))
     return bool(IDossierTemplateSchema.providedBy(parent))