Beispiel #1
0
    def set_references_for_isheet(self, source, isheet: ISheet,
                                  references: dict, registry: Registry,
                                  send_event=True):
        """Set references of this source for one isheet.

        :param references: dictionary with the following content:
                           key - isheet field name
                           value - reference targets
        :param registry: Pyramid Registry with
                         :class:`adhocracy_core.content.ResourceContentRegistry`
                         attribute named `content`.
        """
        sheet_meta = registry.content.sheets_meta[isheet]
        schema = sheet_meta.schema_class()
        for field_name, targets in references.items():
            assert field_name in schema
            if targets is None:
                continue
            node = schema[field_name]
            reftype = getattr(node, 'reftype', None)
            if reftype is None:
                continue
            if IResource.providedBy(targets):
                targets = [targets]
            self.set_references(source, targets, reftype, registry,
                                send_event=send_event)
Beispiel #2
0
    def set_references_for_isheet(self,
                                  source,
                                  isheet: ISheet,
                                  references: dict,
                                  registry: Registry,
                                  send_event=True):
        """Set references of this source for one isheet.

        :param references: dictionary with the following content:
                           key - isheet field name
                           value - reference targets
        :param registry: Pyramid Registry with
                         :class:`adhocracy_core.content.ResourceContentRegistry`
                         attribute named `content`.
        """
        sheet_meta = registry.content.sheets_meta[isheet]
        schema = sheet_meta.schema_class()
        for field_name, targets in references.items():
            assert field_name in schema
            if targets is None:
                continue
            node = schema[field_name]
            reftype = getattr(node, 'reftype', None)
            if reftype is None:
                continue
            if IResource.providedBy(targets):
                targets = [targets]
            self.set_references(source,
                                targets,
                                reftype,
                                registry,
                                send_event=send_event)
Beispiel #3
0
def _assignment_exists(assignment_appstruct: dict, assignments: IResource,
                       registry: Registry):
    for assignment in assignments.values():
        if assignment_appstruct == \
           registry.content.get_sheet(assignment,
                                      sheets.badge.IBadgeAssignment).get():
            return True
    return False
def _assignment_exists(assignment_appstruct: dict, assignments: IResource,
                       registry: Registry):
    for assignment in assignments.values():
        if assignment_appstruct == \
           registry.content.get_sheet(assignment,
                                      sheets.badge.IBadgeAssignment).get():
            return True
    return False
Beispiel #5
0
 def test_add_resource_type(self, config, resource_meta):
     config.include('adhocracy_core.content')
     self.make_one(resource_meta, config)
     resource = config.registry.content.create(IResource.__identifier__)
     assert IResource.providedBy(resource)
Beispiel #6
0
 def test_add_resource_type(self, config, resource_meta):
     config.include('adhocracy_core.content')
     self.make_one(resource_meta, config)
     resource = config.registry.content.create(IResource.__identifier__)
     assert IResource.providedBy(resource)