Exemplo n.º 1
0
def index():
    # with this code, your need to directly type in /store
    store_name = request.args.get('store_name')
    print(store_name)
    newstore = Store(name=store_name)
    newstore.save()
    return render_template('index.html', store_name=store_name)
Exemplo n.º 2
0
    async def store_stock(self, ctx, store_name: str, item_name: str):
        store = Store.find_one({'name': store_name})
        if not store:
            return await ctx.send(
                f'```fix\nCould not find store "{store_name}"\n```')
        item = Item.find_one({'name': item_name})
        if not item:
            return await ctx.send(
                f'```fix\nCould not find item "{item_name}"\n```')

        store = Prodict.from_dict(store)
        item = Prodict.from_dict(item)
        if store.item_list:
            if item.id in store['item_list']:
                return await ctx.send(
                    f'```fix\nItem "{item_name}" already exists in "{store_name}"\n```'
                )
            store.item_list.append(item.id)
            print('exist')
        else:
            print('not exist')
            store.item_list = [item.id]

        Store.save(store)

        await ctx.send(f'```css\nStocked "{item_name}" in "{store_name}"\n```')
def submitBusiness_accepted(request):
	Name = request.POST['name']
	Owner = request.user
	StoreType = request.POST['storeType']
	Address = request.POST['address']
	Info = request.POST['info']
	new_store = Store(name = Name, owner = Owner, storeType = StoreType, address = Address, info = Info)
	new_store.save()
	return HttpResponseRedirect('success')
Exemplo n.º 4
0
 def post(self, request, *args):
     name = request.POST['name']
     owner = request.POST['owner']
     latlon = request.POST['location'].split(",")
     owner = Seller.objects.get(id=owner)
     location = fromstr('POINT(%s %s)' % (latlon[0], latlon[1]), srid=4326)
     s = Store(name=name, owner=owner, location=location)
     s.save()
     success = True
     context = {"success": success, "id": s.id}
     return self.render_to_json_response(context)
Exemplo n.º 5
0
 def post(self, name):
     if StoreModel.find_by_name(name):
         return dict(message=f'A store with name {name} already exists'), 400
     
     store = StoreModel(name)
     try:
         store.save()
     except:
         return dict(message='An error occurred while creating the store'), 500
     
     return store.json(), 201
Exemplo n.º 6
0
def create():
    store_name = request.form.get("store_name")
    store = Store(name=store_name)
    # store.save()
    # return redirect(url_for("show_store"))
    try:
        store.save()
        flash(f"Saved store: {store_name}")
        return redirect(url_for("show_store"))
    except:
        flash("That name is already taken")
        return render_template("show_store.html")
Exemplo n.º 7
0
def bookmarks(request):
    if request.method == 'GET':
        var = request.GET.get('action', '')
        if (var == "add"):
            p1 = Store(text=request.GET.get('text'),
                       url=request.GET.get('url'))
            p1.save()
        elif (var == "remove"):
            p2 = Store.objects.filter(text=request.GET.get('text'),
                                      url=request.GET.get('url'))
            p2.delete()
        urls = Store.objects.all()
        return render(request, 'bookmarks.html', {'context': urls})
Exemplo n.º 8
0
 def post(self):
     '''Add a new store by the method post'''
     try:
         args = self.reqparse.parse_args()
         store = Store(
             name=args['name'],
             address=args['address'],
             phone=args['phone'],
             owner=args['owner'],
             geolocation=args['geolocation']
         )
         store.save()
         return {'store': marshal(store, store_fields)}, 201
     except Exception:
         abort(500)
Exemplo n.º 9
0
    def test_should_have_store_as_addressable(self):
        """
        Prueba que una direccion pueda ser asociada
        a una tienda
        """

        store = Store(name="My store")
        store.save()

        address = Address()
        address.street1 = "Cra 7 # 6-19"
        address.addressable_object = store
        address.save()

        address_from_db = Address.objects.get(id=address.id)
        self.assertEqual(address_from_db.addressable_type.name, 'store')
Exemplo n.º 10
0
    def test_should_have_store_as_addressable(self):
        """
        Prueba que una direccion pueda ser asociada
        a una tienda
        """

        store = Store(name="My store")
        store.save()

        address = Address()
        address.street1 = "Cra 7 # 6-19"
        address.addressable_object = store 
        address.save()

        address_from_db = Address.objects.get(id=address.id)
        self.assertEqual(address_from_db.addressable_type.name, 'store')
Exemplo n.º 11
0
def store_form():
    s = Store(name=request.args['name'])

    if s.save():
        flash("Successfuly save")
        return redirect(url_for('store'))
    else:
        return render_template('store.html', name=request.args['name'] )
Exemplo n.º 12
0
def create_store():
    s = Store(name=request.form.get('store_name'))
    if s.save():
        flash("successfully save")
        return redirect(url_for('create_store'))
    else:
        return render_template('store.html',
                               name=request.form.get('store_name'))
Exemplo n.º 13
0
def store_create():
    store_name = request.form.get('store_name')
    store = Store(name=store_name)
    if store.save():
        flash("Store created!", "success")
        return redirect(url_for('store_new'))
    else:
        return render_template('store.html', errors=store.errors)
Exemplo n.º 14
0
def shop_form(): 
    store_name = request.form.get('store_name')
    store_details = Store(name=store_name)
    if store_details.save(): 
        flash('Store sucessfully saved!')
        return redirect(url_for('index'))
    else: 
        return render_template('shop.html', store_name = store_name)
Exemplo n.º 15
0
def store_create():
    # get form value in form
    store_name = request.form.get('store_name')
    store = Store(name=store_name)
    if store.save():
        flash("Store created!", "success")
    else:
        flash("Unable to create!", "danger")
    return redirect(url_for('store_new'))
Exemplo n.º 16
0
def s_create():
    store_name = request.form.get('store_name')
    s = Store(name=store_name)

    if s.save():
        flash(f"Successfully saved {store_name}")
        return redirect(url_for('store'))
    else :
        return render_template('store.html', name=store_name, errors=s.errors)
Exemplo n.º 17
0
def store_form():
    name=request.form.get('store_name')
    s = Store(name=name)

    if s.save():
        # flash("Successfully saved!") #Set flash for another time. Uses secret key: https://flask.palletsprojects.com/en/1.0.x/quickstart/#sessions
        return redirect(url_for('store'))
    else:
        return render_template('store.html', name=name)
Exemplo n.º 18
0
def store_create():
    store_name = request.form.get('store_name')
    store = Store(name=store_name)
    if store.save():
        flash(f"{store_name} has been created!", 'info')
    else:
        flash('Something went wrong!')

    return redirect('/')
Exemplo n.º 19
0
def store_created():

    store_name = request.form.get("store_name")
    store = Store(name=store_name)
    if store.save():
        flash("Successfully added", "success")
    else:
        flash("Duplicate Entry!!", "danger")
    return redirect(url_for("store_new"))
Exemplo n.º 20
0
def add_store():
    store = Store(name=request.form["store_name"])
    if store.save():
        flash("Successfully saved!")
        return redirect("/")
    else:
        flash("Store already exists! Trash!")
        return render_template("store.html",
                               name=request.form["store_name"],
                               errors=store.errors)
Exemplo n.º 21
0
def create():
    store_name = request.form['store_name']
    # store_name = request.form.get('store_name') //this is a 'softcode' version of the code above
    store = Store(name=store_name)
    if store.save():
        flash('Successfully Created Store', "success")
        return redirect(url_for('show'))
    else:
        flash('failed to create store', "danger")
        return redirect(url_for('show'))
def create():
    store_name = request.form.get('store_name')
    store = Store(name=store_name)

    if store.save():  # save method returns either 0 or 1
        flash(f"Saved Store: {store_name}")
        return redirect(url_for('addstore'))
    else:
        flash('Name is already taken, pick another')
        return render_template('store.html', errors=store.errors)
Exemplo n.º 23
0
def create_store():
    store_name = request.form.get("store_name")
    store = Store(name=store_name)

    if store.save():
        flash(f"Saved store: {store_name}")
        return redirect(url_for("new_store"))
    else:
        flash("That name is already taken")
        return render_template("store.html", errors=store.errors)
Exemplo n.º 24
0
def create_store():
    s = Store(name=request.form.get('name'))

    if s.save():
        flash("successfully saved")
        return redirect(url_for('store'))
    else:
        for e in s.errors:
            flash(e)
        return render_template('store.html', name=request.form['name'])
Exemplo n.º 25
0
class TestEmployee(TestCase):
    def setUp(self):
        self.region = Region(name="test_region")
        self.region.save()
        self.company = Company(code="1001", name="test_company", region=self.region)
        self.company.save()

        self.store = Store(code="10011001", name="test_store", company=self.company)
        self.store.save()

        self.emp_region = Employee(username="******", organization=self.region)
        self.emp_company = Employee(username="******", organization=self.company)
        self.emp_store = Employee(username="******", organization=self.store)

    def test_organizations(self):
        organizations = self.emp_region.organizations()
        self.assertEquals([self.region], organizations)
        organizations = self.emp_company.organizations()
        self.assertEquals([self.region, self.company], organizations)
        organizations = self.emp_store.organizations()
        self.assertEquals([self.region, self.company, self.store], organizations)

    def test_in_xxx_org(self):
        # employee in region
        self.assertTrue(self.emp_region.in_region())
        self.assertFalse(self.emp_region.in_company())
        self.assertFalse(self.emp_region.in_store())

        # employee in company
        self.assertFalse(self.emp_company.in_region())
        self.assertTrue(self.emp_company.in_company())
        self.assertFalse(self.emp_company.in_store())

        # employee in company
        self.assertFalse(self.emp_store.in_region())
        self.assertFalse(self.emp_store.in_company())
        self.assertTrue(self.emp_store.in_store())

    def test_org(self):
        self.assertEqual(self.emp_region.org(), self.region)
        self.assertEqual(self.emp_company.org(), self.company)
        self.assertEqual(self.emp_store.org(), self.store)
Exemplo n.º 26
0
def create_store():
    if request.method == "POST":
        s = Store(name=request.form.get('store_name'))
        if s.save():
            flash(
                f"Store name {request.form['store_name']} successfully saved.")
            return redirect(url_for('new_store'))
        else:
            return render_template('add-store.html',
                                   name=request.form['store_name'],
                                   errors=s.errors)
Exemplo n.º 27
0
def store():
	# form = forms.Store()
	# store_list = Store.select()
	store_list = Store.select()
	payload = []
	for store in store_list:
		new_object = {
			"store_name": store.name,
			"num": len(list(store.warehouses))
		}
		payload.append(new_object)
	if request.method == 'POST':
		# How to post a success message from form submission if not using flash but using bootstrap under 'store.html' line 5
		# breakpoint()
		new_store = Store(name=request.form['store_name'])
		new_store.save()
		flash("Store created", "success")
		return redirect(url_for('store'), store_list)
	else:
		return render_template('store.html', payload=payload)
Exemplo n.º 28
0
def store_update(id):
    # not getting the id will lead to creating new data
    updated_st = Store(store_id=id, name=request.form['name'])
    if updated_st.save(only=[Store.name]):
        flash("Successfully updated!", 'success')
    else:
        flash("Something went wrong, check your internet and try again",
              'danger')

    return redirect(url_for(
        'store_show',
        id=id))  # return back to store_show.html with the selected store_id
Exemplo n.º 29
0
class TestOrganization(TestCase):
    def setUp(self):
        self.region = Region(name="test_region")
        self.region.save()

        self.company = Company(code="1001", name="test_company", region=self.region)
        self.company.save()
        self.company2 = Company(code="1002", name="test_company_2", region=self.region)
        self.company2.save()

        self.store = Store(code="10011001", name="test_store", company=self.company)
        self.store.save()

    def test_ancestor(self):
        self.assertTrue(self.region.pk == self.company.ancestor().pk)
        self.assertTrue(self.region.pk == self.store.ancestor().pk)

    def test_belong_to(self):
        self.assertTrue(self.store.belong_to(self.company))
        self.assertFalse(self.region.belong_to(self.company))
        self.assertFalse(self.store.belong_to(self.company2))
Exemplo n.º 30
0
def create():
    s = Store(name=request.form['name'])
    #s is equal to the class with the name from the html button
    #pulling the informatino from form, not args

    if s.save():
        flash("flash saved")
        return redirect(url_for('store', id=s.id))
    else:
        flash("error")
        return render_template('store.html',
                               name=request.form['name'],
                               errors=s.errors)
Exemplo n.º 31
0
def store_create():
    new_st = Store(name=request.form['name'])

    if not Store.get_or_none(Store.name == new_st.name):
        if new_st.save():
            flash("New store successfully created!", "success")
            return redirect(url_for('stores_list'))
        else:
            flash(
                "Something went wrong, please check your internet and try again",
                "danger")
            return render_template('store.html', name=request.form['name'])
    else:
        flash("Store has already existed", "danger")
        return render_template('store.html', name=request.form['name'])
Exemplo n.º 32
0
def store_edit(request):
    """
    商店资料编辑
    :param request:
    :param store_id:
    :return:
    ['name','seller','business','kinds','link','industry','character','phone','QQ','is_create','is_design','is_custom','is_work_design','company','introduction','post','connector']
    """
    try:

        user = request.user
        store = Store.objects.filter(status=2).get(seller=user)
        Aform = StoreForm(instance=store)
    except:
        return HttpResponseRedirect('/Store/store_apply')
    if request.method == 'POST':
        name = request.POST.get('name')
        business = request.POST.get('business')
        kinds = request.POST.get('kinds')
        link = request.POST.get('link')
        industry = request.POST.get('industry')
        character = request.POST.get('character')
        phone = request.POST.get('phone')
        QQ = request.POST.get('QQ')
        introduction = request.POST.get('introduction')
        headpicture = request.FILES.get('headpicture','')
        companyname = request.POST.get('companyname')
        connectioner = request.POST.get('connectioner')
        connection_number = request.POST.get('connection_number')
        company_adress = request.POST.get('company_adress')
        company_QQ = request.POST.get('company_QQ')
        business_license = request.FILES.get('business_license','')
        company_introduce = request.POST.get('company_introduce')

        kind = big_goods_type.objects.get(id=kinds)

        # 头像保存保存# 营业执照保存
        if not headpicture :
            headpicture = store.headpicture
        else:
            path = default_storage.save(str(headpicture), ContentFile(headpicture.read()))
            tmp_file = os.path.join(settings.MEDIA_ROOT, path)
            headpicture = str(headpicture)
        if not business_license:
            business_license = store.business_license
        else:
            path = default_storage.save(str(business_license), ContentFile(business_license.read()))
            tmp_file = os.path.join(settings.MEDIA_ROOT, path)
            business_license = str(business_license)
        s = Store(name=name, phone=phone, QQ=QQ, link=link, kinds=kind,seller=user,
                                 business=business, industry=industry,
                                 character=character, introduction=introduction, headpicture=headpicture,
                                 companyname=companyname,
                                 connectioner=connectioner, connection_number=connection_number,
                                 company_adress=company_adress, company_QQ=company_QQ,
                                 business_license=business_license, company_introduce=company_introduce)
        s.id = store.id
        s.save()
        return HttpResponse('修改成功啦')
    else:
        return render(request,'person_dpbj.html',{'form':Aform})  # else:
Exemplo n.º 33
0
def store_create():
    store_name = request.form.get('store_name')
    store_1 = Store(name=store_name)
    if store_1.save():
        flash("Store succesfully created")
    return redirect(url_for('store_new'))
def save_store(data):
    store = Store(url=data["url"], public_id=data["public_id"], name=data["name"])
    store.save()
Exemplo n.º 35
0
def store_create():
    store_name = request.form['store_name']
    s = Store(name=store_name)
    s.save()
    return redirect(url_for('store_new'))
Exemplo n.º 36
0
def store_create():
    # request.args() for one input |  request.form() for whole form info name, address, etc
    new_st = Store(name=request.args['new_store_name'])
    new_st.save()
    return redirect(url_for('index'))