예제 #1
0
def load_db():
    tackle = Vendor(name='Tackle.io')
    db.session.add(tackle)
    db.session.flush()

    ami_listing = Product(title="Tackle Amazon Machine Image",
                          listing_type="ami",
                          price=1000,
                          vendor_id=tackle.id)
    govcloud_listing = Product(title="Tackle for GovCloud",
                               listing_type="saas",
                               price=5000,
                               vendor_id=tackle.id)

    db.session.add(ami_listing)
    db.session.add(govcloud_listing)
    db.session.flush()

    orders = []
    orders.append(
        Order(full_name="Linus Torvalds",
              order_date=datetime.now() - relativedelta(months=1),
              quantity=1,
              product_id=ami_listing.id))
    orders.append(
        Order(full_name="Elon Musk",
              order_date=datetime.now() - relativedelta(months=1),
              quantity=2,
              product_id=ami_listing.id))
    orders.append(
        Order(full_name="Alan Turing",
              order_date=datetime.now() - relativedelta(months=4),
              quantity=4,
              product_id=ami_listing.id))
    orders.append(
        Order(full_name="Katherine Johnson",
              order_date=datetime.now() - relativedelta(months=4),
              quantity=1,
              product_id=ami_listing.id))
    orders.append(
        Order(full_name="Margaret Hamilton",
              order_date=datetime.now() - relativedelta(months=3),
              quantity=1,
              product_id=govcloud_listing.id))
    orders.append(
        Order(full_name="Grace Hopper",
              order_date=datetime.now() - relativedelta(months=6),
              quantity=3,
              product_id=govcloud_listing.id))

    for order in orders:
        db.session.add(order)

    db.session.commit()
예제 #2
0
def handle_signup():
    input_data = request.json
    if 'vendor_name' in input_data and 'email' in input_data and 'password' in input_data and 'phone' in input_data:
        new_vendor = Vendor(input_data['vendor_name'], input_data['email'],
                            input_data['password'], input_data['phone'])
        db.session.add(new_vendor)
        try:
            db.session.commit()
            return jsonify(new_vendor.serialize()), 201
        except Exception as error:
            db.session.rollback()
            return jsonify({"msg": error.args}), 500
    else:
        return jsonify({"msg": "check your keys..."}), 400
예제 #3
0
def add_vendor(session, id, name, delivery_estimate, delivery_minimum):
    #, address, phone
    # try:     
    vendor = session.query(Vendor).filter_by(id=id).first()
    if vendor == None:
        vendor = Vendor(
            id=str(id), 
            name=str(name), 
            delivery_estimate=str(delivery_estimate),
            delivery_minimum=str(delivery_minimum)
            # address=address, 
            # phone=phone
            )
        session.add(vendor)
        output = "New Vendor"
    else:
        output = "Vendor Already Exists"
    session.commit()
    print output
예제 #4
0
def add_vendor():
    """ Renders Vendor Add page

    :return: add_vendor.html
    """
    if request.method == "GET":
        return render_template("add_vendor.html")
    company = request.form["company"]
    part = request.form["part"]
    price = float(request.form["price"])
    address_line_1 = request.form["address_line_1"]
    address_line_2 = request.form["address_line_2"]
    city = request.form["city"]
    state = request.form["state"]
    zip_code = float(request.form["zip_code"])
    new_vendor = Vendor(company, part, price, address_line_1, address_line_2, city, state, zip_code)
    db.session.add(new_vendor)
    db.session.commit()
    return redirect("/view_vendors")
예제 #5
0
파일: pranzo.py 프로젝트: bboru21/pranzo
def insert_vendor(site_permit, business_name):
    if settings.USE_DATABASE:
        # include models import here for now so we don't create if user doesn't want
        from models import Vendor

        engine = create_engine(settings.DATABASES['ENGINE'])

        if engine.dialect.has_table(engine, 'vendor'):
            Session = sessionmaker(bind=engine)
            session = Session()

            insert = {"site_permit": site_permit, "name": business_name}

            vendor = session.query(Vendor).filter_by(
                site_permit=site_permit).first()
            if not vendor:
                vendor = Vendor(**insert)
                session.add(vendor)

            session.commit()
예제 #6
0
def seed_db():
    db.session.add(
        Vendor(
            name='YCombinator',
            image_path=
            'https://cdn.freebiesupply.com/logos/thumbs/2x/y-combinator-logo.png',
            menu=[{
                'category_id':
                1,
                'category_name':
                'drinks',
                'items': [{
                    'item_id': 100001,
                    'item_name': 'San Pellegrino Sparkling Mineral Water',
                    'price': 0.0,
                    'image_path': 'https://i.imgur.com/PhL9pDa.png',
                    'ingredients': ['carbonated mineral water'],
                    'sold_out': False,
                }, {
                    'item_id':
                    100002,
                    'item_name':
                    'Red Bull',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/toam81D.png',
                    'ingredients': [
                        'carbonated water', 'citric acid', 'taurine',
                        'sodium bicarbonate', 'glucuronolactone', 'caffeine',
                        'B vitamins', 'sucrose', 'glucose'
                    ],
                    'sold_out':
                    False,
                }, {
                    'item_id':
                    100003,
                    'item_name':
                    'Coca-Cola',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/fAUnPag.png',
                    'ingredients': [
                        'carbonated water', 'high-fructose corn syrup',
                        'caffeine', 'phosphoric acid', 'caramel color',
                        'natural flavorings'
                    ],
                    'sold_out':
                    False,
                }, {
                    'item_id':
                    100004,
                    'item_name':
                    'Diet Coke',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/QenwOaz.png',
                    'ingredients': [
                        'carbonated water', 'aspartame', 'caffeine',
                        'phosphoric acid', 'caramel color',
                        'natural flavorings', 'potassium benzonate'
                    ],
                    'sold_out':
                    False,
                }, {
                    'item_id':
                    100005,
                    'item_name':
                    'Lemon La Croix',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/z3szJoY.png',
                    'ingredients': ['carbonated water', 'natural essence'],
                    'sold_out':
                    False,
                }, {
                    'item_id':
                    100006,
                    'item_name':
                    'Lime La Croix',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/MsJLZbX.png',
                    'ingredients': ['carbonated water', 'natural essence'],
                    'sold_out':
                    False,
                }]
            }, {
                'category_name':
                'snacks',
                'items': [{
                    'item_id': 200001,
                    'item_name': 'Apple',
                    'price': 0.0,
                    'image_path': 'https://i.imgur.com/CGPNqar.png',
                    'ingredients': ['apple'],
                    'sold_out': False,
                }, {
                    'item_id': 200002,
                    'item_name': 'Tangerine',
                    'price': 0.0,
                    'image_path': 'https://i.imgur.com/SBoPfji.png',
                    'ingredients': ['tangerine'],
                    'sold_out': False,
                }, {
                    'item_id':
                    200003,
                    'item_name':
                    'Philippine Brand Dried Mango',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/mcYK0ux.png',
                    'ingredients':
                    ['mangoes', 'sugar', 'sodium metabisulfite'],
                    'sold_out':
                    False,
                }, {
                    'item_id':
                    200004,
                    'item_name':
                    'Cookie',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/GyqlOPI.png',
                    'ingredients': [
                        'butter', 'sugar', 'egg', 'flour', 'vanilla extract',
                        'baking soda', 'chocolate chips'
                    ],
                    'sold_out':
                    False,
                }, {
                    'item_id':
                    200005,
                    'item_name':
                    'Poke',
                    'price':
                    0.0,
                    'image_path':
                    'https://i.imgur.com/eGtI9pF.png',
                    'ingredients': [
                        'rice', 'tuna', 'edamame beans', 'green onions',
                        'soy sauce'
                    ],
                    'sold_out':
                    True,
                }]
            }, {
                'category_name':
                'soup',
                'items': [{
                    'item_id':
                    300001,
                    'item_name':
                    'tomato soup',
                    'price':
                    4.99,
                    'image_path':
                    'https://i.imgur.com/ubjMT8N.png',
                    'ingredients': ['tomato', 'olive oil', 'flour', 'onion'],
                    'sold_out':
                    True,
                }, {
                    'item_id':
                    300002,
                    'item_name':
                    'french onion soup',
                    'price':
                    4.99,
                    'image_path':
                    'https://i.imgur.com/MXilBQ7.png',
                    'ingredients':
                    ['onion', 'olive oil', 'mozzarella cheese', 'garlic'],
                    'sold_out':
                    True,
                }, {
                    'item_id':
                    300003,
                    'item_name':
                    'clam chowder',
                    'price':
                    5.99,
                    'image_path':
                    'https://i.imgur.com/0r26qkn.png',
                    'ingredients': [
                        'clams', 'onion', 'celery', 'potatoes', 'carrots',
                        'flour'
                    ],
                    'sold_out':
                    True,
                }]
            }]))
    db.session.commit()
    db.session.add(
        Order(vendor_id=1,
              order={
                  'table_number':
                  5,
                  'items': [{
                      'item_id': 1001,
                      'item_name': 'tomato soup'
                  }, {
                      'item_id': 1001,
                      'item_name': 'tomato soup'
                  }, {
                      'item_id': 1002,
                      'item_name': 'french onion soup'
                  }, {
                      'item_id': 2001,
                      'item_name': 'garden salad'
                  }]
              }))
    db.session.add(
        Order(vendor_id=1,
              order={
                  'table_number': 2,
                  'special_instructions': None,
                  'user_id': 1,
                  'items': [{
                      'item_id': 2001,
                      'item_name': 'garden salad'
                  }]
              }))
    db.session.commit()
    r = db.session.query(Vendor).first()
    return jsonify(r.to_json())
예제 #7
0
파일: views.py 프로젝트: parul1931/mvp
def register(request):
    posted_data = {}
    #get the current page url request.build_absolute_uri()
    if request.method == "POST":

        posted_data = request.POST
        form = RegisterForm(request.POST, request=request)
        if form.is_valid():
            first_name = request.POST['first_name']
            last_name = request.POST['last_name']
            emailid = request.POST['emailid']
            password = request.POST['password']

            encrypted_password = handler.encrypt(password)

            if 'vendor' in request.POST:
                account_type = AccountType.objects.get(type="vendor")
            else:
                account_type = AccountType.objects.get(type="user")

            detail = Account(first_name=first_name,
                             last_name=last_name,
                             emailid=emailid,
                             password=encrypted_password,
                             account_id=account_type.id)
            detail.save()
            if account_type.type == "vendor":
                vendor_detail = Vendor(user_id=detail.id,
                                       vendor=request.POST['vendor'])
                vendor_detail.save()

                # admin_detail = UserDetail(request).get_admin()
                # admin_email = admin_detail.emailid
                # recipients = [admin_email]

                # too = ", ".join(recipients)
                # link = "https://"+request.META['HTTP_HOST']
                # subject, from_email, to = 'Request for Approval of Vendor Account', '*****@*****.**', too

                # html_content =render_to_string('account_activation.html', {'link':link}) # ...
                # text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.

                # create the email, and attach the HTML version as well.
                # msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
                # msg.attach_alternative(html_content, "text/html")

                #msg.send()

                # fromaddr = "*****@*****.**"
                # password = "******"

                # link = "https://"+request.META['HTTP_HOST']

                # admin_detail = UserDetail(request).get_admin()
                # admin_email = admin_detail.emailid

                # msg = MIMEMultipart()
                # msg['From'] = fromaddr

                # recipients = [admin_email]
                # msg['To'] = ", ".join(recipients)

                # msg['Subject'] = "Request for Approval of Label Account"

                # content_html = render_to_string('account_activation.html', {'link':link})

                # test = MIMEText(content_html, 'html')
                # msg.attach(test)

                # server = smtplib.SMTP('smtp.gmail.com', 465)
                # server.starttls()
                # server.login(fromaddr, password)
                # text = msg.as_string()

                # server.sendmail(fromaddr, recipients, text)
                # server.quit()
                messages.add_message(
                    request, messages.SUCCESS,
                    'Registered Successfully. Please check your mail for approval of your account from admin.'
                )
            return redirect("/")

            #return HttpResponse("Registered Successfully. Please check your mail to activate your account.")
    else:
        form = RegisterForm(request=request)

    return render(request, "register.html", {
        'form': form,
        'posted_data': posted_data
    })
예제 #8
0
                 lastName="__admin__",
                 active=True)
    admin.hash_password("carlos2533")
    group = Group.query.filter_by(name="Admin").first()
    group.users.append(admin)

    event = createEvent(name="Dash Maracay",
                        date=date(2018, 5, 24),
                        location="Maracay",
                        duff_value=0.012,
                        active=True)
    db.session.add(event)
    db.session.add(admin)
    db.session.commit()
    vendors = list(
        map(lambda n: Vendor(name=n, events=[event], user=admin), [
            "Guarapita El Gran Varón", "BurgerManía", "Woufles", "Cocotento",
            "Chiringuitos", "Cerveza Viking Sur", "Pixie Liquors",
            "Restaurante Viejo Puente", "Be Nuts", "Chocolate Digatti"
        ]))
    for v in vendors:
        db.session.add(v)

    foundations = list(
        map(
            lambda n: Vendor(
                name=n, isFoundation=True, user=admin, events=[event]),
            ["Operacion Sonrisa", "Fundameste"]))
    for f in foundations:
        db.session.add(f)