예제 #1
0
파일: views.py 프로젝트: frnwtr/crowdcafe
def VendorSave(request):
	new_vendor = Vendor(
			owner = request.user,

			title = request.POST['vendor_title'],
			description = request.POST['vendor_description'],
			image_url = request.POST['vendor_image_url'],
			website_url = request.POST['vendor_website_url'],
			address = request.POST['vendor_address']
			)
	new_vendor.save()
	return redirect('rewards-home')
예제 #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 manage_upload_addmodel(request):
	data = yield from request.post()
	vendor = data['vd_add']
	model = data['md_add']
	select = data['adde']
	vendor_db = yield from Vendor.findAll('vendor_name = ?', vendor)
	vid = vendor_db[0]['vendor_id']
	md_count = yield from DM.findAll(where='vendor_id=? and model_name=?', args=[vid,model])

	# Add model
	if select=='1':
		if len(md_count)==1:
			return web.StreamResponse(status=999)
		else:
			model_new = DM(vendor_id=vid,model_name=model)
			yield from model_new.save()
			return 'Success'

	#Delete model
	else:
		if len(md_count)==0:
			return web.StreamResponse(status=997)
		else:
			fw_count = yield from Firmware.findAll(where='fw_vendor_name=? and fw_model_name=?',args=[vendor,model])
			if len(fw_count)>0:
				return web.StreamResponse(status=998)
			else:
				model_del = yield from DM.find(md_count[0].model_id)
				yield from model_del.remove()
				return 'Success'
예제 #4
0
    def create(self,request):
        serializer = VendorCreateSerializer(data=request.data)
        if serializer.is_valid():
            vendor = Vendor(name = serializer.validated_data.get('name'),
                            service_type=serializer.validated_data.get('service_type'),
                            address = serializer.validated_data.get('address'),
                            contact_no_1 = serializer.validated_data.get('contact_no_1'),
                            contact_no_2=serializer.validated_data.get('contact_no_2'),
                            description = serializer.validated_data.get('description'),
                            created_by =serializer.validated_data.get('created_by'),
                            created_on=serializer.validated_data.get('created_on'),
                            )

            vendor.put()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
예제 #5
0
파일: event.py 프로젝트: tchaikov/beanfs
 def post(self):
     # TODO: sanity test
     group = self.request.get('group')
     vendor = self.request.get('vendor')
     event = Event(group = Group.get_by_id(long(group)),
                   vendor = Vendor.get_by_id(long(vendor)),
                   advocate = users.get_current_user())
     
     event.put()
     self.redirect('/u/mine/profile')
예제 #6
0
파일: purchase.py 프로젝트: tchaikov/beanfs
 def get(self, event_id):
   event = Event.get_by_id(long(event_id))
   if event is None:
     # TODO: should bring user to a "event not found, do you want to init an event?"
     self.error(404)
     return
   vendors = list(Vendor.all())
   self.generate('order.html',
                 {'vendors':vendors,
                  'event':event,
                  'default_vendor':vendors.index(event.vendor)})
예제 #7
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()
예제 #8
0
 def update(self,request,ID):
     vendor= Vendor.get_by_id(int(ID))
     serializer = VendorUpdateSerializer(data=request.data)
     if serializer.is_valid():
         vendor.name=serializer.validated_data.get('name')
         vendor.service_type = serializer.validated_data.get('service_type')
         vendor.address = serializer.validated_data.get('address')
         vendor.contact_no_1 = serializer.validated_data.get('contact_no_1')
         vendor.contact_no_2 = serializer.validated_data.get('contact_no_2')
         vendor.put()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
예제 #9
0
 def post(self):
     user = users.get_current_user()
     isVendor = False
     
     if self.request.get("entity_key"):
         memento_user_key = ndb.Key(urlsafe=self.request.get("entity_key"))
         memento_user = memento_user_key.get()
         memento_user.user_name = user.nickname()
         isVendor = False
         if 'isVendor' in self.request.POST:
             isVendor = True
         memento_user.isVendor = isVendor
         memento_user.put()
         if memento_user.isVendor:
             self.redirect('/VendorHub')
         else:
             self.redirect('/HRHub')
     else:
         if 'isVendor' in self.request.POST:
             isVendor = True
         new_memento_user = MementoUser(parent = MEMENTO_USER_KEY,
                                     user_name = user.nickname(), 
                                     isVendor = isVendor,
                                     user_data = None)
         new_memento_user.put()
         if new_memento_user.isVendor:
             new_Vendor = Vendor(parent = new_memento_user.key, company_name=self.request.get("company"), inventory=[])
             new_Vendor.put()
             new_memento_user.user_data = new_Vendor.key
             new_memento_user.put()
             self.redirect('/VendorHub')
         else:
             new_HR = HRUser(parent = new_memento_user.key, company_name=self.request.get("company"), mementos=[])
             new_HR.put()
             new_memento_user.user_data = new_HR.key
             new_memento_user.put()
             self.redirect('/HRHub')
예제 #10
0
파일: user.py 프로젝트: tchaikov/beanfs
 def get(self, username):
   if username == 'mine':
     user = User.get_current_user()
   else:
     user = get1_by_property(User, 'name', username)
   
   if user:
     balances = self.get_balances(user)
     self.generate('user_profile.html',
                   {'user':user,
                    'balances':balances,
                    'groups':Group.all(),
                    'vendors':Vendor.all()})    
   else:
     self.redirect('/oops/invalid_user')
예제 #11
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
예제 #12
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")
예제 #13
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()
예제 #14
0
    def get(self):
        user = users.get_current_user()


        
        memento_user_query = ndb.gql("SELECT * from MementoUser WHERE user_name = :1", user.nickname())
        curr_memento_user = memento_user_query.get()
        curr_memento_user_key = curr_memento_user.key
        
        greeting = ('Welcome to HR Page, %s! (<a href="%s">sign out</a>)' %
                    (user.nickname(), users.create_logout_url('/')))
        logout_url = users.create_logout_url('/')
        template = jinja_env.get_template("templates/hrhub.html")
        all_mementos = Memento.query(ancestor=curr_memento_user_key)
        all_vendors = Vendor.query(ancestor=MEMENTO_USER_KEY)
        all_events = Event.query(ancestor=curr_memento_user_key)
        sample_employee = ndb.gql("SELECT * FROM Employee").get()
        model_fields = sample_employee.to_dict()
        jsonStr = json.dumps({"foo":"bar"})
        print(jsonStr)
        jsonDic = json.loads(jsonStr)
        print(jsonDic["foo"])
        self.response.write(template.render({"user":user, "logout_url": logout_url, "all_mementos": all_mementos, "all_events":all_events, "all_vendors":all_vendors, "model_fields":model_fields}))
        self.response.out.write(greeting)
예제 #15
0
 def retrieve(self,request,ID):
     queryset =Vendor.get_by_id(int(ID))
     serializer = VendorUpdateSerializer(queryset)
     return Response(serializer.data)
예제 #16
0
 def list(self,request):
     queryset = Vendor.query().fetch()
     serializer=VendorsListSerializer(queryset,many=True)
     return Response(serializer.data)
예제 #17
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())
예제 #18
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)
예제 #19
0
def api_drive():
	vendors = yield from Vendor.findAll(orderBy='vendor_name')
	models = yield from DM.findAll(orderBy='model_name')
	firmwares = yield from Firmware.findAll()
	return dict(vendor=vendors,model=models,firmware=firmwares)
예제 #20
0
 def destroy(self,request,ID):
     vendor =Vendor.get_by_id(int(ID))
     print vendor
     vendor.key.delete()
     return Response(status=status.HTTP_204_NO_CONTENT)
예제 #21
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
    })