예제 #1
0
 def add(self, form):
     if ISimpleForm.providedBy(form):
         form_sheet = FlexFormSheet(form, self)
         self.sheets.append(form_sheet)
         return form_sheet
     if IMultiForm.providedBy(form):
         form_sheet = MultiRecordFormSheet(form, self)
         self.sheets.append(form_sheet)
         return form_sheet
예제 #2
0
 def add(self, form):
     if ISimpleForm.providedBy(form):
         form_sheet = FlexFormSheet(form, self)
         self.sheets.append(form_sheet)
         return form_sheet
     if IMultiForm.providedBy(form):
         form_sheet = MultiRecordFormSheet(form, self)
         self.sheets.append(form_sheet)
         return form_sheet
예제 #3
0
def form_configuration_modified(context, event):
    if not is_definition_modified(context, event):
        return
    if not IBaseForm.providedBy(context):
        raise ValueError('context must be IBaseForm provider')
    ## re-sign context and data-record with current definition/schema:
    try:
        definition = form_definition(context)
    except ValueError:
        return  # no definition means no schema to sync
    if ISimpleForm.providedBy(context):
        components = IFormComponents(definition)
        sync_simple_form(context, components)
    elif IMultiForm.providedBy(context):
        sync_multi_form(context, definition)
예제 #4
0
 def update(self, *args, **kwargs):
     secmgr = getSecurityManager()
     self.forms = []
     for form in self.content():
         if not secmgr.checkPermission('View', form):
             continue  # user does not have permission to include form
         if not IBaseForm.providedBy(form):
             continue  # ignore non-form content
         if ISimpleForm.providedBy(form):
             if self._flex_form_hasdata(form):
                 self.forms.append(form)
         if IMultiForm.providedBy(form):
             notes = getattr(form, 'entry_notes', '') or ''
             if len(form.keys()) or notes:
                 self.forms.append(form)  # non-empty multiform
     keyfn = lambda o: getattr(aq_base(o), 'start', None)
     self.forms = sorted(self.forms, key=keyfn)
예제 #5
0
 def update(self, *args, **kwargs):
     secmgr = getSecurityManager()
     self.forms = []
     for form in self.content():
         if not secmgr.checkPermission('View', form):
             continue  # user does not have permission to include form
         if not IBaseForm.providedBy(form):
             continue  # ignore non-form content
         if ISimpleForm.providedBy(form):
             if self._flex_form_hasdata(form):
                 self.forms.append(form)
         if IMultiForm.providedBy(form):
             notes = getattr(form, 'entry_notes', '') or ''
             if len(form.keys()) or notes:
                 self.forms.append(form)  # non-empty multiform
     keyfn = lambda o: getattr(aq_base(o), 'start', None)
     self.forms = sorted(self.forms, key=keyfn)
예제 #6
0
def update_form_entries(context):
    blocked_states = ('published', 'archived')
    definition = context
    if IFieldGroup.providedBy(context):
        definition = context.__parent__
    bound_forms = IFormSet(definition)
    simple_forms = [f for f in bound_forms.values()
                    if ISimpleForm.providedBy(f)]
    multi_forms = [f for f in bound_forms.values()
                   if IMultiForm.providedBy(f)]
    wftool = getToolByName(definition, 'portal_workflow')
    components = IFormComponents(definition)
    for form in simple_forms:
        if wftool.getInfoFor(form, 'review_state') not in blocked_states:
            sync_simple_form(form, components)
    for form in multi_forms:
        if wftool.getInfoFor(form, 'review_state') not in blocked_states:
            sync_multi_form(form, definition)
예제 #7
0
def verify(definition, saver, wftool):
    # verify that definition signature matches schema
    computed = saver.signature(definition.schema)
    assert computed == definition.signature
    # verify schema in saver
    assert computed in saver
    # verify serialize/load round-trip for schema saving
    assert saver.signature(saver.load(saver.get(computed))) == computed
    # verify that all form entries are signed with same signature
    forms = IFormSet(definition).values()
    for form in forms:
        blocked_states = ('published', 'archived')
        if wftool.getInfoFor(form, 'review_state') in blocked_states:
            continue   # archived or published form, ignore as preserved
        if IMultiForm.providedBy(form):
            records = form.values()
            assert all(map(lambda v: v.signature == computed, records))
        if ISimpleForm.providedBy(form):
            pass  # TODO
예제 #8
0
 def __init__(self, context, workbook):
     if not ISimpleForm.providedBy(context):
         raise TypeError('Incorrect context, must provide ISimpleForm')
     super(FlexFormSheet, self).__init__(context, workbook)
     self._groups = None
예제 #9
0
 def __init__(self, context, workbook):
     if not ISimpleForm.providedBy(context):
         raise TypeError('Incorrect context, must provide ISimpleForm')
     super(FlexFormSheet, self).__init__(context, workbook)
     self._groups = None