def bind_runtime_fields(self, g, ticket=None): self.product.queryset = Product.get_all_products(g.organization._id) self.owner.queryset = User.get_all_users(g.organization._id) if ticket is not None: self.tid.data = ticket.id else: self.owner.default = unicode(g.user.id)
def prompt_product(prompt="Enter a product ID: "): while True: product_id = raw_input(prompt) if product_id is not "": product = Product.get_product(product_id) if product is not None: return product
def find_product(product_name, product_organization): product = Product.objects(name=product_name, organization=product_organization) if product is None: return None else: return product
def product_save(): form = ProductForm(request.form) if form.validate(): if len(form.pid.data) > 0: # Existing product product = Product.get_product(form.pid.data) else: # New product product = Product() product.organization = g.organization product.active = True form.populate_obj(product) product.save() return redirect(url_for('management.products_browse')) else: print "WTF?!" print form.errors return render_template('management/products/edit_product.html', form=form)
def product_edit(id): form = ProductForm(request.form, Product.get_product(id)) form.pid.data = id return render_template('management/products/edit_product.html', form=form)
def products_browse(): products = Product.get_all_products(g.organization._id) return render_template('management/products/browse_products.html', products=products)