def user_notified_shipped_order_20150530(user, user_subscription_last_order_20150530, user_address, source_1): _order = create_order(user.id, user_subscription_last_order_20150530.id) _order = move_order(_order, None, USER_NOTIFIED_SHIPPED_STATE) yield _order
def mutate_and_get_payload(cls, root, info, identity, **inp): user = get_user_by_sub(identity.id.subject) create_order(user.id, user.primary_user_subscription_id) try: send_template_email( user.email, 'welcome', { 'name': user.first_name or '', 'deeplink': config.SERVER_DEEPLINK_URL + '/subscriptions/', } ) except Exception as e: logging.exception('Error when sending welcome email: %s', e) return StartSearch()
def timed_out_order(user, user_subscription_proposed, user_address): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, PROPOSED_TO_WINE_EXPERT_STATE) _order.state_changed_at = datetime.datetime.utcnow() - datetime.timedelta( days=3) db.session.commit() yield _order
def run(self, order_id): logging.info('running CompleteAction order_id: %s', order_id) order = get_order(order_id) utcnow = datetime.utcnow() if order.user.primary_user_subscription.last_order_searched_at is None: scheduled_for = utcnow else: scheduled_for = order.user.primary_user_subscription.last_order_searched_at scheduled_for += relativedelta(months=1) if scheduled_for < utcnow: scheduled_for = utcnow create_order(order.user.id, order.user.primary_user_subscription.id, scheduled_for=scheduled_for) return None, COMPLETED_STATE
def order_20150515(user, user_subscription, user_address, source_1): _order = create_order( user.id, user_subscription.id, scheduled_for=datetime.datetime(2015, 5, 15, 13, 13, 13, 13), ) yield _order
def support_notified_order(user, user_subscription_proposed, user_address, source_1, order_shipping_method_1): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, SUPPORT_NOTIFIED_STATE) _order.shipping_method_id = order_shipping_method_1.id db.session.commit() yield _order
def accepted_order(user, user_subscription_proposed, user_address, source_1, master_product_1, theme_1): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, OFFER_ACCEPTED_STATE) _populate_product_offers(_order, source_1, master_product_1, theme_1) yield _order
def proposed_to_wine_expert_order(user, user_subscription_proposed, user_address, source_1, master_product_1, theme_1): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, PROPOSED_TO_WINE_EXPERT_STATE) _populate_product_offers(_order, source_1, master_product_1, theme_1) yield _order
def exception_order_20150515(user, user_subscription, user_address, source_1): _order = create_order( user.id, user_subscription.id, ) _order = move_order(_order, None, EXCEPTION_STATE) _order.state_changed_at = datetime.datetime(2015, 5, 15, 13, 13, 13, 13) _order.scheduled_for = None db.session.commit() yield _order
def update_subscription(user_id, subscription, subscription_dct): logging.info('update_subscription: user_id: %s, subscription_id: %s', user_id, subscription.id) def set_value(model, attr, value): if value: setattr(model, attr, value) set_value(subscription, 'type', subscription_dct.get('type')) set_value(subscription, 'bottle_qty', subscription_dct.get('bottle_qty')) set_value(subscription, 'budget', subscription_dct.get('budget')) set_value(subscription, 'state', subscription_dct.get('state')) db.session.commit() if subscription_dct.get('apply_for_current_order'): order = get_current_order(user_id) if order.is_active: db.session.delete(order) db.session.commit() create_order(user_id, subscription.id)
def completed_orders(user, user_subscription_proposed, user_address, source_1, master_product_1, theme_1): orders = [] for i in range(4): _order = create_order(user.id, user_subscription_proposed.id) _order.shipping_name = _order.shipping_name + str(i) _order = move_order(_order, None, COMPLETED_STATE) _order.created_at = datetime.datetime(2000 + i, 10, 10, 12, 2, 38, 784862) _order.state_changed_at = datetime.datetime(2010 + i, 10, 10, 12, 2, 38, 784862) _populate_product_offers(_order, source_1, master_product_1, theme_1) orders.append(_order) yield orders
def proposed_to_user_order(user, user_subscription_proposed, user_address): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, PROPOSED_TO_USER_STATE) yield _order
def placed_order(user, user_subscription_proposed, user_address): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, ORDER_PLACED_STATE) yield _order
def order_proposed(user, user_subscription_proposed, user_address): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, PROPOSED_TO_WINE_EXPERT_STATE) yield _order
def order2(user2, user_subscription2, user_address2): _order = create_order(user2.id, user_subscription2.id) yield _order
def create_order(cls, user_id, subscription_id): order = create_order(user_id=user_id, subscription_id=subscription_id) return cls(order.id)
def old_completed_order(user, user_subscription_proposed, user_address, source_1, master_product_1): _order = create_order(user.id, user_subscription_proposed.id) _order = move_order(_order, None, COMPLETED_STATE) yield _order
def order(user, user_subscription, user_address): _order = create_order(user.id, user_subscription.id) yield _order