Esempio n. 1
0
def test_clear_modification_date(registry, request_):
    from adhocracy_core.utils import get_modification_date
    from . import clear_modification_date_callback
    date_before = get_modification_date(registry)
    clear_modification_date_callback(request_)
    date_after = get_modification_date(registry)
    assert date_before is not date_after
Esempio n. 2
0
def test_clear_modification_date(registry, request_):
    from adhocracy_core.utils import get_modification_date
    from . import clear_modification_date_callback
    date_before = get_modification_date(registry)
    clear_modification_date_callback(request_)
    date_after = get_modification_date(registry)
    assert date_before is not date_after
Esempio n. 3
0
def update_modification_date_modified_by(event):
    """Update the IMetadata fields `modified_by` and `modification_date`."""
    sheet = event.registry.content.get_sheet(event.object, IMetadata,
                                             request=event.request)
    appstruct = {}
    appstruct['modification_date'] = get_modification_date(event.registry)
    if event.request is not None:
        appstruct['modified_by'] = event.request.user
    sheet.set(appstruct,
              send_event=False,
              omit_readonly=False,
              )
Esempio n. 4
0
    def _get_metadata(self, resource: IResource, creator: IResource,
                      registry: Registry) -> dict:
        now = get_modification_date(registry)
        creator = creator if creator is not None else None
        metadata = {'creator': creator,
                    'creation_date': now,
                    'item_creation_date': now,
                    'modified_by': creator,
                    'modification_date': now,
                    }

        item = find_interface(resource, IItem)
        if IItemVersion.providedBy(resource) and item is not None:
            item_sheet = get_sheet(item, IMetadata, registry=registry)
            item_creation_date = item_sheet.get()['creation_date']
            metadata['item_creation_date'] = item_creation_date
        return metadata