本文整理汇总了Python中tally_ho.apps.tally.models.result_form.ResultForm.generate_barcode方法的典型用法代码示例。如果您正苦于以下问题:Python ResultForm.generate_barcode方法的具体用法?Python ResultForm.generate_barcode怎么用?Python ResultForm.generate_barcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tally_ho.apps.tally.models.result_form.ResultForm
的用法示例。
在下文中一共展示了ResultForm.generate_barcode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from tally_ho.apps.tally.models.result_form import ResultForm [as 别名]
# 或者: from tally_ho.apps.tally.models.result_form.ResultForm import generate_barcode [as 别名]
def get(self, *args, **kwargs):
tally_id = kwargs.get('tally_id')
self.initial = {
'tally_id': tally_id,
}
del self.request.session['result_form']
pk = self.request.session.get('result_form')
if pk:
result_form = ResultForm.objects.get(pk=pk, tally__id=tally_id)
else:
tally = Tally.objects.get(id=tally_id)
barcode = ResultForm.generate_barcode(tally_id)
result_form = ResultForm.objects.create(
barcode=barcode,
form_state=FormState.CLEARANCE,
tally=tally)
self.request.session['result_form'] = result_form.pk
form = NewResultForm(instance=result_form)
form_class = self.get_form_class()
form = self.get_form(form_class)
return self.render_to_response(self.get_context_data(
form=form, result_form=result_form, tally_id=tally_id))
示例2: get
# 需要导入模块: from tally_ho.apps.tally.models.result_form import ResultForm [as 别名]
# 或者: from tally_ho.apps.tally.models.result_form.ResultForm import generate_barcode [as 别名]
def get(self, *args, **kwargs):
pk = self.request.session.get('result_form')
if pk:
result_form = ResultForm.objects.get(pk=pk)
else:
barcode = ResultForm.generate_barcode()
result_form = ResultForm.objects.create(
barcode=barcode,
form_state=FormState.CLEARANCE)
self.request.session['result_form'] = result_form.pk
form = NewResultForm(instance=result_form)
form_class = self.get_form_class()
form = self.get_form(form_class)
return self.render_to_response(self.get_context_data(
form=form, result_form=result_form))