本文整理汇总了Python中models.Product.all方法的典型用法代码示例。如果您正苦于以下问题:Python Product.all方法的具体用法?Python Product.all怎么用?Python Product.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def get(self, category=None):
if self.request.get('offset'):
offset = int(self.request.get('offset'))
else:
offset = 0
if self.request.get('limit'):
limit = int(self.request.get('limit'))
else:
limit = 15
if category:
products = Product.all().order('-created').filter('category =', category).fetch(limit, offset=offset)
else:
products = Product.all().order('-created').fetch(limit, offset=offset)
self.render_template('get_read', { 'products' : products, 'offset' : offset, 'limit' : limit, 'category' : category })
示例2: get
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def get(self, subdomain):
namespace_manager.set_namespace(subdomain)
products = Product.all()
context = {
'url':webapp2.uri_for('addproducts'),
'products':products
}
self.render_response('admin-products.html',**context)
示例3: warning_of_prod
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def warning_of_prod():
""""""
l = []
for store in Store.all():
for prod in Product.all():
report = last_report_store_prod(store.name, prod.name)
try:
if report.remaining < Config.nb_warning:
l.append(report)
except AttributeError:
pass
return l
示例4: get
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def get(self, subdomain):
'''query'''
search = self.request.get('search_input')
'''Changing namespace'''
namespace_manager.set_namespace(subdomain)
''''''
query = Product.all().search(search)
context = {'products':query,
'imagelinker':image_linker}
self.render_response('search-result.html',**context)
示例5: write_product_xls
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def write_product_xls(file_name, data):
''' Export data '''
# Principe
# write((nbre ligne - 1), nbre colonne, "contenu", style(optionnel).
# write_merge((nbre ligne - 1), (nbre ligne - 1) + nbre de ligne
# à merger, (nbre de colonne - 1), (nbre de colonne - 1) + nbre
# de colonne à merger, u"contenu", style(optionnel)).
book = xlwt.Workbook(encoding='ascii')
sheet = book.add_sheet(u"Rapports")
sheet.col(0).width = 0x0d00 * 2
sheet.col(1).width = 0x0d00 * 4
sheet.col(2).width = 0x0d00 * 2
rowx = 0
sheet.write_merge(rowx, rowx + 1, 0, 3,
u"Rapports de gestion de stock %s" % Config.NAME_ORGA, style_title)
rowx += 3
sheet.write_merge(rowx, rowx, 1, 2, u"Date du rapport: ", style)
rowx += 1
title = [u"Code", u"Article", u"Nombre de pièce", u""]
for colx, val_center in enumerate(title):
sheet.write(rowx, colx, val_center, style_t_table)
rowx += 1
for prod in Product.all():
if int(rowx) % 2 == 0:
style_row_table = style1
else:
style_row_table = style2
sheet.write(rowx, 0, prod.code, style_row_table)
sheet.write(rowx, 1, prod.name, style_row_table)
sheet.write(rowx, 2, prod.number_parts_box, style_row_table)
# sheet.write(rowx, 3, '[u"%s",u"%s"],' % (prod.code, prod.name))
rowx += 1
book.save(file_name)
return file_name
示例6: __init__
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def __init__(self, report, parent, *args, **kwargs):
QtGui.QDialog.__init__(self, parent, *args, **kwargs)
self.setWindowTitle(u"Modification")
self.title = FPageTitle(u"Vous le vous modifié ?")
self.op = report
vbox = QtGui.QVBoxLayout()
self.qty_use = QtGui.QLineEdit(str(self.op.qty_use))
self.qty_use.setValidator(QtGui.QIntValidator())
self.date_ = FormatDate(QtCore.QDate(self.op.date))
self.time = QtGui.QDateTimeEdit(QtCore.QTime.currentTime())
formbox = QtGui.QVBoxLayout()
editbox = QtGui.QGridLayout()
formbox.addWidget(FBoxTitle(u"Modification"))
# Combobox widget
i = 0
self.liste_type = Reports.TYPES
self.box_type = QtGui.QComboBox()
for index in xrange(0, len(self.liste_type)):
ty = self.liste_type[index]
if ty == self.op.type_:
i = index
sentence = u"%(type_)s" % {'type_': ty}
self.box_type.addItem(sentence, QtCore.QVariant(ty))
self.box_prod.setCurrentIndex(i)
# Combobox widget
# self.liste_store = Store.order_by(desc(Store.id)).all()
# self.box_mag = QtGui.QComboBox()
# for index in xrange(0, len(self.liste_store)):
# op = self.liste_store[index]
# sentence = _(u"%(name)s") % {'name': op.name}
# self.box_mag.addItem(sentence, QtCore.QVariant(op.id))
# Combobox widget
self.liste_product = Product.all()
self.box_prod = QtGui.QComboBox()
for index in xrange(0, len(self.liste_product)):
op = self.liste_product[index]
if op == self.op.product.article:
i = index
sentence = u"%(article)s" % {'article': op.article}
self.box_prod.addItem(sentence, QtCore.QVariant(op.id))
self.box_prod.setCurrentIndex(i)
editbox.addWidget(QtGui.QLabel(u"Type"), 0, 0)
editbox.addWidget(self.box_type, 1, 0)
# editbox.addWidget(QtGui.QLabel((_(u"Store"))), 0, 1)
# editbox.addWidget(self.box_mag, 1, 1)
editbox.addWidget(QtGui.QLabel(u"Produit"), 0, 2)
editbox.addWidget(self.box_prod, 1, 2)
editbox.addWidget(QtGui.QLabel(u"Quantité"), 0, 3)
editbox.addWidget(self.qty_use, 1, 3)
editbox.addWidget(QtGui.QLabel((u"Date")), 0, 4)
editbox.addWidget(self.date_, 1, 4)
butt = Button(u"Enregistrer")
butt.clicked.connect(self.edit_report)
cancel_but = Button(u"Annuler")
cancel_but.clicked.connect(self.cancel)
editbox.addWidget(butt, 2, 3)
editbox.addWidget(cancel_but, 2, 4)
formbox.addLayout(editbox)
vbox.addLayout(formbox)
self.setLayout(vbox)
示例7: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def set_data_for(self, *args):
rest = self.restor_pew_order()
self.data = [(2 if prod.name in rest.keys() else 0,
rest[prod.name] if prod.name in rest.keys() else "",
prod.name, prod.code) for prod in Product.all()]
示例8: __init__
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def __init__(self, table_p, report, parent, *args, **kwargs):
QDialog.__init__(self, parent, *args, **kwargs)
self.setWindowTitle(u"Modification")
self.table_p = table_p
self.rpt = report
self.parent = parent
self.out_op = True
if self.rpt.type_ == Report.E:
self.out_op = False
self.selling_price_field = IntLineEdit(unicode(self.rpt.selling_price))
self.cost_buying_field = IntLineEdit(unicode(self.rpt.cost_buying))
self.qty_field = IntLineEdit(unicode(self.rpt.qty))
self.date_field = FormatDate(QDate(self.rpt.date))
self.date_field.setEnabled(False)
butt = Button(u"Mise à jour")
butt.clicked.connect(self.edit_report)
cancel_but = Button(u"Annuler")
cancel_but.clicked.connect(self.cancel)
# Combobox widget
i = 0
self.liste_type = [Report.E, Report.S]
self.box_type = QComboBox()
self.box_type.setEnabled(False)
for index in xrange(0, len(self.liste_type)):
ty = self.liste_type[index]
if ty == self.rpt.type_:
i = index
sentence = u"%(ty)s" % {'ty': ty}
self.box_type.addItem(sentence, ty)
self.box_type.setCurrentIndex(i)
# Combobox widget
# self.liste_store = Store.order_by(desc(Store.id)).all()
# self.box_mag = QComboBox()
# for index in xrange(0, len(self.liste_store)):
# op = self.liste_store[index]
# sentence = u"%(name)s" % {'name': op.name}
# self.box_mag.addItem(sentence, QVariant(op.id))
# Combobox widget
self.liste_product = Product.all()
self.box_prod_field = QComboBox()
self.box_prod_field.setEnabled(False)
for index in xrange(0, len(self.liste_product)):
prod = self.liste_product[index]
if prod.name == self.rpt.product.name:
i = index
sentence = u"%(name)s" % {'name': prod.name}
self.box_prod_field.addItem(sentence, prod.id)
self.box_prod_field.setCurrentIndex(i)
vbox = QVBoxLayout()
formbox = QFormLayout()
# editbox.addWidget(FormLabel((_(u"Store"))), 0, 1)
# editbox.addWidget(self.box_mag, 1, 1)
formbox.addRow(FormLabel(u"Type"), FormLabel(self.rpt.type_))
formbox.addRow(FormLabel(u"Désignation"), self.box_prod_field)
formbox.addRow(FormLabel(u"Quantité"), self.qty_field)
formbox.addRow(FormLabel("Prix d'achat"), self.cost_buying_field)
formbox.addRow(FormLabel("Prix vente"), self.selling_price_field)
formbox.addRow(FormLabel(u"Date"), self.date_field)
formbox.addRow(butt, cancel_but)
vbox.addLayout(formbox)
self.setLayout(vbox)
示例9: index
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import all [as 别名]
def index(request, *args):
"Index page - show available products"
return render_to_response('store/index.html', {
'products': Product.all()
}, RequestContext(request))