Ejemplo n.º 1
0
class MockFileServiceConfig(FileServiceConfig):
    """File service configuration."""

    record_cls = RecordWithFiles
    permission_policy_cls = PermissionPolicy

    file_links_list = {
        "self": RecordLink("{+api}/mocks/{id}/files"),
    }

    file_links_item = {
        "self": FileLink("{+api}/mocks/{id}/files/{key}"),
        "content": FileLink("{+api}/mocks/{id}/files/{key}/content"),
        "commit": FileLink("{+api}/mocks/{id}/files/{key}/commit"),
    }
Ejemplo n.º 2
0
class RDMFileDraftServiceConfig(FileServiceConfig):
    """Configuration for draft files."""

    record_cls = RDMDraft
    permission_policy_cls = RDMRecordPermissionPolicy

    file_links_list = {
        "self": RecordLink("{+api}/records/{id}/draft/files"),
    }

    file_links_item = {
        "self": FileLink("{+api}/records/{id}/draft/files/{key}"),
        "content": FileLink("{+api}/records/{id}/draft/files/{key}/content"),
        "commit": FileLink("{+api}/records/{id}/draft/files/{key}/commit"),
    }
Ejemplo n.º 3
0
class RDMFileDraftServiceConfig(FileServiceConfig, ConfiguratorMixin):
    """Configuration for draft files."""

    record_cls = RDMDraft
    permission_action_prefix = "draft_"
    permission_policy_cls = FromConfig("RDM_PERMISSION_POLICY",
                                       default=RDMRecordPermissionPolicy)

    file_links_list = {
        "self": RecordLink("{+api}/records/{id}/draft/files"),
    }

    file_links_item = {
        "self": FileLink("{+api}/records/{id}/draft/files/{key}"),
        "content": FileLink("{+api}/records/{id}/draft/files/{key}/content"),
        "commit": FileLink("{+api}/records/{id}/draft/files/{key}/commit"),
    }
Ejemplo n.º 4
0
class RDMFileDraftServiceConfig(FileServiceConfig, ConfiguratorMixin):
    """Configuration for draft files."""

    record_cls = RDMDraft
    permission_action_prefix = "draft_"
    permission_policy_cls = FromConfig("RDM_PERMISSION_POLICY",
                                       default=RDMRecordPermissionPolicy)

    file_links_list = {
        "self": RecordLink("{+api}/records/{id}/draft/files"),
    }

    file_links_item = {
        "self":
        FileLink("{+api}/records/{id}/draft/files/{key}"),
        "content":
        FileLink("{+api}/records/{id}/draft/files/{key}/content"),
        "commit":
        FileLink("{+api}/records/{id}/draft/files/{key}/commit"),
        # FIXME: should we check if the file is IIIF compatible?
        # FIXME: filename instead
        "iiif_canvas":
        FileLink("{+api}/iiif/draft:{id}/canvas/{key}"),
        "iiif_base":
        FileLink("{+api}/iiif/draft:{id}:{key}"),
        "iiif_info":
        FileLink("{+api}/iiif/draft:{id}:{key}/info.json"),
        "iiif_api":
        FileLink("{+api}/iiif/draft:{id}:{key}/{region=full}"
                 "/{size=full}/{rotation=0}/{quality=default}.{format=png}"),
    }
class CommunityFileServiceConfig(FileServiceConfig):
    """Configuration for community files."""

    record_cls = Community
    permission_policy_cls = CommunityPermissionPolicy

    file_links_item = {
        "self": FileLink("{+api}/communities/{id}/logo"),
    }
Ejemplo n.º 6
0
class RDMFileRecordServiceConfig(FileServiceConfig, ConfiguratorMixin):
    """Configuration for record files."""

    record_cls = RDMRecord
    permission_policy_cls = FromConfig("RDM_PERMISSION_POLICY",
                                       default=RDMRecordPermissionPolicy)

    file_links_item = {
        **FileServiceConfig.file_links_item,
        # FIXME: should we check if the file is IIIF compatible?
        # FIXME: filename instead
        "iiif_canvas":
        FileLink("{+api}/iiif/record:{id}/canvas/{key}"),
        "iiif_base":
        FileLink("{+api}/iiif/record:{id}:{key}"),
        "iiif_info":
        FileLink("{+api}/iiif/record:{id}:{key}/info.json"),
        "iiif_api":
        FileLink("{+api}/iiif/record:{id}:{key}/{region=full}"
                 "/{size=full}/{rotation=0}/{quality=default}.{format=png}"),
    }