def new_item(request): """ New item """ data = {} template = 'itembase/simpleform.djhtml' data['message'] = None data['headstring'] = 'New Item' if request.method == "POST": form = ItemForm(request.POST) if form.is_valid(): item = Items( it_name=form.cleaned_data['it_name'], it_info=form.cleaned_data['it_info'], it_storageinfo=form.cleaned_data['it_storageinfo'], it_back_to_owner=form.cleaned_data['it_back_to_owner'], it_personal_handover=form.cleaned_data['it_personal_handover'], it_owner=request.user, ) item.save() return redirect('itembase/home') return redirect('itembase/home') else: data['form'] = ItemForm() return render(request, template, data)
def doDatabaseWrite(categories, previous_category, user_data, item=None): """ Método utilitário que checa se os campos do formulário estão preenchidos antes de salvar o item no banco de dados. Em caso de erro, retorna os redirects e erros correspondente à ação sendo executada (criação ou edição) Também checa se um item já existe na categoria informada com o mesmo nome. """ if item: form_name = "edititem.html" message = "Item edited" isInsert = False else: item = Items(title=None, description=None, category_id=None, user_id=login_session["user_id"]) form_name = "newitem.html" message = "New item created" isInsert = True if user_data["title"] \ and user_data["description"] \ and user_data["category_id"]: item.title = user_data["title"] item.description = user_data["description"] item.category_id = user_data["category_id"] try: session.add(item) session.commit() flash(message) category_name = session.query(Categories) \ .filter_by(id=user_data["category_id"]) \ .first().name if isInsert: return redirect(url_for("showAllItems", category_name=category_name)) else: return redirect(url_for("showItem", category_name=category_name, item_name=user_data["title"])) except IntegrityError: session.rollback() flash("Item '%s' already exists in selected category." % user_data["title"]) return render_template(form_name, categories=categories, item=user_data, previous_category=previous_category, previous_item=item.title) else: flash("There is missing data") return render_template(form_name, categories=categories, item=user_data, previous_category=previous_category, previous_item=item.title)
def add_item(request, item, body, title): try: if item: item.append(title, body) else: Items.create(title, body) except Exception as error: print "Exception", type(error) return "ok"
def post_item(): if Items.objects.count() < max_items: root_count = Items.root_count() if root_count<10: text = get_text() item = Items.create(text,text) elif root_count<10: item = Items.objects.order_by('?')[0] else: item = Items.objects.filter(parent__gte=1)[0] text = get_text() item.append(text, text)
def order(request): # 这里添加验证 不能全是0 网页上也要验证 orderTemp = Order(employee=Employee.objects.get(name=request.session['username'])) orderTemp.save() for stationery in Stationery.objects.all(): if request.POST.get(str(stationery.id)) != '0': item = Items(stationery=stationery, amount=request.POST[str(stationery.id)], order=orderTemp) item.save() # print request.POST.get(str(stationery.id)) ItemList = Items.objects.filter(order=orderTemp) return render(request, 'wenjuApp/result.html', {'ItemList': ItemList})
def updateMetascore(request): # get items items = Items.query().fetch() # iterate items for item in items: # if metacriticPage is valid if (item.item_metacriticPage != None and item.item_metacriticPage != ''): # fetch page url = METACRITIC_BASE_URL + item.item_metacriticPage logging.info(url) # allow 30 seconds for response response = urlfetch.fetch(url, None, 'GET', {}, False, False, 30) if response.status_code == 200: # parse metacritic page response - return score metascore = getMetacriticScore(response.content) logging.info('------ METASCORE -------') logging.info('-------------------') logging.info(metascore) logging.info('-------------------') # upate item record item.item_metascore = metascore item.put() return HttpResponse('success', mimetype='text/plain', status='200')
def newItem(category_name): user = login_session.get('user', None) category = session.query(Categories).filter_by(name=category_name).one() # User must be logged in to create an item. if user is None: flash("Sorry, you need to be login to use that.") return redirect(url_for('login')) if request.method == 'POST': name = request.form['name'] description = request.form['description'] location = request.form['location'] url = request.form['url'] item = Items(name=name, description=description, location=location, url=url, user=user, category=category) dbAddUpdate(item) flash("{0} has been added to {1}.".format(item.name, category.name)) return redirect( url_for('showOneCategoryAndItems', category_name=category_name)) else: return render_template('newItem.html', category=category, login=loginLabel['logout'])
def addItem(): if login_session.get('username'): if request.method == 'POST': category = session.query(Categories).filter_by( name=request.form.get("category")).one() # noqa: E501 # get item picture if selected pic = request.form.get("picture") if pic != "": if 'picture' in request.files: file = request.files['picture'] if file.filename != '': # save picture to upload folder and give it item name filename = secure_filename(file.filename) file.save( os.path.join(app.config['UPLOAD_FOLDER'], filename)) os.rename( os.path.join(app.config['UPLOAD_FOLDER'], filename), os.path.join(app.config['UPLOAD_FOLDER'], request.form.get("name") + ".jpg")) item = Items(name=request.form.get("name"), description=request.form.get("description"), picture=request.form.get("name") + ".jpg", cat_id=category.id, category=category.name, user_id=login_session['username']) session.add(item) session.commit() return redirect(url_for("showMain")) else: categories = session.query(Categories).all() return render_template('newItem.html', categories=categories) else: return redirect(url_for('showLogin'))
def add_item(): form = ItemForm() if form.validate_on_submit(): try: _ = int(form.quantity.data) except ValueError: return "The \"quantity\" field must contain an integer. No items were added, and the database was NOT updated." if (len(form.name.data) > 256): _l = "name" elif (len(form.description.data) > 256): _l = "description" else: _l = "x" if (_l != "x"): return "Length of the \"{}\" field must not exceed 256 characters. No items were added, and the database was NOT updated.".format( _l) item = Items(name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) db_session.add(item) db_session.commit() return redirect(url_for('success')) return render_template('index.html', form=form)
def newItem(): if 'username' not in login_session: print('you are not login') return redirect(url_for('showTop')) else: print('you are logged in') if request.method == 'POST': category_name = request.form['category'] item_name = request.form['item_name'] description = request.form['description'] category = session.query(Category.id).filter( Category.category_name == category_name).first() newItem = Items(item_name=item_name, registered_at=str(datetime.now()), category_id=category.id, description=description) print(newItem) session.add(newItem) flash('New Item {} Successfully Created'.format(newItem.item_name)) session.commit() return redirect(url_for('showTop')) else: category_names = session.query(Category.category_name).order_by( asc(Category.category_name)).all() if category_names == []: category_names = str("No category is registered yet.") print(category_names) return render_template('reg_item.html', category_names=category_names)
def add_item(): form = ItemForm() if form.validate_on_submit(): #Through testing, I found this bit of code is what's causing the 504 error. #Took out the date_added variable to see if that was holding it up. #Added datetime back in. It didn't break anything. Still getting outputs like [,,]. item = Items(name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) ## #Maybe item isn't being populated correctly. Try one attribute at a time. ## #Still getting the same [,,,] type output. ## item = Items() ## item.name = form.name.data ## item.quantity = form.quantity.data ## item.description = form.description.data ## item.date_added = datetime.datetime.now() #More testing shows the error 504 came from calling db_session. #This was because the postgres port was supposed to stay as 5432. #Output after submittion is a list of commas, so maybe item isn't getting #added correctly to the table. db_session.add(item) db_session.commit() return redirect(url_for('success')) return render_template('index.html', form=form)
def items(category): if request.method == 'POST': newItem = Items(item_name=request.form['name'], registered_at=str(datetime.now())) session.add(newItem) flash('New Item {} Successfully Created'.format(newItem.item_name)) session.commit() return redirect(url_for('showTop')) else: category_list = session.query(Category.category_name).all() category = session.query(Category.id, Category.category_name).filter( Category.category_name == category).first() items = session.query(Items, Category.category_name).join( Items, Items.category_id == Category.id).filter( Items.category_id == category.id).all() num_items = session.query( Items.item_name).filter(Items.category_id == category.id).count() if 'username' not in login_session: print('you are not login') return render_template('items_in_category.html', items=items, category_list=category_list, category=category.category_name, num_items=num_items) else: print('you are login') return render_template('items_in_categoryLogin.html', items=items, category_list=category_list, category=category.category_name, num_items=num_items)
def getCreate(id): # Login user can only access his/her own information if id != login_session['user_id']: return render_template('youShallNotPass.html') # query user from db user = session.query(User).filter_by(id=login_session['user_id']).one() # if 'post' then add the new item to the db # item.user_id will be the login_session['user_id'] if request.method == 'POST': newItem = Items( name=request.form['name'], user_id=login_session['user_id'], description=request.form['description'] ) session.add(newItem) session.commit() return redirect(url_for('getCatalog', user_id=id)) # if 'get' return html template to create new item if request.method == 'GET': return render_template('getCreate_GET.html', user=user, login_session=login_session )
def add_item(): form = ItemForm() if form.validate_on_submit(): item = Items(name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) db_session.add(item) db_session.commit() return redirect(url_for('success')) return render_template('index.html', form=form)
def testBasic(self): body, title = get_text(),get_text() item = Items.create(body, title) self.assertTrue(item.text , 'text value') self.assertEqual(item.parent, None, 'appending to root') body, title = get_text(),get_text() child = Items.create(body, title, item) self.assertEqual(child.parent, item, 'appending to item') item2 = Items.create(get_text(),get_text()) child.move(item2.id) self.assertEqual(child.parent, item2m, 'moving')
def buy(): item = json.loads(request.data) username = session['username'] user = Users.query.filter_by(username=username).first() player_item = PlayerInventory.query.filter_by(item_name=item) if not player_item: if item == 'tiger' or item == 'lion': add_item=Items(1, username.id, item, 1, 500000) db_session.add(add_item) db_session.commit() elif item == 'sugar': add_item=Items(2, username.id, item, 1, 500) db_session.add(add_item) db_session.commit() else: player_items = PlayerInventory.query.filter_by(item_name=player_item.item_name,user_id=user.id) player_items.quantity += 1 db_session.commit()
def create_items_helper(files): index = 1 for string in files: housewares = load_json(string) for (k, item) in housewares.items(): name = item[0]['name']['name-USen'] kitCost = item[0]['kit-cost'] if kitCost == None: kitCost = -1 size = item[0]['size'].replace(" ", "") source = item[0]['source'] isInteractive = item[0]['isInteractive'] if type(item[0]['isInteractive']) == str: isInteractive = True buyPrice = item[0]['buy-price'] sellPrice = item[0]['sell-price'] category = item[0]['tag'] if category == "": category = str('N/A') variant_list = [] image_list = [] pattern_list = [] for i in item: v = i['variant'] if not v in variant_list: variant_list.append(v) img = i['image_uri'] if not img in image_list: image_list.append(img) p = i['pattern'] if not p in pattern_list: pattern_list.append(p) variant = "" if variant_list[0] != None: variant = ', '.join(variant_list) image = ','.join(image_list) pattern = "" if pattern_list[0] != None: pattern = ', '.join(pattern_list) typeof = string.split('.')[0].capitalize() id = index new_item = Items(name=name, kitCost=kitCost, size=size, source=source, isInteractive=isInteractive, buyPrice=buyPrice, sellPrice=sellPrice, image=image, category=category, variant=variant, pattern=pattern, typeof=typeof, id=id) db.session.add(new_item) db.session.commit() index += 1
def submit_item_to_sell(request, user_email): """ View for filling out information about an item to sell """ if request.method == 'POST': new_item = Items() max_id_value = 0 for existing_item in Items.objects.all(): last_id = existing_item.item_id if int(last_id) > max_id_value: max_id_value = int(last_id) new_id = str(max_id_value+1) new_item.item_id = new_id new_item.item_name = request.POST.get('item_name') new_item.description = request.POST.get('description') new_item.location = request.POST.get('location') new_item.save() new_user = True #search for users for user in Sellers.objects.all(): if user.seller_id == request.POST.get('user_email'): user.item_id_id = new_item.item_id new_user = False user.save() if new_user == True: new_seller = Sellers() new_seller.username_id = retrieve_id_of_registered_user(request.POST.get('user_email')) idd = new_seller.username_id if request.POST.get('user_email') == None: new_seller.seller_id = 'empty' else: new_seller.seller_id = request.POST.get('user_email') new_seller.item_id_id = new_item.item_id use = request.GET.get('user_email') new_seller.save() price_entry_for_new_item = Fixed_Price() price_entry_for_new_item.item_id = new_item price_entry_for_new_item.price = request.POST.get('price') price_entry_for_new_item.save() item_belongs_to = Belongs_to() item_belongs_to.item_id = new_item item_belongs_to.category = 'Books' item_belongs_to.save() #return render_to_response('add_item_for_sell.html') return HttpResponseRedirect('/online_store/submitted_item_to_sell', {'user_email': user_email} )
def test_fill(self): item = Items(name="test", quantity=1, description="test", date_added=datetime.datetime.now()) db_session.add(item) db_session.commit() items = Items.query.all() assert item in items print len(items)
def add_item(): #raise form = ItemForm() if request.method == 'POST': if form.validate_on_submit(): item = Items(name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) db_session.add(item) db_session.commit() logging.warn(" after committ...") #return redirect(url_for('success')) return redirect('/success') return render_template('index.html', form=form)
def addItem(): if request.method == 'GET': # Make sure only logged in users can access this page if ('username' in login_session): return render_template('addItem.html', login_session=login_session) else: flash('Please login in order to add key/value pairs') return redirect(url_for('login')) elif request.method == 'POST': # Make sure only logged in users are adding key/value pairs if ('username' in login_session): key = request.form.get('key') value = request.form.get('value') item = db.query(Items).filter_by(key=key).first() # Make sure key is unique/not already added if item: flash('"%s" has already been added' % item.key) return redirect(url_for('addItem')) if key is not None and key != '': item = Items(key=key) if value is not None and value != '': item.value = value item.author = getUserInfo(login_session['user_id']) else: flash('You need to provide a proper Key/Value pair') return redirect(url_for('addItem')) db.add(item) db.commit() flash('Item Added!') return redirect(url_for('index')) else: flash('Please login in order to add key/value pairs') return redirect(url_for('login')) else: return redirect(url_for('index'))
def item(): print "reached in item view" if request.method == 'GET': form = ItemForm(request.form) return render_template('forms/item.html', form=form) if request.method == 'POST': print "hii" itemlist = Items(request.form['itemname'], request.form['price'], request.form['description']) print itemlist db.session.add(itemlist) db.session.commit() return redirect(url_for('how'))
def add_item(): form = ItemForm() if form.validate_on_submit(): item = Items( name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=str(datetime.datetime.now()), ) db_session.add(item) db_session.commit() return redirect(url_for("success", _external=True)) return render_template("index.html", form=form)
def newCategoryItem(): """add new items""" categories = session.query(Categories).all() if request.method == 'POST': newItem = Items(name=request.form['name'], description=request.form['description'], date=datetime.datetime.now(), category_id=request.form['category'], user_id=login_session['user_id']) session.add(newItem) session.commit() flash("New Item added: %s " % newItem.name) return redirect(url_for('showCatalog')) return render_template('addItem.html', categories=categories)
def addItem(): catalog = session.query(Category).all() if request.method == 'POST': newItemToAdd = Items(name=request.form['name'], description=request.form['description'], category=session.query(Category).filter_by( name=request.form['category']).one(), user_id=login_session['user_id']) session.add(newItemToAdd) session.commit() flash("Successfully Added New Item") return redirect(url_for('showCatalog')) else: return render_template('private_AddItem.html', catalog=catalog)
def add_todo(name, item): os.system('clear') todo_title() s = select([Category]) result = s.execute() for r in result: if r[1] == name: data = Items(category_id=r[0], items=item) session.add(data) session.commit() open_todo(name)
def addCatalogItem(): if not login_session.get('access_token'): return redirect('/') else: logged_in = True ownerId = login_session["user_id"] # Query all of the categories categories = session.query(Categories).order_by("categoryName").all() # POST methods actions if request.method == 'POST': # Set the name of the new restaurant into the dictionary new_item = Items(itemName=request.form['item_name'], itemDescription=request.form['item_description'], owner=ownerId, added=currentDateTime, modified=currentDateTime, status='A') # Add it to the session session.add(new_item) # Commit the addition to the database session.commit() addedItem = session.query(Items).order_by(Items.itemId.desc()).first() """Flash message that the item was successfully added. Add BOOTSTRAP css classes as the message category.""" flash('New item was successfully added! (%s)' % addedItem.itemName, 'badge badge-success') new_cat = request.form['item_category'] new_count = request.form['item_inventory'] new_price = request.form['item_price'] new_item_category = ItemCategories(categoryId=new_cat, itemId=addedItem.itemId) new_item_inventory = Inventory(itemId=addedItem.itemId, inventoryCount=new_count, itemPrice=new_price, lastUpdated=currentDateTime) session.add(new_item_category) session.add(new_item_inventory) session.commit() # Item Tags - Outside of scope of this project - Do later # Item Photo - Outside of scope of this project - Do later # Redirect the user back to the main Restaurants page return redirect(url_for('showMyItems')) # GET method actions else: # Display the Add New Restaurant form page return render_template('addItem_LoggedIn.html', categories=categories, email=login_session['email'], logged_in=logged_in)
def add_item(): form = ItemForm() if form.validate_on_submit(): item = Items(id=random.randint(1, 5000), name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) db_session.add(item) db_session.commit() flash('Thank you for entering your item') return redirect(url_for('success')) # else: add some sort of error catching here return render_template('index.html', form=form)
def add_item(): form = ItemForm(request.form) if request.method=="POST" and form.validate_on_submit(): try: item = Items( name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) db_session.add(item) db_session.commit() return redirect(url_for('success')) except: return 'There was a problem adding an item' return render_template('index.html', form=form)
def add_item(): form = ItemForm() # Only when posting if form.validate_on_submit(): # Populate item for insertion item = Items(name=form.name.data, quantity=form.quantity.data, description=form.description.data, date_added=datetime.datetime.now()) try: db_session.add(item) db_session.commit() return redirect(url_for('success')) except: #When failed, pressing the back key will keep the input boxes filled return "Go back and check if quantity is a number or not." return render_template('index.html', form=form)
def add_item(): if request.method == 'GET': if (login_session['username'] is not None): categories = db.query(Category).all() return render_template('add_item.html', login_session=login_session, categories=categories) else: return render_template('login.html', error="You must be logged in to do that!") elif request.method == 'POST': if login_session['username'] is not None: categories = db.query(Category).all() item_name = request.form.get('item_name') price = request.form.get('price') description = request.form.get('description') category = request.form.get('category') new_category = request.form.get('new_category') if item_name is not None and item_name != '': item = Items(name=item_name) if price is not None and item.price != '': item.price = price if description is not None and description != '': item.description = description item.author = getUserInfo(login_session['user_id']) else: flash("You need to give an item!") return redirect(url_for('add_item')) if category is not None and category != '': c = db.query(Category).filter_by(name=category).first() item.category = c elif new_category is not None and new_category != '': c = db.query(Category).filter_by(name=new_category).first() if (c): flash("You cannot add a category that already exists!") return redirect(url_for('add_item')) new_category = Category(name=new_category) item.category = new_category db.add(new_category) else: flash("You need to provide a category!") return redirect(url_for('add_item')) db.add(item) db.commit() return redirect(url_for('index')) else: flash("Please log in to add items") return redirect(url_for('index'))
def new_item(request): """ New item """ data = {} template = 'itembase/simpleform.djhtml' data['message'] = None data['headstring']='New Item' if request.method == "POST": form = ItemForm(request.POST) if form.is_valid(): item = Items(it_name=form.cleaned_data['it_name'], it_info=form.cleaned_data['it_info'], it_storageinfo=form.cleaned_data['it_storageinfo'], it_back_to_owner=form.cleaned_data['it_back_to_owner'], it_personal_handover=form.cleaned_data['it_personal_handover'], it_owner=request.user, ) item.save() return redirect('itembase/home') return redirect('itembase/home') else: data['form'] = ItemForm() return render(request, template, data)
def get_item_id(self): item_index = self.cbItem.findText(self.cbItem.currentText()) if item_index >= 0: return self.cbItem.itemData(item_index)['id'] if not self.msg_confirmation("Cannot find such an item in the DB.", "Would you like to add this one?"): return None item_id = Items.insert(name=self.cbItem.currentText()) if item_id: self.reload(Items) return item_id else: return None
def createItem(category): if request.method == 'POST': find_category = session.query(Categories).filter_by( category=category).first() item = Items(category_id=find_category.id, item=request.form['item'], description=request.form['description'], user_id=login_session['id']) session.add(item) session.commit() flash('%s has been succesfully added' % request.form['item']) return redirect( url_for('itemDetail', category=category, item=request.form['item'])) # GET request return render_template('newItem.html', category=category)
def create(self, data): customers_id = data['customers_id'] items = data['items'] self.buy_at_most_ten_diferrent_books(items) price = self.apply_discount(items, customers_id) total = price.total discount = price.discount sales = Sales(customers_id, total, discount) db.session.add(sales) for item in items: new_items = Items(sales.id, item['books_id'], item['quantity']) sales.items.append(new_items) db.session.add(new_items) db.session.commit() return create_sales(sales)
def updateSteamPriceDeferred(): # get items items = Items.query().fetch() # iterate items for item in items: # steam price URL found if (item.item_steamPriceURL != None and item.item_steamPriceURL.strip() != ''): # fetch page url = item.item_steamPriceURL # headers required for response headers = {'Cookie': 'Steam_Language=english; birthtime=-2208959999;', 'User-Agent': 'Mozilla', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'Accept': 'text/html', 'Accept-Encoding': 'gzip'} # fetch(url, payload=None, method=GET, headers={}, allow_truncated=False, follow_redirects=True, deadline=None, validate_certificate=None) # allow 30 seconds for response response = urlfetch.fetch(url, None, 'GET', headers, False, False, 30) # decompress f = StringIO.StringIO(response.content) c = gzip.GzipFile(fileobj=f) content = c.read() if response.status_code == 200: # parse metacritic page response - return score steamPrice = getSteamPrice(content) if (steamPrice != None): logging.info('------ UPDATE STEAM PRICE v2 -------') logging.info(item.item_name) logging.info(steamPrice) # upate item record item.item_steamPrice = steamPrice item.put() return HttpResponse('success', mimetype='text/plain', status='200')
def newItem(category_id): session = DBSession() if 'username' not in login_session: return redirect('/login') category = session.query(Category).filter_by(id=category_id).one() if login_session['user_id'] != category.user_id: return """<script>function myFunction() {alert('You are not authorized to add items items to this catalog. Please create your own catalog in order to add items.');}</script><body onload='myFunction()'>""" if request.method == 'POST': newItem = Items(name=request.form['name'], description=request.form['description'], category_id=category.id, user_id=category.user_id) session.add(newItem) session.commit() flash('New %s Item Successfully Created' % (newItem.name)) return redirect(url_for('showItems', category_id=category_id)) else: return render_template('newitem.html', category_id=category_id)
def newItem(): if 'username' not in login_session: return 'Unauthorized Access!' else: categories = session.query(Categories).all() if request.method == 'POST': getuser = session.query(User).filter_by( username=login_session['username']).first() getuser_id = getuser.id new_item = Items(user_id=getuser_id, title=request.form.get('title', False), description=request.form.get( 'description', False), cat_id=request.form.get('id', False)) session.add(new_item) session.commit() flash('New item created!') return redirect(url_for('pcatalog')) else: return render_template('newItem.html', categories=categories)
def updateSteamPageDeferred(): # get items items = Items.query().fetch() # iterate items for item in items: # steam price URL not found if (item.item_steamPriceURL == None or item.item_steamPriceURL.strip() == ''): # search steam searchList = Steam.searchSteam(item.item_name) # add all names to array and item names to dictionary by name nameList = [] searchDictionary = {} for steamItem in searchList: nameList.append(steamItem['name']) searchDictionary[steamItem['name']] = steamItem # get closest matches closestMatches = difflib.get_close_matches(item.item_name, nameList, 1) # match found if (len(closestMatches) != 0): firstMatch = closestMatches[0] logging.info('------ UPDATE STEAM PAGE v2 -------') logging.info(item.item_name) logging.info(searchDictionary[firstMatch]['page']) # update steam price info item.item_steamPriceURL = searchDictionary[firstMatch]['page'] item.item_steamPrice = searchDictionary[firstMatch]['price'] item.put() return HttpResponse('success', mimetype='text/plain', status='200')
def updateImageSize(request): items = Items.query(Items.item_initialProvider == '1').fetch() itemDict = [] if items: for item in items: arr = item.item_largeImage.split('/') arr[0] = 'small' smallString = '/'.join(arr) item.item_largeImage = smallString item.put() itemDict.append(item.item_largeImage) return HttpResponse(json.dumps({'items': itemDict}), mimetype='application/json') return HttpResponse(json.dumps({'status': 'empty'}), mimetype='application/json')
def get_item(request, item): "отдает данные об элементе" return item.get() if item else Items.get_dict()
def get_childs(request, item): "возвращает список дочерних объектов" return item.get_childs() if item else Items.get_root()