本文整理汇总了Python中tally_ho.libs.views.form_state.form_in_state函数的典型用法代码示例。如果您正苦于以下问题:Python form_in_state函数的具体用法?Python form_in_state怎么用?Python form_in_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了form_in_state函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self, *args, **kwargs):
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk)
form_in_state(result_form, [FormState.CORRECTION])
return self.render_to_response(
self.get_context_data(result_form=result_form))
示例2: post
def post(self, *args, **kwargs):
tally_id = kwargs.get('tally_id')
form_class = self.get_form_class()
form = self.get_form(form_class)
post_data = self.request.POST
pk = session_matches_post_result_form(post_data, self.request)
result_form = get_object_or_404(ResultForm, pk=pk, tally__id=tally_id)
form_in_state(result_form, FormState.AUDIT)
if form.is_valid():
user = self.request.user
audit = create_or_get_audit(post_data,
user.userprofile,
result_form,
form)
url = audit_action(audit, post_data, result_form, self.success_url)
return redirect(url, tally_id=tally_id)
else:
return self.render_to_response(self.get_context_data(form=form,
result_form=result_form,
tally_id=tally_id))
示例3: get
def get(self, *args, **kwargs):
tally_id = self.kwargs['tally_id']
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk, tally__id=tally_id)
form_in_state(result_form, [FormState.CORRECTION])
return self.corrections_response(result_form)
示例4: post
def post(self, race_type):
post_data = self.request.POST
pk = session_matches_post_result_form(post_data, self.request)
result_form = get_object_or_404(ResultForm, pk=pk)
form_in_state(result_form, FormState.CORRECTION)
if 'submit_corrections' in post_data:
user = self.request.user
try:
with transaction.atomic():
if result_form.reconciliationform_exists:
save_recon(post_data, user, result_form)
save_component_results(result_form, post_data, user)
save_general_results(result_form, post_data, user)
save_women_results(result_form, post_data, user)
except ValidationError as e:
return self.corrections_response(result_form, u"%s" % e)
except SuspiciousOperation as e:
self.request.session['error_message'] = u"%s" % e
if result_form.form_state == FormState.DATA_ENTRY_1:
result_form.save()
return redirect(self.failed_url)
else:
result_form.form_state = FormState.QUALITY_CONTROL
result_form.save()
return redirect(self.success_url)
else:
return incorrect_checks(post_data, result_form, 'corrections')
示例5: post
def post(self, *args, **kwargs):
tally_id = kwargs.get('tally_id')
form_class = self.get_form_class()
form = self.get_form(form_class)
if form.is_valid():
pk = session_matches_post_result_form(
form.cleaned_data, self.request)
result_form = get_object_or_404(ResultForm,
pk=pk,
tally__id=tally_id)
form_in_state(result_form, [FormState.CORRECTION])
if not result_form.corrections_passed:
raise Exception(_(u"Results do not match."))
save_final_results(result_form, self.request.user)
save_unchanged_final_recon_form(result_form, self.request.user)
result_form.form_state = FormState.QUALITY_CONTROL
result_form.save()
del self.request.session['result_form']
return redirect(self.success_url, tally_id=tally_id)
else:
return self.form_invalid(form)
示例6: post
def post(self, *args, **kwargs):
post_data = self.request.POST
pk = post_data['result_form']
result_form = get_object_or_404(ResultForm, pk=pk)
form_in_state(result_form, FormState.CLEARANCE)
self.request.session['result_form'] = result_form.pk
return redirect(self.success_url)
示例7: get
def get(self, *args, **kwargs):
pk = self.request.session.get("result_form")
result_form = get_object_or_404(ResultForm, pk=pk)
possible_states = states_for_form(self.request.user, result_form)
form_in_state(result_form, possible_states)
return self.render_to_response(self.get_context_data(result_form=result_form))
示例8: get
def get(self, *args, **kwargs):
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk)
form_in_state(result_form, FormState.AUDIT)
problems = result_form.audit.get_problems()
return self.render_to_response(
self.get_context_data(result_form=result_form,
problems=problems))
示例9: get
def get(self, *args, **kwargs):
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk)
possible_states = states_for_form(self.request.user,
[FormState.INTAKE], result_form)
form_in_state(result_form, possible_states)
return self.render_to_response(
self.get_context_data(result_form=result_form, printed_url=reverse(self.printed_url, args=(pk,))))
示例10: get
def get(self, *args, **kwargs):
"""Display print view with a cover for audit if an audit exists
for the form, otherwise with a cover for archive.
"""
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk)
form_in_state(result_form, FormState.QUALITY_CONTROL)
return self.render_to_response(
self.get_context_data(result_form=result_form))
示例11: post
def post(self, *args, **kwargs):
post_data = self.request.POST
pk = post_data['result_form']
result_form = get_object_or_404(ResultForm, pk=pk)
valid_form_state = result_form.form_state
if (valid_form_state == FormState.CLEARANCE or valid_form_state == FormState.CLEARANCE_PENDING_STATE):
form_in_state(result_form, valid_form_state)
self.request.session['result_form'] = result_form.pk
return redirect(self.success_url)
示例12: get
def get(self, *args, **kwargs):
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk)
form_in_state(result_form, FormState.CLEARANCE)
problems = result_form.clearance.get_problems()
return self.render_to_response(
self.get_context_data(result_form=result_form,
problems=problems,
printed_url = reverse(self.printed_url, args = (pk,))))
示例13: post
def post(self, *args, **kwargs):
post_data = self.request.POST
pk = session_matches_post_result_form(post_data, self.request)
result_form = get_object_or_404(ResultForm, pk=pk)
possible_states = states_for_form(self.request.user, result_form)
form_in_state(result_form, possible_states)
result_form.form_state = FormState.AUDIT if result_form.audit else FormState.ARCHIVED
result_form.save()
return redirect(self.success_url)
示例14: get
def get(self, *args, **kwargs):
tally_id = kwargs.get('tally_id')
pk = self.request.session.get('result_form')
result_form = get_object_or_404(ResultForm, pk=pk)
possible_states = states_for_form(self.request.user, result_form)
form_in_state(result_form, possible_states)
check_quarantine(result_form, self.request.user)
return self.render_to_response(
self.get_context_data(result_form=result_form))
示例15: post
def post(self, *args, **kwargs):
tally_id = kwargs.get('tally_id')
post_data = self.request.POST
pk = post_data['result_form']
result_form = get_object_or_404(ResultForm, pk=pk, tally__id=tally_id)
form_in_state(result_form, FormState.AUDIT)
self.request.session['result_form'] = result_form.pk
return redirect(self.success_url, tally_id=tally_id)