Example #1
0
def payment_complete(order_id):
    ## this needs to be rewritten to take into account stripe and crypto payments
    token = request.args.get('token')
    payer_id = request.args.get('PayerID')

    order = Order().fetch_order(order_id)

    if not order:
        return abort(404)

    if order.payment.transaction_id != token:
        return abort(404)

    if order.status != 'Paid':
        capture_paypal_order(token)
        check_order = get_paypal_order(token)

        if check_order['payment_status'] == 'COMPLETED':
            order.status = 'Paid'
            deliver_goods = Product().deliver_product(order.product_id,
                                                      order_id, order.quantity,
                                                      order.customer.email)
            leave_feedback.apply_async(args=[
                order.customer.email,
                User().fetch_user_supply_uuid(order.user).username, order_id,
                order.order_hash
            ],
                                       countdown=120)

        if not order.customer.email:
            order.customer.email = check_order['buyer_email']

        order.update()

    return redirect(url_for('order.track_order', order_id=order_id))
    def test_shopify_uninstall_app(self):
        shop = Shop.query.filter_by(id=testing_constants.SHOPIFY_SHOP_ID).first()
        shop.owner = self.shop_owner_user
        product = Product(platform_product_id=testing_constants.NEW_PRODUCT_PLATFORM_ID,
                          name=testing_constants.NEW_PRODUCT_NAME,
                          shop_id=testing_constants.SHOPIFY_SHOP_ID)
        order = Order(user_id=1, shop_id=testing_constants.SHOPIFY_SHOP_ID)
        order.products.append(product)
        db.session.add(order)
        db.session.commit()
        order.ship()
        order.set_notifications()
        # emails are sent automatically anyway, just check it happened
        self.assertEquals(len(self.outbox), 1)
        data = json.dumps({})
        sha256 = base64.b64encode(hmac.new(Config.SHOPIFY_APP_SECRET, msg=data, digestmod=hashlib.sha256).digest())
        response_actual = self.desktop_client.post(url_for('api.platform_shopify_app_uninstalled'),
                                                   data=data,
                                                   headers={
                                                       'X-Shopify-Hmac-SHA256': sha256,
                                                       'X-Shopify-Shop-Domain': testing_constants.SHOPIFY_SHOP_DOMAIN})
        self.assertEquals(response_actual.status_code, 200)
        shop = Shop.query.filter_by(id=testing_constants.SHOPIFY_SHOP_ID).first()
        shop_customer = shop.owner.customer[0]
        self.assertFalse(shop_customer.active)
        self.assertEqual(len(shop_customer.subscription), 0)

        # make sure tasks are revoked
        db.session.delete(order)
        db.session.delete(product)
        db.session.commit()
Example #3
0
 def create(self, validated_data):
     order = Order()
     setattr(order, 'tel_number', validated_data['tel_number'])
     setattr(order, 'address', validated_data['address'])
     order.save()
     for product in validated_data['order_products']:
         order_products = ProductOrder()
         setattr(order_products, 'product', product['product'])
         setattr(order_products, 'quantity', product['quantity'])
         setattr(order_products, 'order', order)
         order_products.save()
     return validated_data
Example #4
0
 def test_YOTPO_import_reviews_verified_review(self):
     self.refresh_db()
     p = Product(shop_id=self.yotpo_shop.id,
                 name=testing_constants.NEW_PRODUCT_NAME)
     user_legacy = UserLegacy(name=testing_constants.ORDER_USER_NAME,
                              email=testing_constants.ORDER_USER_EMAIL)
     o = Order(user_legacy=user_legacy,
               shop=self.yotpo_shop,
               status=Constants.ORDER_STATUS_NOTIFIED)
     o.products.append(p)
     db.session.add(p)
     db.session.add(o)
     db.session.commit()
     before_count = len(Review.query.all())
     self.yotpo_importer.import_reviews(
         testing_constants.YOTPO_REVIEWS_CSV_FILEPATH)
     after_count = len(Review.query.all())
     r = Review.query.filter_by(user_legacy=user_legacy).first()
     self.assertEqual(after_count, before_count + 2)
     self.assertNotEqual(r, None)
     self.assertEqual(r.body, testing_constants.NEW_REVIEW_BODY)
     self.assertEqual(r.product, p)
     self.assertEqual(r.star_rating, 4)
     self.assertEqual(
         r.created_ts,
         parse(
             testing_constants.YOTPO_REVIEW_TIMESTAMP).replace(tzinfo=None))
     self.assertEqual(r.youtube_video, None)
     self.assertTrue(r.verified_review)
 def test_shopify_fulfill_order(self):
     product = Product(name=testing_constants.NEW_PRODUCT_NAME)
     order = Order(
         platform_order_id=testing_constants.NEW_ORDER_PLATFORM_ID,
         shop_id=testing_constants.SHOPIFY_SHOP_ID,
         user=self.reviewer_user)
     order.products.append(product)
     db.session.add(order)
     db.session.commit()
     data = json.dumps({
         'order_id': testing_constants.NEW_ORDER_PLATFORM_ID,
         'tracking_number': testing_constants.ORDER_TRACKING_NUMBER,
         'created_at': testing_constants.ORDER_SHIPPED_AT
     })
     sha256 = base64.b64encode(
         hmac.new(Config.SHOPIFY_APP_SECRET,
                  msg=data,
                  digestmod=hashlib.sha256).digest())
     response_actual = self.desktop_client.post(
         url_for('api.platform_shopify_fulfill_order'),
         data=data,
         headers={
             'X-Shopify-Hmac-SHA256': sha256,
             'X-Shopify-Shop-Domain': testing_constants.SHOPIFY_SHOP_DOMAIN
         })
     self.assertEquals(response_actual.status_code, 200)
     order = Order.query.filter_by(
         platform_order_id=testing_constants.NEW_ORDER_PLATFORM_ID,
         shop_id=testing_constants.SHOPIFY_SHOP_ID).first()
     self.assertEquals(order.status, Constants.ORDER_STATUS_NOTIFIED)
     db.session.delete(order)
     db.session.commit()
Example #6
0
def submit_feedback(username, order_id, order_hash):

    form = FeedbackForm()

    if not form.validate_on_submit():
        flash(list(form.errors.values())[0])
        return redirect(request.referrer)

    order = Order().fetch_order(order_id)

    if (not order) or (order.order_hash != order_hash):
        return abort(404)

    feedback = Feedback().fetch_feedback(order.id)

    if not feedback:
        Feedback().add(request.form, order.id, order.user)
        flash(['Feedback Submitted'])

        return redirect(url_for('shop.shop', username=User().fetch_user_supply_uuid(order.user).username))

    Feedback().update_feedback(order.id, request.form)

    flash(['Feedback successfully updated.'])
    return redirect(url_for('shop.shop', username=User().fetch_user_supply_uuid(order.user).username))
Example #7
0
def leave_feedback(username, order_id, order_hash):
    order = Order().fetch_order(order_id)
    
    if (not order) or (order.order_hash != order_hash):
        return abort(404)
    
    return render_template('/shop/leave-feedback.html', user=User().fetch_user_supply_username(username), form=FeedbackForm(), order_id=order_id, order_hash=order_hash)
 def test_shopify_create_order_already_exists(self):
     order = Order(
         platform_order_id=testing_constants.NEW_ORDER_PLATFORM_ID)
     db.session.add(order)
     db.session.commit()
     data = json.dumps({
         'id':
         testing_constants.NEW_ORDER_PLATFORM_ID,
         'customer': {
             'email': testing_constants.ORDER_USER_EMAIL
         },
         'line_items': [{
             'product_id':
             testing_constants.NEW_PRODUCT_PLATFORM_ID
         }]
     })
     sha256 = base64.b64encode(
         hmac.new(Config.SHOPIFY_APP_SECRET,
                  msg=data,
                  digestmod=hashlib.sha256).digest())
     response_actual = self.desktop_client.post(
         url_for('api.platform_shopify_create_order'),
         data=data,
         headers={
             'X-Shopify-Hmac-SHA256': sha256,
             'X-Shopify-Shop-Domain': testing_constants.SHOPIFY_SHOP_DOMAIN
         })
     self.assertEquals(response_actual.status_code, 401)
     self.assertTrue('Order already exists' in response_actual.data)
     order = Order.query.filter_by(
         platform_order_id=testing_constants.NEW_ORDER_PLATFORM_ID).first()
     db.session.delete(order)
     db.session.commit()
Example #9
0
def view_order(order_id):
    order = Order().fetch_order(order_id)

    if order.user != current_user.get_id():
        return abort(404)

    return render_template('/dashboard/view-order.html', order=order)
Example #10
0
def track_order(order_id) -> render_template:
    fetch_order = Order().fetch_order(order_id)

    if not fetch_order:
        return abort(404)

    return render_template(
        '/shop/order.html',
        order=fetch_order,
        flashed_message=get_flashed_messages(),
        user=User().fetch_user_supply_uuid(fetch_order.user),
        product=Product().fetch_product(fetch_order.product_id,
                                        fetch_order.user))
Example #11
0
    def mutate(self, info, **kwargs):
        # print(kwargs)
        id = kwargs.get('id', None)
        type = kwargs.get('type', None)
        quantity = kwargs.get('quantity', None)

        if id:
            order = Order.objects.get(pk=id)
            if type:
                order.type = type
            if quantity:
                order.quantity = quantity
            order.save()
        else:
            user = info.context.user
            order = Order(
                type=type,
                quantity=quantity,
                user=user,
            )
            order.save()
        OnNewOrder.update("order")
        return OrderMutation(order=order)
Example #12
0
def download_attachment(order_id, attachment_id):
    order = Order().fetch_order(order_id)

    if (not order) or (order.status != 'Completed'):
        return abort(404)

    attachment = Attachment().fetch_attachment(attachment_id)
    fetch_file = download_file(attachment.attachment_filename,
                               environ.get('AWS_ATTACHMENTS'))

    return Response(
        fetch_file['file'],
        mimetype='text/plain',
        headers={
            "Content-Disposition":
            f"attachment;filename={attachment.original_attachment_filename}"
        })
Example #13
0
def create_order() -> redirect:
    form = PurchaseProduct()

    if not form.validate_on_submit():
        flash(list(form.errors.values())[0])
        return redirect(request.referrer)

    if request.form.get('coupon_code') != '':
        if not Coupon().check_coupon(request.form):
            flash(['Coupon is invalid. Please try again'])
            return redirect(request.referrer)

    new_order = Order().add(request.form, request.headers.get('User-Agent'))

    if False in new_order:
        flash([new_order[1]])
        return redirect(request.referrer)

    if new_order['payment_method'] == 'paypal':
        return redirect(new_order['payment_address'])

    return redirect(url_for('order.track_order', order_id=new_order))
Example #14
0
    def test_shopify_uninstall_app(self):
        shop = Shop.query.filter_by(
            id=testing_constants.SHOPIFY_SHOP_ID).first()
        shop.owner = self.shop_owner_user
        product = Product(
            platform_product_id=testing_constants.NEW_PRODUCT_PLATFORM_ID,
            name=testing_constants.NEW_PRODUCT_NAME,
            shop_id=testing_constants.SHOPIFY_SHOP_ID)
        order = Order(user_id=1, shop_id=testing_constants.SHOPIFY_SHOP_ID)
        order.products.append(product)
        db.session.add(order)
        db.session.commit()
        order.ship()
        order.set_notifications()
        # emails are sent automatically anyway, just check it happened
        self.assertEquals(len(self.outbox), 1)
        data = json.dumps({})
        sha256 = base64.b64encode(
            hmac.new(Config.SHOPIFY_APP_SECRET,
                     msg=data,
                     digestmod=hashlib.sha256).digest())
        response_actual = self.desktop_client.post(
            url_for('api.platform_shopify_app_uninstalled'),
            data=data,
            headers={
                'X-Shopify-Hmac-SHA256': sha256,
                'X-Shopify-Shop-Domain': testing_constants.SHOPIFY_SHOP_DOMAIN
            })
        self.assertEquals(response_actual.status_code, 200)
        shop = Shop.query.filter_by(
            id=testing_constants.SHOPIFY_SHOP_ID).first()
        shop_customer = shop.owner.customer[0]
        self.assertFalse(shop_customer.active)
        self.assertEqual(len(shop_customer.subscription), 0)

        # make sure tasks are revoked
        db.session.delete(order)
        db.session.delete(product)
        db.session.commit()
Example #15
0
def checkout(request):
    if request.POST:
        ptype = request.POST['submit']
        ordid = request.POST['oid']
        order = Order.objects.get(order_id=ordid)
        order.status = Order.ORDER_STATE_PLACED
        order.payment_hash_id = 1
        order.instructions = request.POST['instruct']
        order.save()
        if ptype == "Pay Later":
            order.payment_mode_online = False
            order.save()
            return render(request, 'webapp/orderplaced.html', {})
        else:
            payment = Payment()
            payment.amount = request.POST['total_price']
            payment.save()
            order.payment_hash_id = payment.hash
            order.save()
            return render(request, 'webapp/online_pay.html', {})
    else:
        cart = request.COOKIES['cart'].split(",")
        cart = dict(Counter(cart))
        items = []
        totalprice = 0
        order = Order()

        # order.save()
        print(order.order_id)
        order.tax = 0.05 * totalprice
        order.user = Customer.objects.get(user_id=request.user.id)
        order.datetime = datetime.now()
        # order.offer = Offer.objects.get(offer_id=1)
        for x, y in cart.items():
            it = FoodItem.objects.get(food_item_id=int(x))
            print(it.name)
            item_rest = FoodRestaurant.objects.get(
                food_item_id=it.food_item_id)
            order.restaurant = Restaurant.objects.get(
                restaurant_id=item_rest.restaurant.restaurant_id)
            yu = Offer.objects.get(offer_id=Restaurant.objects.get(
                restaurant_id=item_rest.restaurant.restaurant_id).offer_id)
            print(yu.discount)
            order.offer_id = yu.offer_id
        order.payment_hash_id = 1
        order.save()
        for x, y in cart.items():
            item = []
            it = FoodItem.objects.get(food_item_id=int(x))
            print(it.name)
            item_rest = FoodRestaurant.objects.get(
                food_item_id=it.food_item_id)

            print(order.order_id)
            order_detail = OrderDetail()
            order_detail.food_item_id = it.food_item_id
            order_detail.order_id = order.order_id
            order_detail.quantity = int(y)
            order_detail.save()
            item.append(it.name)
            item.append(y)
            totalprice += item_rest.cost * y
            item.append(item_rest.cost * y)
            items.append(item)
        order.tax = int(0.05 * totalprice)
        withouttax = totalprice
        totalprice += order.tax
        totalprice -= int(yu.discount)
        if totalprice < order.tax:
            totalprice = order.tax
        order.save()

        context = {
            "items": items,
            "yu": yu,
            "totalprice": totalprice,
            "withouttax": withouttax,
            "order": order,
            "oid": order.order_id
        }
        return render(request, 'webapp/order.html', context)
Example #16
0
    def test_fetch_new_and_updated_orders_already_exist(self):
        # setup with existing product 0,1,2
        user_shop_owner = User(email=testing_constants.NEW_USER_EMAIL)
        Customer(user=user_shop_owner)
        shop = Shop(name=testing_constants.MAGENTO_SHOP_NAME)
        shop.owner = user_shop_owner
        product0 = Product(platform_product_id=testing_constants.MAGENTO_PRODUCT_0_PLATFORM_PRODUCT_ID,
                           name=testing_constants.MAGENTO_PRODUCT_0_NAME,
                           active=True,
                           short_description=testing_constants.MAGENTO_PRODUCT_0_DESCRIPTION)

        product1 = Product(platform_product_id=testing_constants.MAGENTO_PRODUCT_1_PLATFORM_PRODUCT_ID,
                           name=testing_constants.MAGENTO_PRODUCT_1_NAME,
                           active=True,
                           short_description=testing_constants.MAGENTO_PRODUCT_1_DESCRIPTION)

        product2 = Product(platform_product_id=testing_constants.MAGENTO_PRODUCT_2_PLATFORM_PRODUCT_ID,
                           name=testing_constants.MAGENTO_PRODUCT_2_NAME,
                           active=False,
                           short_description=testing_constants.MAGENTO_PRODUCT_2_DESCRIPTION)

        order0_user_legacy = UserLegacy(email=testing_constants.MAGENTO_ORDER_0_EMAIL,
                                        name=testing_constants.MAGENTO_ORDER_0_NAME)
        order0 = Order(platform_order_id=testing_constants.MAGENTO_ORDER_0_PLATFORM_ORDER_ID,
                       status=Constants.ORDER_STATUS_PURCHASED,
                       purchase_timestamp=testing_constants.MAGENTO_ORDER_0_CREATED,
                       user_legacy=order0_user_legacy)
        order0.products.append(product0)

        order1_user_legacy = UserLegacy(email=testing_constants.MAGENTO_ORDER_1_EMAIL,
                                        name=testing_constants.MAGENTO_ORDER_1_NAME)
        order1 = Order(platform_order_id=testing_constants.MAGENTO_ORDER_1_PLATFORM_ORDER_ID,
                       status=Constants.ORDER_STATUS_NOTIFIED,
                       purchase_timestamp=testing_constants.MAGENTO_ORDER_1_CREATED,
                       shipment_timestamp=testing_constants.MAGENTO_ORDER_1_SHIPPED,
                       user_legacy=order1_user_legacy)
        order1.products.append(product0)
        order1.products.append(product1)

        order2_user_legacy = UserLegacy(email=testing_constants.MAGENTO_ORDER_2_EMAIL,
                                        name=testing_constants.MAGENTO_ORDER_2_NAME)
        order2 = Order(platform_order_id=testing_constants.MAGENTO_ORDER_2_PLATFORM_ORDER_ID,
                       status=Constants.ORDER_STATUS_PURCHASED,
                       purchase_timestamp=testing_constants.MAGENTO_ORDER_2_CREATED,
                       user_legacy=order2_user_legacy)

        shop.products.append(product0)
        shop.products.append(product1)
        shop.products.append(product2)
        shop.orders.append(order0)
        shop.orders.append(order1)
        shop.orders.append(order2)
        db.session.add(shop)
        db.session.commit()

        # test
        api = magento_api.API()
        current_orders = Order.query.filter_by(shop_id=shop.id).all()
        new_and_updated = api.fetch_new_and_updated_orders(current_orders, shop)
        self.assertEquals(len(new_and_updated), 0)

        # tear down
        user = User.query.filter_by(email=testing_constants.NEW_USER_EMAIL).first()
        customer = user.customer[0]
        shop = Shop.query.filter_by(name=testing_constants.MAGENTO_SHOP_NAME).first()
        orders = Order.query.all()

        for product in shop.products:
            db.session.delete(product)
        db.session.delete(user)
        db.session.delete(customer)
        db.session.delete(shop)
        db.session.delete(shop)
        for order in orders:
            for review_request in order.review_requests:
                db.session.delete(review_request)
            db.session.delete(order)
        db.session.commit()
Example #17
0
    def test_fetch_new_and_updated_orders_already_exist_but_not_shipped(self):
        # setup with existing product 0,1,2
        user_shop_owner = User(email=testing_constants.NEW_USER_EMAIL)
        Customer(user=user_shop_owner)
        shop = Shop(name=testing_constants.MAGENTO_SHOP_NAME)
        shop.owner = user_shop_owner
        product0 = Product(platform_product_id=testing_constants.MAGENTO_PRODUCT_0_PLATFORM_PRODUCT_ID,
                           name=testing_constants.MAGENTO_PRODUCT_0_NAME,
                           active=True,
                           short_description=testing_constants.MAGENTO_PRODUCT_0_DESCRIPTION)

        product1 = Product(platform_product_id=testing_constants.MAGENTO_PRODUCT_1_PLATFORM_PRODUCT_ID,
                           name=testing_constants.MAGENTO_PRODUCT_1_NAME,
                           active=True,
                           short_description=testing_constants.MAGENTO_PRODUCT_1_DESCRIPTION)

        product2 = Product(platform_product_id=testing_constants.MAGENTO_PRODUCT_2_PLATFORM_PRODUCT_ID,
                           name=testing_constants.MAGENTO_PRODUCT_2_NAME,
                           active=False,
                           short_description=testing_constants.MAGENTO_PRODUCT_2_DESCRIPTION)

        order0_user_legacy = UserLegacy(email=testing_constants.MAGENTO_ORDER_0_EMAIL,
                                        name=testing_constants.MAGENTO_ORDER_0_NAME)
        order0 = Order(platform_order_id=testing_constants.MAGENTO_ORDER_0_PLATFORM_ORDER_ID,
                       status=Constants.ORDER_STATUS_PURCHASED,
                       purchase_timestamp=testing_constants.MAGENTO_ORDER_0_CREATED,
                       user_legacy=order0_user_legacy)
        order0.products.append(product0)

        order1_user_legacy = UserLegacy(email=testing_constants.MAGENTO_ORDER_1_EMAIL,
                                        name=testing_constants.MAGENTO_ORDER_1_NAME)
        order1 = Order(platform_order_id=testing_constants.MAGENTO_ORDER_1_PLATFORM_ORDER_ID,
                       status=Constants.ORDER_STATUS_PURCHASED,
                       purchase_timestamp=testing_constants.MAGENTO_ORDER_1_CREATED,
                       user_legacy=order1_user_legacy)
        order1.products.append(product0)
        order1.products.append(product1)

        order2_user_legacy = UserLegacy(email=testing_constants.MAGENTO_ORDER_2_EMAIL,
                                        name=testing_constants.MAGENTO_ORDER_2_NAME)
        order2 = Order(platform_order_id=testing_constants.MAGENTO_ORDER_2_PLATFORM_ORDER_ID,
                       status=Constants.ORDER_STATUS_PURCHASED,
                       purchase_timestamp=testing_constants.MAGENTO_ORDER_2_CREATED,
                       user_legacy=order2_user_legacy)

        shop.products.append(product0)
        shop.products.append(product1)
        shop.products.append(product2)
        shop.orders.append(order0)
        shop.orders.append(order1)
        shop.orders.append(order2)
        db.session.add(shop)
        db.session.commit()

        # test
        api = magento_api.API()
        current_orders = Order.query.filter_by(shop_id=shop.id).all()
        new_and_updated = api.fetch_new_and_updated_orders(current_orders, shop)
        self.assertEquals(len(new_and_updated), 1)
        db.session.add_all(new_and_updated)
        db.session.commit()

        self.assertEquals(len(self.outbox), 1)
        self.assertEquals(len(self.outbox[0].send_to), 1)
        self.assertEquals(self.outbox[0].send_to.pop(), testing_constants.MAGENTO_ORDER_1_EMAIL)
        self.assertEquals(self.outbox[0].subject,
                          Constants.DEFAULT_REVIEW_SUBJECT % (testing_constants.MAGENTO_ORDER_1_NAME.split()[0],
                                                              testing_constants.MAGENTO_SHOP_NAME))
        self.assertTrue(testing_constants.MAGENTO_ORDER_1_NAME.split()[0] in self.outbox[0].body)
        self.assertTrue(testing_constants.MAGENTO_PRODUCT_0_NAME in self.outbox[0].body)
        self.assertTrue(testing_constants.MAGENTO_PRODUCT_1_NAME in self.outbox[0].body)
        self.assertTrue(testing_constants.MAGENTO_SHOP_NAME in self.outbox[0].body)

        self.assertEquals(new_and_updated[0].platform_order_id, testing_constants.MAGENTO_ORDER_1_PLATFORM_ORDER_ID)
        self.assertEquals(new_and_updated[0].status, Constants.ORDER_STATUS_NOTIFIED)
        self.assertEquals(new_and_updated[0].purchase_timestamp,
                          datetime.datetime.strptime(testing_constants.MAGENTO_ORDER_1_CREATED, '%Y-%m-%d %H:%M:%S'))
        self.assertEquals(new_and_updated[0].shipment_timestamp,
                          datetime.datetime.strptime(testing_constants.MAGENTO_ORDER_1_SHIPPED, '%Y-%m-%d %H:%M:%S'))
        self.assertEquals(len(new_and_updated[0].products), 2)
        self.assertIsNotNone(new_and_updated[0].products[0])
        self.assertEquals(new_and_updated[0].products[0].platform_product_id,
                          testing_constants.MAGENTO_PRODUCT_0_PLATFORM_PRODUCT_ID)
        self.assertIsNotNone(new_and_updated[0].products[1])
        self.assertEquals(new_and_updated[0].products[1].platform_product_id,
                          testing_constants.MAGENTO_PRODUCT_1_PLATFORM_PRODUCT_ID)
        self.assertEquals(len(new_and_updated[0].tasks), 2)
        self.assertEquals(new_and_updated[0].tasks[0].method, 'notify_for_review')
        self.assertEquals(str(new_and_updated[0].tasks[0].eta), '2015-12-19 12:00:00')
        self.assertEquals(new_and_updated[0].tasks[1].method, 'send_email')
        self.assertEquals(str(new_and_updated[0].tasks[1].eta), '2015-12-19 12:00:00')
        self.assertIsNotNone(new_and_updated[0].user_legacy)
        self.assertEquals(new_and_updated[0].user_legacy.email, testing_constants.MAGENTO_ORDER_1_EMAIL)
        self.assertEquals(new_and_updated[0].user_legacy.name, testing_constants.MAGENTO_ORDER_1_NAME)

        # tear down
        user = User.query.filter_by(email=testing_constants.NEW_USER_EMAIL).first()
        customer = user.customer[0]
        shop = Shop.query.filter_by(name=testing_constants.MAGENTO_SHOP_NAME).first()
        orders = Order.query.all()

        for product in shop.products:
            db.session.delete(product)
        db.session.delete(user)
        db.session.delete(customer)
        db.session.delete(shop)
        db.session.delete(shop)
        for order in orders:
            for review_request in order.review_requests:
                db.session.delete(review_request)
            db.session.delete(order)
        db.session.commit()
Example #18
0
def orders() -> render_template:
    return render_template('/dashboard/orders.html',
                           orders=Order().fetch_orders(),
                           user=User().fetch_user_logged_in())
Example #19
0
def reviews() -> render_template:
    return render_template('/dashboard/reviews.html',
                           orders=Order().fetch_orders())