Esempio n. 1
0
multipolygon_meta = simple_meta._replace(
    iresource=IMultiPolygon,
    permission_create='create_multipolygon',
    is_implicit_addable=False,
    extended_sheets=(adhocracy_core.sheets.geo.IMultiPolygon, ),
)


class ILocationsService(IServicePool):
    """The 'locations' ServicePool."""


locations_service_meta = service_meta._replace(
    iresource=ILocationsService,
    content_name='locations',
    element_types=[
        IMultiPolygon,
    ],
)


def add_locations_service(context: IPool, registry: Registry, options: dict):
    """Add `locations` service to context."""
    registry.content.create(ILocationsService.__identifier__,
                            parent=context,
                            registry=registry)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(multipolygon_meta, config)
Esempio n. 2
0
                                       iresource=IPolarization,
                                       element_types=(IPolarizationVersion, ),
                                       item_type=IPolarizationVersion,
                                       use_autonaming=True,
                                       autonaming_prefix='polarization_',
                                       permission_create='create_relation',
                                       is_implicit_addable=True)


class IRelationsService(IServicePool):
    """The 'relations' ServicePool."""


relations_meta = service_meta._replace(
    iresource=IRelationsService,
    content_name='relations',
    element_types=(IRelation, ),
)


def add_relationsservice(context: IPool, registry: Registry, options: dict):
    """Add `relations` service to context."""
    registry.content.create(IRelationsService.__identifier__,
                            autoupdated=True,
                            parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(relations_meta, config)
    add_resource_type_to_registry(polarizationversion_meta, config)
Esempio n. 3
0
    """Add users, groups and resets subobjects to context."""
    registry.content.create(IUsersService.__identifier__,
                            parent=context,
                            registry=registry)
    registry.content.create(IGroupsService.__identifier__,
                            parent=context,
                            registry=registry)
    registry.content.create(IPasswordResetsService.__identifier__,
                            parent=context,
                            registry=registry)


principals_meta = service_meta._replace(
    iresource=IPrincipalsService,
    content_name='principals',
    element_types=(),  # we don't want the frontend to post resources here
    permission_create='create_service',
    extended_sheets=(adhocracy_core.sheets.badge.IHasBadgesPool, ),
)._add(after_creation=(create_initial_content_for_principals,
                       add_badges_service))


class IUser(IPool):
    """User resource.

    This inherits from IPool in order to allow to use this resource as a
    namespace for user objects.

    """

    active = Attribute('Whether the user account has been activated (bool)')
    activation_path = Attribute(
Esempio n. 4
0
    iresource=IComment,
    element_types=(ICommentVersion, ),
    item_type=ICommentVersion,
    use_autonaming=True,
    autonaming_prefix='comment_',
    permission_create='create_comment',
)


class ICommentsService(IServicePool):
    """The 'comments' ServicePool."""


comments_meta = service_meta._replace(
    iresource=ICommentsService,
    content_name='comments',
    element_types=(IComment, ),
    extended_sheets=(adhocracy_core.sheets.anonymize.IAllowAddAnonymized, ))


def add_commentsservice(context: IPool, registry: Registry, options: dict):
    """Add `comments` service to context."""
    registry.content.create(ICommentsService.__identifier__,
                            parent=context,
                            autoupdated=True)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(comments_meta, config)
    add_resource_type_to_registry(commentversion_meta, config)
Esempio n. 5
0
from pyramid.registry import Registry

from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.service import IServicePool
from adhocracy_core.resources.service import service_meta
from adhocracy_core.resources.document import IDocument


class ILogbookService(IServicePool):
    """The 'logbook' ServicePool."""


logbook_service_meta = service_meta._replace(
    iresource=ILogbookService,
    content_name='logbook',
    element_types=(IDocument,),
)


def add_logbook_service(context: IPool, registry: Registry, options: dict):
    """Add `logbook` service to context."""
    creator = options.get('creator')
    registry.content.create(ILogbookService.__identifier__,
                            parent=context,
                            creator=creator)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(logbook_service_meta, config)
Esempio n. 6
0
    is_implicit_addable=False,
    extended_sheets=(
        adhocracy_core.sheets.geo.IMultiPolygon,
    ),
)


class ILocationsService(IServicePool):

    """The 'locations' ServicePool."""


locations_service_meta = service_meta._replace(
    iresource=ILocationsService,
    content_name='locations',
    element_types=[
        IMultiPolygon,
    ],
)


def add_locations_service(context: IPool, registry: Registry, options: dict):
    """Add `locations` service to context."""
    registry.content.create(ILocationsService.__identifier__, parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(multipolygon_meta, config)
    add_resource_type_to_registry(locations_service_meta, config)
Esempio n. 7
0
                  adhocracy_core.sheets.description.IDescription,
                  adhocracy_core.sheets.metadata.IMetadata,
                  ),
    permission_create='create_page',
    is_sdi_addable=True,

)


class IPageService(IServicePool):
    """The 'page' ServicePool."""


page_service_meta = service_meta._replace(
    iresource=IPageService,
    content_name='pages',
    element_types=(IPage,),
)


def add_page_service(context: IPool, registry: Registry, options: dict):
    """Add `page` service to context."""
    registry.content.create(IPageService.__identifier__,
                            parent=context,
                            autoupdated=True)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(page_meta, config)
    add_resource_type_to_registry(page_service_meta, config)
Esempio n. 8
0
    iresource=IRate,
    element_types=(IRateVersion, ),
    item_type=IRateVersion,
    use_autonaming=True,
    autonaming_prefix='rate_',
    permission_create='create_rate',
)


class IRatesService(IServicePool):
    """The 'rates' ServicePool."""


rates_meta = service_meta._replace(
    iresource=IRatesService,
    content_name='rates',
    element_types=(IRate, ),
    extended_sheets=(IAllowAddAnonymized, ),
)


def add_ratesservice(context: IPool, registry: Registry, options: dict):
    """Add `rates` service to context."""
    registry.content.create(IRatesService.__identifier__,
                            autoupdated=True,
                            parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(rate_meta, config)
    add_resource_type_to_registry(rateversion_meta, config)
Esempio n. 9
0
        adhocracy_core.sheets.title.ITitle,
        adhocracy_core.sheets.description.IDescription,
        adhocracy_core.sheets.metadata.IMetadata,
    ),
    permission_create='create_page',
    is_sdi_addable=True,
)


class IPageService(IServicePool):
    """The 'page' ServicePool."""


page_service_meta = service_meta._replace(
    iresource=IPageService,
    content_name='pages',
    element_types=(IPage, ),
)


def add_page_service(context: IPool, registry: Registry, options: dict):
    """Add `page` service to context."""
    registry.content.create(IPageService.__identifier__,
                            parent=context,
                            autoupdated=True)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(page_meta, config)
    add_resource_type_to_registry(page_service_meta, config)
Esempio n. 10
0
    iresource=IRate,
    element_types=(IRateVersion,),
    item_type=IRateVersion,
    use_autonaming=True,
    autonaming_prefix='rate_',
    permission_create='create_rate',
)


class IRatesService(IServicePool):
    """The 'rates' ServicePool."""


rates_meta = service_meta._replace(
    iresource=IRatesService,
    content_name='rates',
    element_types=(IRate,),
)


def add_ratesservice(context: IPool, registry: Registry, options: dict):
    """Add `rates` service to context."""
    registry.content.create(IRatesService.__identifier__, parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(rate_meta, config)
    add_resource_type_to_registry(rateversion_meta, config)
    add_resource_type_to_registry(rates_meta, config)
Esempio n. 11
0
    element_types=(IRateVersion,),
    item_type=IRateVersion,
    use_autonaming=True,
    autonaming_prefix='rate_',
    permission_create='create_rate',
)


class IRatesService(IServicePool):

    """The 'rates' ServicePool."""


rates_meta = service_meta._replace(
    iresource=IRatesService,
    content_name='rates',
    element_types=(IRate,),
)


def add_ratesservice(context: IPool, registry: Registry, options: dict):
    """Add `rates` service to context."""
    registry.content.create(IRatesService.__identifier__, parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(rate_meta, config)
    add_resource_type_to_registry(rateversion_meta, config)
    add_resource_type_to_registry(rates_meta, config)
Esempio n. 12
0
    permission_create='create_activity',
    autonaming_prefix='activity',
    basic_sheets=(
        adhocracy_core.sheets.metadata.IMetadata,
        adhocracy_core.sheets.activity.IActivity,
    ),
)


class IActivityService(IServicePool):
    """The 'activity' ServicePool."""


activity_service_meta = service_meta._replace(
    iresource=IActivityService,
    content_name='activity_stream',
    element_types=(IActivity, ),
)


def add_activiy_service(context: IPool, registry: Registry, options: dict):
    """Add `activity` service to context."""
    registry.content.create(IActivityService.__identifier__,
                            parent=context,
                            autoupdated=True)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(activity_meta, config)
    add_resource_type_to_registry(activity_service_meta, config)
Esempio n. 13
0
    iresource=IComment,
    element_types=(ICommentVersion, ),
    item_type=ICommentVersion,
    use_autonaming=True,
    autonaming_prefix='comment_',
    permission_create='create_comment',
)


class ICommentsService(IServicePool):
    """The 'comments' ServicePool."""


comments_meta = service_meta._replace(
    iresource=ICommentsService,
    content_name='comments',
    element_types=(IComment, ),
)


def add_commentsservice(context: IPool, registry: Registry, options: dict):
    """Add `comments` service to context."""
    registry.content.create(ICommentsService.__identifier__, parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(comments_meta, config)
    add_resource_type_to_registry(commentversion_meta, config)
    add_resource_type_to_registry(comment_meta, config)
Esempio n. 14
0
from pyramid.registry import Registry

from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.service import IServicePool
from adhocracy_core.resources.service import service_meta
from adhocracy_core.resources.document import IDocument


class ILogbookService(IServicePool):
    """The 'logbook' ServicePool."""


logbook_service_meta = service_meta._replace(
    iresource=ILogbookService,
    content_name='logbook',
    element_types=(IDocument, ),
)


def add_logbook_service(context: IPool, registry: Registry, options: dict):
    """Add `logbook` service to context."""
    creator = options.get('creator')
    registry.content.create(ILogbookService.__identifier__,
                            parent=context,
                            autoupdated=True,
                            creator=creator)


def includeme(config):
    """Add resource type to registry."""
Esempio n. 15
0
    element_types=(ICommentVersion,
                   ),
    item_type=ICommentVersion,
    use_autonaming=True,
    autonaming_prefix='comment_',
    permission_create='create_comment',
)


class ICommentsService(IServicePool):
    """The 'comments' ServicePool."""


comments_meta = service_meta._replace(
    iresource=ICommentsService,
    content_name='comments',
    element_types=(IComment,),
)


def add_commentsservice(context: IPool, registry: Registry, options: dict):
    """Add `comments` service to context."""
    registry.content.create(ICommentsService.__identifier__, parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(comments_meta, config)
    add_resource_type_to_registry(commentversion_meta, config)
    add_resource_type_to_registry(comment_meta, config)
Esempio n. 16
0
                   ),
    item_type=IPolarizationVersion,
    use_autonaming=True,
    autonaming_prefix='polarization_',
    permission_create='create_relation',
    is_implicit_addable=True
)


class IRelationsService(IServicePool):
    """The 'relations' ServicePool."""


relations_meta = service_meta._replace(
    iresource=IRelationsService,
    content_name='relations',
    element_types=(IRelation,),
)


def add_relationsservice(context: IPool,
                         registry: Registry,
                         options: dict):
    """Add `relations` service to context."""
    registry.content.create(IRelationsService.__identifier__,
                            parent=context)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(relations_meta, config)
Esempio n. 17
0
    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):
    """Add `badge` service to context."""
    registry.content.create(IBadgesService.__identifier__, parent=context,
                            registry=registry)


class IBadgeAssignment(ISimple):

    """A generic badge assignment."""
Esempio n. 18
0
def create_initial_content_for_principals(context: IPool, registry: Registry,
                                          options: dict):
    """Add users, groups and resets subobjects to context."""
    registry.content.create(IUsersService.__identifier__,
                            parent=context, registry=registry)
    registry.content.create(IGroupsService.__identifier__,
                            parent=context, registry=registry)
    registry.content.create(IPasswordResetsService.__identifier__,
                            parent=context, registry=registry)


principals_meta = service_meta._replace(
    iresource=IPrincipalsService,
    content_name='principals',
    element_types=(),  # we don't want the frontend to post resources here
    permission_create='create_service',
    extended_sheets=(adhocracy_core.sheets.badge.IHasBadgesPool,),
)._add(after_creation=(create_initial_content_for_principals,
                       add_badges_service))


class IUser(IPool):

    """User resource.

    This inherits from IPool in order to allow to use this resource as a
    namespace for user objects.

    """

    active = Attribute('Whether the user account has been activated (bool)')
Esempio n. 19
0
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):
    """Add `badge` service to context."""
    registry.content.create(IBadgesService.__identifier__, parent=context, registry=registry)


class IBadgeAssignment(ISimple):

    """A generic badge assignment."""


badge_assignment_meta = simple_meta._replace(
    iresource=IBadgeAssignment,
Esempio n. 20
0
        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(
    iresource=IAssetsService,
    content_name='assets',
    element_types=(IAsset,),
)


class IPoolWithAssets(IPool):

    """A pool with an auto-created asset service pool."""


deprecated('IPoolWithAssets', 'Backward compatible code, use process instead')


def add_assets_service(context: IPool, registry: Registry, options: dict):
    """Add `assets` service to context."""
    registry.content.create(IAssetsService.__identifier__, parent=context)
Esempio n. 21
0
        # 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,
    content_name='assets',
    element_types=(IAsset, ),
)


class IPoolWithAssets(IPool):
    """A pool with an auto-created asset service pool."""


deprecated('IPoolWithAssets', 'Backward compatible code, use process instead')


def add_assets_service(context: IPool, registry: Registry, options: dict):
    """Add `assets` service to context."""
    registry.content.create(IAssetsService.__identifier__,
                            parent=context,
Esempio n. 22
0
        .union(KeywordComparator.__members__)
        .union(KeywordSequenceComparator.__members__)
        .union(FieldSequenceComparator.__members__)
        .union(ReferenceComparator.__members__)
    )


def add_catalogs_system_and_adhocracy(context: ICatalogsService, registry: Registry, options: dict):
    """Add catalogs `system` and `adhocracy`."""
    context.add_catalog("system")
    context.add_catalog("adhocracy")


catalogs_service_meta = service_meta._replace(
    iresource=ICatalogsService,
    content_name="catalogs",
    content_class=CatalogsServiceAdhocracy,
    after_creation=[add_catalogs_system_and_adhocracy],
)


def includeme(config):
    """Register catalog utilities."""
    config.include("adhocracy_core.events")
    config.add_view_predicate("catalogable", catalog._CatalogablePredicate)
    config.add_directive("add_catalog_factory", catalog.add_catalog_factory)
    config.add_directive("add_indexview", catalog.add_indexview, action_wrap=False)
    config.registry.registerAdapter(catalog.deferred.BasicActionProcessor, (Interface,), IIndexingActionProcessor)
    add_resource_type_to_registry(catalogs_service_meta, config)
    config.scan("substanced.catalog")
    config.scan(".index")
    config.include(".adhocracy")
Esempio n. 23
0
                   ),
    item_type=ICommentVersion,
    use_autonaming=True,
    autonaming_prefix='comment_',
    permission_create='create_comment',
)


class ICommentsService(IServicePool):
    """The 'comments' ServicePool."""


comments_meta = service_meta._replace(
    iresource=ICommentsService,
    content_name='comments',
    element_types=(IComment,),
    extended_sheets=(adhocracy_core.sheets.anonymize.IAllowAddAnonymized,
                     )
)


def add_commentsservice(context: IPool, registry: Registry, options: dict):
    """Add `comments` service to context."""
    registry.content.create(ICommentsService.__identifier__,
                            parent=context,
                            autoupdated=True)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(comments_meta, config)
Esempio n. 24
0
    _comparators = set(FieldComparator.__members__) \
        .union(KeywordComparator.__members__) \
        .union(KeywordSequenceComparator.__members__) \
        .union(FieldSequenceComparator.__members__)


def add_catalogs_system_and_adhocracy(context: ICatalogsService,
                                      registry: Registry, options: dict):
    """Add catalogs 'system' and 'adhocracy'."""
    context.add_catalog('system')
    context.add_catalog('adhocracy')


catalogs_service_meta = service_meta._replace(
    iresource=ICatalogsService,
    content_name='catalogs',
    content_class=CatalogsServiceAdhocracy,
    after_creation=[add_catalogs_system_and_adhocracy])


def includeme(config):
    """Register catalog utilities."""
    config.include('adhocracy_core.events')
    config.add_view_predicate('catalogable', catalog._CatalogablePredicate)
    config.add_directive('add_catalog_factory', catalog.add_catalog_factory)
    config.add_directive('add_indexview',
                         catalog.add_indexview,
                         action_wrap=False)
    config.registry.registerAdapter(catalog.deferred.BasicActionProcessor,
                                    (Interface, ), IIndexingActionProcessor)
    add_resource_type_to_registry(catalogs_service_meta, config)
Esempio n. 25
0
    iresource=IActivity,
    permission_create='create_activity',
    autonaming_prefix='activity',
    basic_sheets=(adhocracy_core.sheets.metadata.IMetadata,
                  adhocracy_core.sheets.activity.IActivity,
                  ),
)


class IActivityService(IServicePool):
    """The 'activity' ServicePool."""


activity_service_meta = service_meta._replace(
    iresource=IActivityService,
    content_name='activity_stream',
    element_types=(IActivity,),
)


def add_activiy_service(context: IPool, registry: Registry, options: dict):
    """Add `activity` service to context."""
    registry.content.create(IActivityService.__identifier__,
                            parent=context,
                            autoupdated=True)


def includeme(config):
    """Add resource type to registry."""
    add_resource_type_to_registry(activity_meta, config)
    add_resource_type_to_registry(activity_service_meta, config)