コード例 #1
0
class SharedStockExtender(ExtenderBase):
    layer = ITicketShopExtensionLayer
    fields = [
        XSharedStockBooleanField(
            name='item_display_stock',
            schemata='Shop',
            widget=BooleanField._properties['widget'](label=_(
                u'label_item_display_stock', u'Display item stock'), ),
        ),
        XSharedStockFloatField(
            name='item_available',
            schemata='Shop',
            widget=FloatField._properties['widget'](label=_(
                u'label_item_available', u'Item stock available'), ),
        ),
        XSharedStockFloatField(
            name='item_overbook',
            schemata='Shop',
            widget=FloatField._properties['widget'](label=_(
                u'label_item_overbook', u'Item stock overbook'), ),
        ),
        XFloatField(
            name='item_stock_warning_threshold',
            schemata='Shop',
            widget=FloatField._properties['widget'](label=_(
                u'label_stock_warning_threshold',
                default=u'Item stock warning threshold.'), ),
        ),
    ]
コード例 #2
0
def ticket_wf_changed(obj, event):
    if ITicketOccurrence.providedBy(obj):
        # Don't change state for subobjects of TicketOccurrence and avoid
        # infinite loops. We land in here after changing the state for
        # TicketOccurrence objects.
        return
    wft = getToolByName(obj, 'portal_workflow')
    changed = []
    failed = []
    for sub in obj.contentValues():
        if not ITicketOccurrence.providedBy(sub):
            # WTF? continue.
            continue
        try:
            wft.doActionFor(sub, event.action)
            changed.append(sub)
        except WorkflowException:
            failed.append(sub)

    state = wft.getInfoFor(obj, 'review_state')
    if changed:
        msg = _(
            'msg_changed_ticketoccurrence_workflow',
            default=u"Set the workflow to ${state} for these "
                    u"Ticket Occurrences: ${items}.",
            mapping={
                'state': state,
                'items': ', '.join([it.id for it in changed])
            }

        )
        IStatusMessage(getRequest()).addStatusMessage(msg, 'info')

    if failed:
        msg = _(
            'msg_failed_ticketoccurrence_workflow',
            default=u"Failed to set the workflow to ${state} for these "
                    u"Ticket Occurrences: ${items}.",
            mapping={
                'state': state,
                'items': ', '.join([
                    '{} ({})'.format(it.id, wft.getInfoFor(it, 'review_state'))
                    for it in failed])
            }

        )
        IStatusMessage(getRequest()).addStatusMessage(msg, 'warning')
コード例 #3
0
def ticket_wf_changed(obj, event):
    if ITicketOccurrence.providedBy(obj):
        # Don't change state for subobjects of TicketOccurrence and avoid
        # infinite loops. We land in here after changing the state for
        # TicketOccurrence objects.
        return
    wft = getToolByName(obj, 'portal_workflow')
    changed = []
    failed = []
    for sub in obj.contentValues():
        if not ITicketOccurrence.providedBy(sub):
            # WTF? continue.
            continue
        try:
            wft.doActionFor(sub, event.action)
            changed.append(sub)
        except WorkflowException:
            failed.append(sub)

    state = wft.getInfoFor(obj, 'review_state')
    if changed:
        msg = _('msg_changed_ticketoccurrence_workflow',
                default=u"Set the workflow to ${state} for these "
                u"Ticket Occurrences: ${items}.",
                mapping={
                    'state': state,
                    'items': ', '.join([it.id for it in changed])
                })
        IStatusMessage(getRequest()).addStatusMessage(msg, 'info')

    if failed:
        msg = _('msg_failed_ticketoccurrence_workflow',
                default=u"Failed to set the workflow to ${state} for these "
                u"Ticket Occurrences: ${items}.",
                mapping={
                    'state':
                    state,
                    'items':
                    ', '.join([
                        '{} ({})'.format(it.id,
                                         wft.getInfoFor(it, 'review_state'))
                        for it in failed
                    ])
                })
        IStatusMessage(getRequest()).addStatusMessage(msg, 'warning')
コード例 #4
0
class SharedBuyablePeriodExtender(ExtenderBase):
    layer = ITicketShopExtensionLayer

    fields = [
        XSharedBuyablePeriodDateTimeField(
            name='buyable_effective',
            schemata='Shop',
            widget=atapi.CalendarWidget(label=_(
                u'label_buyable_effective_date',
                default=u'Buyable effective date'), ),
        ),
        XSharedBuyablePeriodDateTimeField(
            name='buyable_expires',
            schemata='Shop',
            widget=atapi.CalendarWidget(label=_(
                u'label_buyable_expiration_date',
                default=u'Buyable expiration date'), ),
        ),
    ]
コード例 #5
0
class BuyableEventExtender(ExtenderBase):
    layer = ITicketShopExtensionLayer
    fields = [
        XFloatField(
            name='item_cart_count_limit',
            schemata='Shop',
            widget=FloatField._properties['widget'](label=_(
                u'label_item_cart_count_limit',
                default=u'Max count of this item in cart'), ),
        ),
    ]
コード例 #6
0
class IBuyableEventBehavior(model.Schema, IDXBuyableEvent):

    model.fieldset(
        'shop',
        label=u"Shop",
        fields=[
            'item_cart_count_limit',
        ]
    )

    item_cart_count_limit = schema.Float(
        title=_(u'label_item_cart_count_limit',
                default=u'Max count of this item in cart'),
        required=False,
        defaultFactory=default_item_cart_count_limit
    )