Exemple #1
0
def make_forkable_itemversion(parent=None, follows=[]):
    from adhocracy_core.resources import ResourceFactory
    from adhocracy_core.sheets.versions import IForkableVersionable
    from adhocracy_core.resources.itemversion import itemversion_meta
    forkable_itemversion_metadata = itemversion_meta._replace(
        extended_sheets=(IForkableVersionable, ))
    appstructs = {IForkableVersionable.__identifier__: {'follows': follows}}
    return ResourceFactory(forkable_itemversion_metadata)(
        parent=parent, appstructs=appstructs)
Exemple #2
0
def make_forkable_itemversion(parent=None, follows=[]):
    from adhocracy_core.resources import ResourceFactory
    from adhocracy_core.sheets.versions import IForkableVersionable
    from adhocracy_core.resources.itemversion import itemversion_meta
    forkable_itemversion_metadata = itemversion_meta._replace(
        extended_sheets=(IForkableVersionable,)
    )
    appstructs = {IForkableVersionable.__identifier__: {'follows': follows}}
    return ResourceFactory(forkable_itemversion_metadata)(
        parent=parent, appstructs=appstructs)
    def test_autoupdate_with_referencing_items(self, config, context):
        # for more tests see adhocracy_core.resources.subscriber
        from adhocracy_core.sheets.document import IDocument
        from adhocracy_core.resources.itemversion import itemversion_meta
        from adhocracy_core.resources import add_resource_type_to_registry
        from adhocracy_core.sheets.versions import IVersionable
        from adhocracy_core.utils import get_sheet

        config.include("adhocracy_core.sheets.document")
        config.include("adhocracy_core.sheets.versions")
        metadata = itemversion_meta._replace(extended_sheets=(IDocument,))
        add_resource_type_to_registry(metadata, config)
        referenced_v0 = self.make_one(config, context)
        appstructs = {IDocument.__identifier__: {"elements": [referenced_v0]}}
        referenceing_v0 = self.make_one(config, context, appstructs=appstructs)
        config.registry.changelog.clear()
        referenced_v1 = self.make_one(config, context, follows=[referenced_v0])

        referencing_v0_versions = get_sheet(referenceing_v0, IVersionable).get()
        assert len(referencing_v0_versions["followed_by"]) == 1
    def test_autoupdate_with_referencing_items(self, config, context):
        # for more tests see adhocracy_core.resources.subscriber
        from adhocracy_core.sheets.document import IDocument
        from adhocracy_core.resources.itemversion import itemversion_meta
        from adhocracy_core.resources import add_resource_type_to_registry
        from adhocracy_core.sheets.versions import IVersionable
        from adhocracy_core.utils import get_sheet
        config.include('adhocracy_core.sheets.document')
        config.include('adhocracy_core.sheets.versions')
        metadata = itemversion_meta._replace(extended_sheets=(IDocument, ))
        add_resource_type_to_registry(metadata, config)
        referenced_v0 = self.make_one(config, context)
        appstructs = {IDocument.__identifier__: {'elements': [referenced_v0]}}
        referenceing_v0 = self.make_one(config, context, appstructs=appstructs)
        config.registry.changelog.clear()
        referenced_v1 = self.make_one(config, context, follows=[referenced_v0])

        referencing_v0_versions = get_sheet(referenceing_v0,
                                            IVersionable).get()
        assert len(referencing_v0_versions['followed_by']) == 1
    def test_autoupdate_with_referencing_versionable(self, config, registry,
                                                     item, other_item):
        # for more tests see adhocracy_core.resources.subscriber
        from pyramid.traversal import resource_path
        from adhocracy_core.sheets.document import IDocument
        from adhocracy_core.resources.itemversion import itemversion_meta
        from adhocracy_core.resources import add_resource_type_to_registry
        metadata = itemversion_meta._replace(extended_sheets=(IDocument,))
        add_resource_type_to_registry(metadata, config)
        referenced_v0 = self.make_one(registry, item)
        referenced_v0.v0 = 1
        appstructs = {IDocument.__identifier__: {'elements': [referenced_v0]}}
        referenceing_v0 = self.make_one(registry, other_item,
                                        appstructs=appstructs)
        referenceing_v0.vr0 = 1
        registry.changelog.clear()
        referenced_v1 = self.make_one(registry, item, follows=[referenced_v0])
        referenced_v1.v1 = 1

        referenceing_v0_path = resource_path(referenceing_v0)
        assert registry.changelog[referenceing_v0_path].followed_by
Exemple #6
0
    def test_autoupdate_with_referencing_versionable(self, config, registry,
                                                     item, other_item):
        # for more tests see adhocracy_core.resources.subscriber
        from pyramid.traversal import resource_path
        from adhocracy_core.sheets.document import IDocument
        from adhocracy_core.resources.itemversion import itemversion_meta
        from adhocracy_core.resources import add_resource_type_to_registry
        metadata = itemversion_meta._replace(extended_sheets=(IDocument, ))
        add_resource_type_to_registry(metadata, config)
        referenced_v0 = self.make_one(registry, item)
        referenced_v0.v0 = 1
        appstructs = {IDocument.__identifier__: {'elements': [referenced_v0]}}
        referenceing_v0 = self.make_one(registry,
                                        other_item,
                                        appstructs=appstructs)
        referenceing_v0.vr0 = 1
        registry.changelog.clear()
        referenced_v1 = self.make_one(registry, item, follows=[referenced_v0])
        referenced_v1.v1 = 1

        referenceing_v0_path = resource_path(referenceing_v0)
        assert registry.changelog[referenceing_v0_path].followed_by
    def test_autoupdate_with_referencing_versionable(self, config, registry,
                                                     item, other_item):
        # for more tests see adhocracy_core.resources.subscriber
        from adhocracy_core.sheets.document import IDocument
        from adhocracy_core.resources.itemversion import itemversion_meta
        from adhocracy_core.resources import add_resource_type_to_registry
        from adhocracy_core.sheets.versions import IVersionable
        from adhocracy_core.utils import get_sheet
        metadata = itemversion_meta._replace(extended_sheets=(IDocument,))
        add_resource_type_to_registry(metadata, config)
        referenced_v0 = self.make_one(registry, item)
        referenced_v0.v0 = 1
        appstructs = {IDocument.__identifier__: {'elements': [referenced_v0]}}
        referenceing_v0 = self.make_one(registry, other_item,
                                        appstructs=appstructs)
        referenceing_v0.vr0 = 1
        registry.changelog.clear()
        referenced_v1 = self.make_one(registry, item, follows=[referenced_v0])
        referenced_v1.v1 = 1

        referencing_v0_versions = get_sheet(referenceing_v0, IVersionable).get()
        assert len(referencing_v0_versions['followed_by']) == 1
from adhocracy_core.resources.itemversion import itemversion_meta
from adhocracy_core.resources.item import item_meta
from adhocracy_core.resources.comment import add_commentsservice
import adhocracy_core.sheets.comment
import adhocracy_core.sheets.document


class IParagraphVersion(IItemVersion):

    """Document paragraph (a leaf in the paragraph tree)."""


paragraphversion_meta = itemversion_meta._replace(
    content_name='ParagraphVersion',
    iresource=IParagraphVersion,
    extended_sheets=(adhocracy_core.sheets.document.IParagraph,
                     adhocracy_core.sheets.comment.ICommentable,
                     ),
    permission_create='edit_proposal',
)


class IParagraph(IItem):

    """Paragraph Versions Pool."""


paragraph_meta = item_meta._replace(
    content_name='Paragraph',
    iresource=IParagraph,
    basic_sheets=(adhocracy_core.sheets.tags.ITags,
                  adhocracy_core.sheets.versions.IVersions,
Exemple #9
0
from adhocracy_core.sheets.description import IDescription
from adhocracy_core.sheets.geo import IPoint
from adhocracy_core.sheets.rate import IRateable
from adhocracy_core.sheets.title import ITitle
from adhocracy_core.sheets.relation import IPolarizable


class IProposalVersion(IItemVersion):
    """Proposal version."""

proposal_version_meta = itemversion_meta._replace(
    content_name='ProposalVersion',
    iresource=IProposalVersion,
    extended_sheets=(IBadgeable,
                     ITitle,
                     IDescription,
                     ICommentable,
                     IRateable,
                     IPolarizable,
                     ),
    permission_create='edit_proposal',
)


class IProposal(IItem):
    """Proposal versions pool."""

proposal_meta = item_meta._replace(
    content_name='Proposal',
    iresource=IProposal,
    element_types=(IProposalVersion,),
    extended_sheets=(IBadgeable,
Exemple #10
0
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.itemversion import itemversion_meta
from adhocracy_core.resources.item import item_meta
from adhocracy_core.resources.service import service_meta

from adhocracy_core.sheets.rate import IRate


class IRateVersion(IItemVersion):
    """Rate version."""


rateversion_meta = itemversion_meta._replace(
    iresource=IRateVersion,
    extended_sheets=(IRate,),
    permission_create='edit_rate',
)


class IRate(IItem):
    """Rate versions pool."""


rate_meta = item_meta._replace(
    iresource=IRate,
    element_types=(IRateVersion,),
    item_type=IRateVersion,
    use_autonaming=True,
    autonaming_prefix='rate_',
    permission_create='create_rate',
Exemple #11
0
from adhocracy_core.interfaces import IPool
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.itemversion import itemversion_meta
from adhocracy_core.resources.item import item_meta
from adhocracy_core.resources.service import service_meta
from adhocracy_core.sheets.rate import IRate
from adhocracy_core.sheets.anonymize import IAllowAddAnonymized


class IRateVersion(IItemVersion):
    """Rate version."""


rateversion_meta = itemversion_meta._replace(
    iresource=IRateVersion,
    extended_sheets=(IRate, ),
    permission_create='edit_rate',
)


class IRate(IItem):
    """Rate versions pool."""


rate_meta = item_meta._replace(
    iresource=IRate,
    element_types=(IRateVersion, ),
    item_type=IRateVersion,
    use_autonaming=True,
    autonaming_prefix='rate_',
    permission_create='create_rate',
Exemple #12
0
class IRelation(IItem):
    """Relation versions pool."""


class IRelationVersion(IItemVersion):
    """Relation version."""


class IPolarizationVersion(IRelationVersion):
    """A polarization in a discussion."""


polarizationversion_meta = itemversion_meta._replace(
    content_name='PolarizationVersion',
    iresource=IPolarizationVersion,
    extended_sheets=(adhocracy_core.sheets.relation.IPolarization,
                     ),
    permission_create='edit_relation',
)


class IPolarization(IRelation):
    """Polarization versions pool."""


polarization_meta = item_meta._replace(
    content_name='Polarization',
    iresource=IPolarization,
    element_types=(IPolarizationVersion,
                   ),
    item_type=IPolarizationVersion,
Exemple #13
0
import adhocracy_core.sheets.document
import adhocracy_core.sheets.image
import adhocracy_core.sheets.workflow


class IDocumentVersion(IItemVersion):

    """Versionable item with Document propertysheet."""


document_version_meta = itemversion_meta._replace(
    iresource=IDocumentVersion,
    extended_sheets=(adhocracy_core.sheets.document.IDocument,
                     adhocracy_core.sheets.comment.ICommentable,
                     adhocracy_core.sheets.badge.IBadgeable,
                     adhocracy_core.sheets.rate.IRateable,
                     adhocracy_core.sheets.image.IImageReference,
                     adhocracy_core.sheets.title.ITitle,
                     ),
    permission_create='edit_proposal',
)


class IDocument(IItem):

    """All versions of a Proposal."""


document_meta = item_meta._replace(
    iresource=IDocument,
    element_types=(ITag,
Exemple #14
0
import adhocracy_core.sheets.image
import adhocracy_core.sheets.workflow

_ = TranslationStringFactory('adhocracy')


class IDocumentVersion(IItemVersion):
    """Versionable item with Document propertysheet."""


document_version_meta = itemversion_meta._replace(
    iresource=IDocumentVersion,
    extended_sheets=(
        adhocracy_core.sheets.document.IDocument,
        adhocracy_core.sheets.comment.ICommentable,
        adhocracy_core.sheets.badge.IBadgeable,
        adhocracy_core.sheets.rate.IRateable,
        adhocracy_core.sheets.image.IImageReference,
        adhocracy_core.sheets.title.ITitle,
    ),
    permission_create='edit',
)


class IDocument(IItem):
    """All versions of a Proposal."""


document_meta = item_meta._replace(
    content_name=_('Document'),
    iresource=IDocument,
    element_types=(
Exemple #15
0
from adhocracy_core.sheets.badge import IBadgeable
from adhocracy_core.sheets.comment import ICommentable
from adhocracy_core.sheets.logbook import IHasLogbookPool

import adhocracy_core.sheets.title
import adhocracy_mercator.sheets.mercator


class IOrganizationInfoVersion(IItemVersion):
    """One of the mercator commentable subresources."""


organization_info_version_meta = itemversion_meta._replace(
    content_name='OrganizationInfoVersion',
    iresource=IOrganizationInfoVersion,
    extended_sheets=(
        adhocracy_mercator.sheets.mercator.IOrganizationInfo,
        ICommentable),
    permission_create='edit_mercator_proposal',
)


class IOrganizationInfo(IItem):
    """One of the mercator commentable subresources version pool."""


organization_info_meta = item_meta._replace(
    content_name='OrganizationInfo',
    iresource=IOrganizationInfo,
    element_types=(IOrganizationInfoVersion,
                   ),
    item_type=IOrganizationInfoVersion,
Exemple #16
0
import adhocracy_core.sheets.comment
import adhocracy_core.sheets.rate
import adhocracy_core.sheets.relation


class ICommentVersion(IItemVersion):
    """A comment in a discussion."""


commentversion_meta = itemversion_meta._replace(
    content_name='CommentVersion',
    iresource=ICommentVersion,
    extended_sheets=(
        adhocracy_core.sheets.comment.IComment,
        adhocracy_core.sheets.comment.ICommentable,
        adhocracy_core.sheets.rate.IRateable,
        adhocracy_core.sheets.relation.ICanPolarize,
    ),
    permission_create='edit_comment',
)


class IComment(IItem):
    """Comment versions pool."""


comment_meta = item_meta._replace(
    content_name='Comment',
    iresource=IComment,
    element_types=(ICommentVersion, ),
Exemple #17
0
from adhocracy_core.resources.itemversion import itemversion_meta
from adhocracy_core.resources.item import item_meta
from adhocracy_core.resources.comment import add_commentsservice
import adhocracy_core.sheets.comment
import adhocracy_core.sheets.document


class IParagraphVersion(IItemVersion):
    """Document paragraph (a leaf in the paragraph tree)."""


paragraphversion_meta = itemversion_meta._replace(
    content_name='ParagraphVersion',
    iresource=IParagraphVersion,
    extended_sheets=(
        adhocracy_core.sheets.document.IParagraph,
        adhocracy_core.sheets.comment.ICommentable,
    ),
    permission_create='edit',
)


class IParagraph(IItem):
    """Paragraph Versions Pool."""


paragraph_meta = item_meta._replace(
    content_name='Paragraph',
    iresource=IParagraph,
    element_types=(IParagraphVersion, ),
    item_type=IParagraphVersion,
Exemple #18
0
import adhocracy_core.sheets.relation
import adhocracy_core.sheets.anonymize


_ = TranslationStringFactory('adhocracy')


class ICommentVersion(IItemVersion):
    """A comment in a discussion."""


commentversion_meta = itemversion_meta._replace(
    content_name='CommentVersion',
    iresource=ICommentVersion,
    extended_sheets=(adhocracy_core.sheets.comment.IComment,
                     adhocracy_core.sheets.comment.ICommentable,
                     adhocracy_core.sheets.rate.IRateable,
                     adhocracy_core.sheets.relation.ICanPolarize,
                     ),
    permission_create='edit',
)


class IComment(IItem):
    """Comment versions pool."""


comment_meta = item_meta._replace(
    content_name=_('Comment'),
    iresource=IComment,
    element_types=(ICommentVersion,
                   ),
Exemple #19
0
from adhocracy_core.resources import add_resource_type_to_registry
from adhocracy_core.resources.itemversion import itemversion_meta
from adhocracy_core.resources.item import item_meta
from adhocracy_core.resources import process
import adhocracy_meinberlin.sheets.bplan


class IProposalVersion(IItemVersion):

    """BPlan proposal version."""


proposal_version_meta = itemversion_meta._replace(
    content_name='ProposalVersion',
    iresource=IProposalVersion,
    extended_sheets=(adhocracy_meinberlin.sheets.bplan.IProposal,
                     ),
    permission_create='edit_proposal',
)


class IProposal(IItem):

    """BPlan proposal versions pool."""


proposal_meta = item_meta._replace(
    content_name='Proposal',
    iresource=IProposal,
    element_types=(IProposalVersion,),
    item_type=IProposalVersion,
Exemple #20
0
class IRelation(IItem):
    """Relation versions pool."""


class IRelationVersion(IItemVersion):
    """Relation version."""


class IPolarizationVersion(IRelationVersion):
    """A polarization in a discussion."""


polarizationversion_meta = itemversion_meta._replace(
    content_name='PolarizationVersion',
    iresource=IPolarizationVersion,
    extended_sheets=(adhocracy_core.sheets.relation.IPolarization, ),
    permission_create='edit_relation',
)


class IPolarization(IRelation):
    """Polarization versions pool."""


polarization_meta = item_meta._replace(content_name='Polarization',
                                       iresource=IPolarization,
                                       element_types=(IPolarizationVersion, ),
                                       item_type=IPolarizationVersion,
                                       use_autonaming=True,
                                       autonaming_prefix='polarization_',
                                       permission_create='create_relation',
Exemple #21
0
from adhocracy_core.sheets.badge import IBadgeable
from adhocracy_core.sheets.comment import ICommentable
from adhocracy_core.sheets.logbook import IHasLogbookPool

import adhocracy_core.sheets.title
import adhocracy_mercator.sheets.mercator


class IOrganizationInfoVersion(IItemVersion):
    """One of the mercator commentable subresources."""


organization_info_version_meta = itemversion_meta._replace(
    content_name='OrganizationInfoVersion',
    iresource=IOrganizationInfoVersion,
    extended_sheets=(adhocracy_mercator.sheets.mercator.IOrganizationInfo,
                     ICommentable),
    permission_create='edit_mercator_proposal',
)


class IOrganizationInfo(IItem):
    """One of the mercator commentable subresources version pool."""


organization_info_meta = item_meta._replace(
    content_name='OrganizationInfo',
    iresource=IOrganizationInfo,
    element_types=(IOrganizationInfoVersion, ),
    item_type=IOrganizationInfoVersion,
    permission_create='edit_mercator_proposal',
Exemple #22
0
from adhocracy_core.sheets.image import IImageReference
from adhocracy_core.sheets.rate import IRateable
from adhocracy_core.sheets.relation import IPolarizable
from adhocracy_core.sheets.title import ITitle


class IProposalVersion(IItemVersion):
    """Proposal version."""

proposal_version_meta = itemversion_meta._replace(
    content_name='ProposalVersion',
    iresource=IProposalVersion,
    extended_sheets=(IBadgeable,
                     ITitle,
                     IDescription,
                     ICommentable,
                     IRateable,
                     IPolarizable,
                     IImageReference,
                     ),
    permission_create='edit',
)


class IProposal(IItem):
    """Proposal versions pool."""

proposal_meta = item_meta._replace(
    content_name='Proposal',
    iresource=IProposal,
    element_types=(IProposalVersion,),