class PaymentCreated(Event): identifier = "payment_created" name = _("Payment Created") order = Variable(_("Order"), type=Model("shuup.Order")) customer_email = Variable(_("Customer Email"), type=Email) customer_phone = Variable(_("Customer Phone"), type=Phone) language = Variable(_("Language"), type=Language) payment_status = Variable(_("Order Payment Status"), type=Enum(PaymentStatus)) payment = Variable(_("Payment"), type=Model("shuup.Payment"))
class ShipmentDeleted(Event): identifier = "shipment_deleted" name = _("Shipment Deleted") order = Variable(_("Order"), type=Model("shuup.Order")) customer_email = Variable(_("Customer Email"), type=Email) customer_phone = Variable(_("Customer Phone"), type=Phone) language = Variable(_("Language"), type=Language) shipment = Variable(_("Shipment"), type=Model("shuup.Shipment")) shipping_status = Variable(_("Order Shipping Status"), type=Enum(ShippingStatus))
class RefundCreated(Event): identifier = "refund_created" name = _("Refund Created") order = Variable(_("Order"), type=Model("shuup.Order"), attributes=ORDER_ATTRIBUTES) customer_email = Variable(_("Customer Email"), type=Email) customer_phone = Variable(_("Customer Phone"), type=Phone) language = Variable(_("Language"), type=Language) payment_status = Variable(_("Order Payment Status"), type=Enum(PaymentStatus))
class RefundCreated(Event): identifier = "refund_created" order = Variable("Order", type=Model("shuup.Order")) customer_email = Variable("Customer Email", type=Email) customer_phone = Variable("Customer Phone", type=Phone) language = Variable("Language", type=Language) payment_status = Variable( "Order Payment Status", type=Enum(PaymentStatus), help_text=_("Possible values: {0}").format(", ".join( ["{0}".format(choice) for choice in PaymentStatus])))
class ShipmentDeleted(Event): identifier = "shipment_deleted" order = Variable("Order", type=Model("shuup.Order")) customer_email = Variable("Customer Email", type=Email) customer_phone = Variable("Customer Phone", type=Phone) language = Variable("Language", type=Language) shipment = Variable("Shipment", type=Model("shuup.Shipment")) shipping_status = Variable( "Order Shipping Status", type=Enum(ShippingStatus), help_text=_("Possible values: {0}").format(", ".join( ["{0}".format(choice) for choice in ShippingStatus])))
class AddNotification(Action): identifier = "add_notification" recipient_type = Binding( "Recipient Type", type=Enum(RecipientType), constant_use=ConstantUse.CONSTANT_ONLY, default=RecipientType.ADMINS ) recipient = Binding( "Recipient", type=Model(settings.AUTH_USER_MODEL), constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=False ) priority = Binding("Priority", type=Enum(Priority), constant_use=ConstantUse.CONSTANT_ONLY, default=Priority.NORMAL) message = TemplatedBinding("Message", type=Text, constant_use=ConstantUse.CONSTANT_ONLY, required=True) message_identifier = Binding("Message Identifier", Text, constant_use=ConstantUse.CONSTANT_ONLY, required=False) url = Binding("URL", type=URL, constant_use=ConstantUse.VARIABLE_OR_CONSTANT) def execute(self, context): """ :type context: shuup.notify.script.Context """ values = self.get_values(context) if values["recipient_type"] == RecipientType.SPECIFIC_USER: if not values["recipient"]: context.log(logging.WARN, "Misconfigured AddNotification -- no recipient for specific user") return Notification.objects.create( recipient_type=values["recipient_type"], recipient=values["recipient"], priority=values["priority"], identifier=values.get("message_identifier"), message=values["message"][:140], url=values["url"], shop=context.shop )
def test_enum_type(): enum_type = Enum(StepConditionOperator) assert enum_type.unserialize(StepConditionOperator.ANY) == StepConditionOperator.ANY assert enum_type.unserialize("any") == StepConditionOperator.ANY assert not enum_type.unserialize("herp")
def test_enum_type(): enum_type = Enum(StepConditionOperator) assert enum_type.unserialize( StepConditionOperator.ANY) == StepConditionOperator.ANY assert enum_type.unserialize("any") == StepConditionOperator.ANY assert not enum_type.unserialize("herp")