コード例 #1
0
ファイル: image.py プロジェクト: liqd/adhocracy3
    """Validate image mime type of `value`."""
    mimetype = value.mimetype
    image_mime_type_validator(node, mimetype)


class ImageMetadataSchema(AssetMetadataSchema):
    """Data structure storing image asset metadata."""

    detail = Resource(dimensions=Dimensions(width=800, height=800),
                      readonly=True)
    thumbnail = Resource(dimensions=Dimensions(width=100, height=100),
                         readonly=True)


image_metadata_meta = asset_metadata_meta._replace(
    isheet=IImageMetadata,
    schema_class=ImageMetadataSchema,
)


class IImageReference(ISheet, ISheetReferenceAutoUpdateMarker):
    """Marker interface for an image reference."""


class ImageReference(SheetToSheet):
    """Reference to an image."""

    source_isheet = IImageReference
    source_isheet_field = 'picture'
    target_isheet = IImageMetadata

コード例 #2
0
ファイル: image.py プロジェクト: fhartwig/adhocracy3.mercator
from adhocracy_core.interfaces import SheetToSheet


class IImageMetadata(IAssetMetadata):
    """Marker interface for images."""


def image_mime_type_validator(mime_type: str) -> bool:
    """Validate image file types."""
    return mime_type in ('image/gif', 'image/jpeg', 'image/png')


image_metadata_meta = asset_metadata_meta._replace(
    isheet=IImageMetadata,
    mime_type_validator=image_mime_type_validator,
    image_sizes={
        'thumbnail': Dimensions(width=100, height=100),
        'detail': Dimensions(width=800, height=800)
    },
)


class IImageReference(ISheet, ISheetReferenceAutoUpdateMarker):
    """Marker interface for an image reference."""


class ImageReference(SheetToSheet):
    """Reference to an image."""

    source_isheet = IImageReference
    source_isheet_field = 'picture'
    target_isheet = IImageMetadata
コード例 #3
0
ファイル: image.py プロジェクト: robx/adhocracy3.mercator
from adhocracy_core.interfaces import SheetToSheet


class IImageMetadata(IAssetMetadata):

    """Marker interface for images."""


def image_mime_type_validator(mime_type: str) -> bool:
    """Validate image file types."""
    return mime_type in ('image/gif', 'image/jpeg', 'image/png')


image_metadata_meta = asset_metadata_meta._replace(
    isheet=IImageMetadata,
    mime_type_validator=image_mime_type_validator,
    image_sizes={'thumbnail': Dimensions(width=100, height=100),
                 'detail': Dimensions(width=800, height=800)},
)


class IImageReference(ISheet, ISheetReferenceAutoUpdateMarker):

    """Marker interface for an image reference."""


class ImageReference(SheetToSheet):

    """Reference to an image."""

    source_isheet = IImageReference
    source_isheet_field = 'picture'
コード例 #4
0

image_mime_type_validator = OneOf(('image/gif', 'image/jpeg', 'image/png'))


class ImageMetadataSchema(AssetMetadataSchema):
    """Data structure storing image asset metadata."""

    mime_type = SingleLine(missing=required,
                           validator=image_mime_type_validator)
    detail = Resource(dimensions=Dimensions(width=800, height=800))
    thumbnail = Resource(dimensions=Dimensions(width=100, height=100))


image_metadata_meta = asset_metadata_meta._replace(
    isheet=IImageMetadata,
    schema_class=ImageMetadataSchema,
)


class IImageReference(ISheet, ISheetReferenceAutoUpdateMarker):
    """Marker interface for an image reference."""


class ImageReference(SheetToSheet):
    """Reference to an image."""

    source_isheet = IImageReference
    source_isheet_field = 'picture'
    target_isheet = IImageMetadata

コード例 #5
0
organizationinfo_meta = sheet_meta._replace(
    isheet=IOrganizationInfo, schema_class=OrganizationInfoSchema)


class IIntroImageMetadata(IAssetMetadata):
    """Marker interface for intro images."""


def _intro_image_mime_type_validator(mime_type: str) -> bool:
    return mime_type in ('image/gif', 'image/jpeg', 'image/png')


intro_image_metadata_meta = asset_metadata_meta._replace(
    isheet=IIntroImageMetadata,
    mime_type_validator=_intro_image_mime_type_validator,
    image_sizes={
        'thumbnail': Dimensions(width=105, height=90),
        'detail': Dimensions(width=800, height=350)
    },
)


class IntroImageReference(SheetToSheet):
    """Reference to an intro image."""

    source_isheet = IIntroduction
    source_isheet_field = 'picture'
    target_isheet = IIntroImageMetadata


class IntroductionSchema(colander.MappingSchema):
    """Data structure for the proposal introduction."""
コード例 #6
0
ファイル: mercator.py プロジェクト: robx/adhocracy3.mercator
organizationinfo_meta = sheet_meta._replace(isheet=IOrganizationInfo, schema_class=OrganizationInfoSchema)


class IIntroImageMetadata(IAssetMetadata):

    """Marker interface for intro images."""


def _intro_image_mime_type_validator(mime_type: str) -> bool:
    return mime_type in ("image/gif", "image/jpeg", "image/png")


intro_image_metadata_meta = asset_metadata_meta._replace(
    isheet=IIntroImageMetadata,
    mime_type_validator=_intro_image_mime_type_validator,
    image_sizes={"thumbnail": Dimensions(width=105, height=90), "detail": Dimensions(width=800, height=350)},
)


class IntroImageReference(SheetToSheet):

    """Reference to an intro image."""

    source_isheet = IIntroduction
    source_isheet_field = "picture"
    target_isheet = IIntroImageMetadata


class IntroductionSchema(colander.MappingSchema):