Beispiel #1
0
"""Basic organisation pool to structure processes."""
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources.process import IProcess


class IOrganisation(IPool):
    """Organisation Pool."""


organisation_meta = pool_meta._replace(
    iresource=IOrganisation,
    permission_create='create_organisation',
    is_implicit_addable=True,
    element_types=(IProcess,
                   IOrganisation,
                   ),
)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(organisation_meta, config)
Beispiel #2
0
from adhocracy_core.resources.rate import add_ratesservice
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import IBasicPool
from adhocracy_core.resources.pool import pool_meta

import adhocracy_core.sheets.document
import adhocracy_core.sheets.comment


class IExternalResource(IBasicPool):

    """An external resource.

    This is currently a commentable simple.
    """


external_resource_meta = pool_meta._replace(
    content_name='ExternalResource',
    iresource=IExternalResource,
    element_types=(IComment,),
    is_implicit_addable=True,
    permission_create='create_external',
    extended_sheets=(adhocracy_core.sheets.comment.ICommentable,),
)._add(after_creation=(add_commentsservice, add_ratesservice))


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(external_resource_meta, config)
Beispiel #3
0
class IProcess(IPool):
    """Participation Process Pool."""


process_meta = pool_meta._replace(
    content_name=_('Process'),
    iresource=IProcess,
    permission_create='create_process',
    is_sdi_addable=True,
    after_creation=(add_assets_service,
                    add_badges_service,
                    ),
    default_workflow='sample',
    alternative_workflows=(
        'standard',
        'standard_private',
        'debate',
        'debate_private',
    )
)._add(basic_sheets=(IHasAssetPool,
                     IHasBadgesPool,
                     IDescription,
                     IEmbed,
                     IFollowable,
                     IAllowAddAnonymized,
                     ))


def process_embed_code_config_adapter(context: IResource,
                                      request: IRequest) -> {}:
    """Return config to render `adhocracy_core:templates/embed_code.html`."""
Beispiel #4
0
    meta_appstruct = {
        'size': file.size,
        'filename': file.title,
        'mime_type': file.mimetype,
    }
    meta_sheet.set(meta_appstruct, omit_readonly=False)


asset_meta = pool_meta._replace(
    content_name='Asset',
    iresource=IAsset,
    basic_sheets=(
        adhocracy_core.sheets.metadata.IMetadata,
        adhocracy_core.sheets.asset.IAssetData,
        adhocracy_core.sheets.title.ITitle,
    ),
    extended_sheets=(
        # all subtypes need to provide an IAssetMetadata sheet
        adhocracy_core.sheets.asset.IAssetMetadata, ),
    use_autonaming=True,
    permission_create='create_asset',
    after_creation=(add_metadata, ),
    is_sdi_addable=True,
)


class IAssetsService(IServicePool):
    """The 'assets' ServicePool."""


assets_service_meta = service_meta._replace(
    iresource=IAssetsService,
Beispiel #5
0
    appstructs = {IName.__identifier__: {'name': name},
                  IAssetData.__identifier__: {'data': file_download}}
    registry.content.create(IAssetDownload.__identifier__,
                            parent=context,
                            appstructs=appstructs,
                            registry=registry)


asset_meta = pool_meta._replace(
    content_name='Asset',
    iresource=IAsset,
    basic_sheets=(
        adhocracy_core.sheets.metadata.IMetadata,
        adhocracy_core.sheets.asset.IAssetData,
        adhocracy_core.sheets.title.ITitle,
    ),
    extended_sheets=(
        # all subtypes need to provide an IAssetMetadata sheet
        adhocracy_core.sheets.asset.IAssetMetadata,
    ),
    use_autonaming=True,
    permission_create='create_asset',
    after_creation=[validate_and_complete_asset],
)


class IAssetsService(IServicePool):

    """The 'assets' ServicePool."""


assets_service_meta = service_meta._replace(
        sheet = get_sheet(self, IMetadata)
        appstruct = sheet.get()
        appstruct['hidden'] = not active
        sheet.set(appstruct)


user_meta = pool_meta._replace(
    iresource=IUser,
    content_class=User,
    basic_sheets=(
        adhocracy_core.sheets.principal.IUserBasic,
        adhocracy_core.sheets.principal.IUserExtended,
        adhocracy_core.sheets.principal.IPermissions,
        adhocracy_core.sheets.metadata.IMetadata,
        adhocracy_core.sheets.pool.IPool,
    ),
    extended_sheets=(
        adhocracy_core.sheets.principal.IPasswordAuthentication,
        adhocracy_core.sheets.rate.ICanRate,
        adhocracy_core.sheets.badge.ICanBadge,
        adhocracy_core.sheets.badge.IBadgeable,
    ),
    element_types=(),  # we don't want the frontend to post resources here
    use_autonaming=True,
    permission_create='create_user',
)


class IUsersService(IServicePool):
    """Service Pool for Users."""

Beispiel #7
0
from adhocracy_core.interfaces import IServicePool
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources import add_resource_type_to_registry
import adhocracy_core.sheets.name
import adhocracy_core.sheets.pool
import adhocracy_core.sheets.metadata


class IBasicService(IServicePool):
    """Basic :term:`service` resource type.

    The resource name is always set to the `content_name`.
    """


# TODO remove IBasicService, use IService instead

service_meta = pool_meta._replace(content_name='service',
                                  iresource=IBasicService,
                                  basic_sheets=(
                                      adhocracy_core.sheets.pool.IPool,
                                      adhocracy_core.sheets.metadata.IMetadata,
                                  ),
                                  permission_create='create_service')


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(service_meta, config)
Beispiel #8
0
        self.active = active
        sheet = get_sheet(self, IMetadata)
        appstruct = sheet.get()
        appstruct['hidden'] = not active
        sheet.set(appstruct)


user_meta = pool_meta._replace(
    iresource=IUser,
    content_class=User,
    basic_sheets=(adhocracy_core.sheets.principal.IUserBasic,
                  adhocracy_core.sheets.principal.IUserExtended,
                  adhocracy_core.sheets.principal.IPermissions,
                  adhocracy_core.sheets.metadata.IMetadata,
                  adhocracy_core.sheets.pool.IPool,
                  ),
    extended_sheets=(adhocracy_core.sheets.principal.IPasswordAuthentication,
                     adhocracy_core.sheets.rate.ICanRate,
                     adhocracy_core.sheets.badge.ICanBadge,
                     adhocracy_core.sheets.badge.IBadgeable,
                     ),
    element_types=(),  # we don't want the frontend to post resources here
    use_autonaming=True,
    permission_create='create_user',
)


class IUsersService(IServicePool):

    """Service Pool for Users."""

Beispiel #9
0
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.asset import add_assets_service
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources.process import IProcess
from adhocracy_core.sheets.asset import IHasAssetPool
from adhocracy_core.sheets.description import IDescription
from adhocracy_core.sheets.image import IImageReference


class IOrganisation(IPool):
    """Organisation Pool."""


organisation_meta = pool_meta._replace(
    iresource=IOrganisation,
    permission_create='create_organisation',
    is_implicit_addable=True,
    element_types=(IProcess,
                   IOrganisation,
                   ),
    after_creation=(add_assets_service,)
)._add(basic_sheets=(IDescription,
                     IImageReference,),
       extended_sheets=(IHasAssetPool,),)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(organisation_meta, config)
Beispiel #10
0
from adhocracy_core.interfaces import IServicePool
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources import add_resource_type_to_registry
import adhocracy_core.sheets.name
import adhocracy_core.sheets.pool
import adhocracy_core.sheets.metadata


class IBasicService(IServicePool):
    """Basic :term:`service` resource type.

    The resource name is always set to the `content_name`.
    """

# TODO remove IBasicService, use IService instead


service_meta = pool_meta._replace(
    content_name='service',
    iresource=IBasicService,
    basic_sheets=(adhocracy_core.sheets.pool.IPool,
                  adhocracy_core.sheets.metadata.IMetadata,
                  ),
    permission_create='create_service'
)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(service_meta, config)
Beispiel #11
0
            title = content.get_sheet_field(subobject, ITitle, 'title')
    additional_columns = [
        {'name': 'Type', 'value': content_name},
        {'name': 'Title', 'value': title},
    ]
    return default_columnspec + additional_columns


organisation_meta = pool_meta._replace(
    content_name='Organisation',
    iresource=IOrganisation,
    permission_create='create_organisation',
    is_implicit_addable=True,
    is_sdi_addable=True,
    sdi_column_mapper=sdi_organisation_columns,
    element_types=(IProcess,
                   IOrganisation,
                   ),
    after_creation=(add_assets_service,
                    enabled_ordering)
)._add(basic_sheets=(IDescription,
                     IImageReference,
                     IFollowable,
                     ),
       extended_sheets=(IHasAssetPool,),)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(organisation_meta, config)
Beispiel #12
0

user_meta = pool_meta._replace(
    iresource=IUser,
    content_class=User,
    basic_sheets=(adhocracy_core.sheets.principal.IUserBasic,
                  adhocracy_core.sheets.principal.IUserExtended,
                  adhocracy_core.sheets.description.IDescription,
                  adhocracy_core.sheets.principal.ICaptcha,
                  adhocracy_core.sheets.principal.IPermissions,
                  adhocracy_core.sheets.metadata.IMetadata,
                  adhocracy_core.sheets.pool.IPool,
                  adhocracy_core.sheets.principal.IEmailNew,
                  ),
    extended_sheets=(adhocracy_core.sheets.principal.IPasswordAuthentication,
                     adhocracy_core.sheets.principal.IActivationConfiguration,
                     adhocracy_core.sheets.principal.IAnonymizeDefault,
                     adhocracy_core.sheets.rate.ICanRate,
                     adhocracy_core.sheets.badge.ICanBadge,
                     adhocracy_core.sheets.badge.IBadgeable,
                     adhocracy_core.sheets.image.IImageReference,
                     adhocracy_core.sheets.notification.INotification,
                     adhocracy_core.sheets.principal.IServiceKonto,
                     adhocracy_core.sheets.principal.IServiceKontoSettings,
                     ),
    element_types=(),  # we don't want the frontend to post resources here
    use_autonaming=True,
    permission_create='create_user',
    is_sdi_addable=True,
)

Beispiel #13
0
"""Basic organisation pool to structure processes."""
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources.process import IProcess


class IOrganisation(IPool):
    """Organisation Pool."""


organisation_meta = pool_meta._replace(
    iresource=IOrganisation,
    permission_create='create_organisation',
    is_implicit_addable=True,
    element_types=(
        IProcess,
        IOrganisation,
    ),
)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(organisation_meta, config)
Beispiel #14
0
class IProcess(IPool):
    """Participation Process Pool."""


process_meta = pool_meta._replace(content_name=_('Process'),
                                  iresource=IProcess,
                                  permission_create='create_process',
                                  is_sdi_addable=True,
                                  after_creation=(
                                      add_assets_service,
                                      add_badges_service,
                                  ),
                                  default_workflow='sample',
                                  alternative_workflows=(
                                      'standard',
                                      'standard_private',
                                      'debate',
                                      'debate_private',
                                  ))._add(basic_sheets=(
                                      IHasAssetPool,
                                      IHasBadgesPool,
                                      IDescription,
                                      IEmbed,
                                      IFollowable,
                                      IAllowAddAnonymized,
                                  ))


def process_embed_code_config_adapter(context: IResource,
                                      request: IRequest) -> {}:
    """Return config to render `adhocracy_core:templates/embed_code.html`."""
Beispiel #15
0
user_meta = pool_meta._replace(
    iresource=IUser,
    content_class=User,
    basic_sheets=(
        adhocracy_core.sheets.principal.IUserBasic,
        adhocracy_core.sheets.principal.IUserExtended,
        adhocracy_core.sheets.description.IDescription,
        adhocracy_core.sheets.principal.ICaptcha,
        adhocracy_core.sheets.principal.IPermissions,
        adhocracy_core.sheets.metadata.IMetadata,
        adhocracy_core.sheets.pool.IPool,
        adhocracy_core.sheets.principal.IEmailNew,
    ),
    extended_sheets=(
        adhocracy_core.sheets.principal.IPasswordAuthentication,
        adhocracy_core.sheets.principal.IActivationConfiguration,
        adhocracy_core.sheets.principal.IAnonymizeDefault,
        adhocracy_core.sheets.rate.ICanRate,
        adhocracy_core.sheets.badge.ICanBadge,
        adhocracy_core.sheets.badge.IBadgeable,
        adhocracy_core.sheets.image.IImageReference,
        adhocracy_core.sheets.notification.INotification,
        adhocracy_core.sheets.principal.IServiceKonto,
        adhocracy_core.sheets.principal.IServiceKontoSettings,
    ),
    element_types=(),  # we don't want the frontend to post resources here
    use_autonaming=True,
    permission_create='create_user',
    is_sdi_addable=True,
)
Beispiel #16
0
"""Basic participation process."""
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources.asset import add_assets_service
from adhocracy_core.resources.badge import add_badges_service
from adhocracy_core.sheets.asset import IHasAssetPool
from adhocracy_core.sheets.badge import IHasBadgesPool


class IProcess(IPool):
    """Participation Process Pool."""


process_meta = pool_meta._replace(
    iresource=IProcess,
    permission_create='create_process',
    after_creation=(add_assets_service,
                    add_badges_service,
                    ),
    workflow_name='sample',
)._add(basic_sheets=(IHasAssetPool,
                     IHasBadgesPool))


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(process_meta, config)
Beispiel #17
0
    create(ITag.__identifier__, parent=context, appstructs=tag_first_data)
    tag_last_data = {'adhocracy_core.sheets.tags.ITag': {'elements':
                                                         [first_version]},
                     'adhocracy_core.sheets.name.IName': {'name': u'LAST'}}
    create(ITag.__identifier__, parent=context, appstructs=tag_last_data)


item_meta = pool_meta._replace(
    iresource=IItem,
    basic_sheets=(adhocracy_core.sheets.tags.ITags,
                  adhocracy_core.sheets.versions.IVersions,
                  adhocracy_core.sheets.pool.IPool,
                  adhocracy_core.sheets.metadata.IMetadata,
                  adhocracy_core.sheets.workflow.IWorkflowAssignment,
                  ),
    element_types=(IItemVersion,
                   ITag,
                   ),
    after_creation=(create_initial_content_for_item,),
    item_type=IItemVersion,
    permission_create='create_item',
    use_autonaming=True,
    autonaming_prefix='item_'
)


item_basic_sheets_without_name = tuple([x for x in item_meta.basic_sheets if
                                        x != adhocracy_core.sheets.name.IName])


def includeme(config):
Beispiel #18
0
                           registry=registry)
    request = options.get('request', None)
    tags_sheet.set({'FIRST': first_version,
                    'LAST': first_version},
                   request=request)


item_meta = pool_meta._replace(
    iresource=IItem,
    basic_sheets=(adhocracy_core.sheets.tags.ITags,
                  adhocracy_core.sheets.versions.IVersions,
                  adhocracy_core.sheets.pool.IPool,
                  adhocracy_core.sheets.metadata.IMetadata,
                  adhocracy_core.sheets.workflow.IWorkflowAssignment,
                  ),
    element_types=(IItemVersion,
                   ITag,
                   ),
    after_creation=(create_initial_content_for_item,),
    item_type=IItemVersion,
    permission_create='create_item',
    use_autonaming=True,
    autonaming_prefix='item_'
)


item_basic_sheets_without_name = tuple([x for x in item_meta.basic_sheets if
                                        x != adhocracy_core.sheets.name.IName])


def includeme(config):
Beispiel #19
0
        adhocracy_core.sheets.badge.IBadge,
    ),
    permission_create='create_badge',
)


class IBadgeGroup(IPool):

    """A generic badge group pool."""


badge_group_meta = pool_meta._replace(
    iresource=IBadgeGroup,
    extended_sheets=(
        adhocracy_core.sheets.description.IDescription,
    ),
    permission_create='create_badge_group',
    element_types=(IBadge,
                   IBadgeGroup,
                   ),
)


class IBadgesService(IServicePool):

    """The 'badges' ServicePool."""


badges_service_meta = service_meta._replace(
    iresource=IBadgesService,
    content_name='badges',
    element_types=(IBadge,
Beispiel #20
0
from adhocracy_core.resources.comment import add_commentsservice
from adhocracy_core.resources.rate import add_ratesservice
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import IBasicPool
from adhocracy_core.resources.pool import pool_meta

import adhocracy_core.sheets.document
import adhocracy_core.sheets.comment


class IExternalResource(IBasicPool):
    """An external resource.

    This is currently a commentable simple.
    """


external_resource_meta = pool_meta._replace(
    content_name='ExternalResource',
    iresource=IExternalResource,
    element_types=(IComment,),
    is_implicit_addable=True,
    permission_create='create_external',
    extended_sheets=(adhocracy_core.sheets.comment.ICommentable,),
)._add(after_creation=(add_commentsservice, add_ratesservice))


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(external_resource_meta, config)
Beispiel #21
0
badge_meta = simple_meta._replace(
    iresource=IBadge,
    extended_sheets=(adhocracy_core.sheets.description.IDescription, adhocracy_core.sheets.badge.IBadge),
    permission_create="create_badge",
)


class IBadgeGroup(IPool):

    """A generic badge group pool."""


badge_group_meta = pool_meta._replace(
    iresource=IBadgeGroup,
    extended_sheets=(adhocracy_core.sheets.description.IDescription,),
    permission_create="create_badge_group",
    element_types=(IBadge, IBadgeGroup),
)


class IBadgesService(IServicePool):

    """The 'badges' ServicePool."""


badges_service_meta = service_meta._replace(
    iresource=IBadgesService, content_name="badges", element_types=(IBadge, IBadgeGroup)
)


def add_badges_service(context: IPool, registry: Registry, options: dict):
Beispiel #22
0
"""Basic participation process."""
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.pool import pool_meta
from adhocracy_core.resources.asset import add_assets_service
from adhocracy_core.resources.badge import add_badges_service
from adhocracy_core.sheets.asset import IHasAssetPool
from adhocracy_core.sheets.badge import IHasBadgesPool


class IProcess(IPool):

    """Participation Process Pool."""


process_meta = pool_meta._replace(
    iresource=IProcess,
    permission_create='create_process',
    after_creation=(add_assets_service,
                    add_badges_service,
                    ),
    workflow_name='sample',
)._add(basic_sheets=(IHasAssetPool,
                     IHasBadgesPool))


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(process_meta, config)
Beispiel #23
0
    is_sdi_addable=True,
)._add(
    extended_sheets=(adhocracy_core.sheets.name.IName,)
)


class IBadgeGroup(IPool):
    """A generic badge group pool."""


badge_group_meta = pool_meta._replace(
    iresource=IBadgeGroup,
    extended_sheets=(
        adhocracy_core.sheets.description.IDescription,
    ),
    permission_create='create_badge_group',
    element_types=(IBadge,
                   IBadgeGroup,
                   ),
    is_sdi_addable=True,
)


class IParticipantsAssignableBadgeGroup(IBadgeGroup):
    """A badge group pool for badges assignable by participants."""


participants_assignable_badge_group_meta = badge_group_meta._replace(
    iresource=IParticipantsAssignableBadgeGroup,
    default_workflow='badge_assignment',
    element_types=(IBadge,