Skip to content

Commit

Permalink
Code clean up and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMwashuma committed Nov 12, 2024
1 parent 7b1da81 commit 07e06cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions tally_ho/apps/tally/views/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def audit_action(audit, post_data, result_form, url):
[ActionsPrior.REQUEST_AUDIT_ACTION_FROM_FIELD,
ActionsPrior.REQUEST_COPY_FROM_FIELD]:
audit.active = True
result_form.reject(new_state=FormState.AUDIT)
result_form.form_state=FormState.AUDIT
result_form.save()
else:
audit.active = False
result_form.reject(new_state=FormState.DATA_ENTRY_1)
Expand Down Expand Up @@ -372,12 +373,12 @@ def post(self, *args, **kwargs):
self.request.user):
possible_states.append(FormState.ARCHIVED)

if result_form.form_state == FormState.AUDIT &\
result_form.audit.active == True &\
result_form.audited_count > 0 &\
result_form.audit.action_prior_to_recommendation in\
if (result_form.form_state == FormState.AUDIT) &\
(result_form.audit.active is True) &\
(result_form.audited_count > 0) &\
(result_form.audit.action_prior_to_recommendation in\
[ActionsPrior.REQUEST_AUDIT_ACTION_FROM_FIELD,
ActionsPrior.REQUEST_COPY_FROM_FIELD]:
ActionsPrior.REQUEST_COPY_FROM_FIELD]):
possible_states.append(FormState.AUDIT)

form = safe_form_in_state(result_form, possible_states, form)
Expand Down
9 changes: 5 additions & 4 deletions tally_ho/apps/tally/views/clearance.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def clearance_action(post_data, clearance, result_form, url):
if clearance.resolution_recommendation ==\
ClearanceResolution.PENDING_FIELD_INPUT:
clearance.active = True
result_form.reject(new_state=FormState.CLEARANCE)
result_form.form_state = FormState.CLEARANCE
result_form.save()

if clearance.resolution_recommendation ==\
ClearanceResolution.RESET_TO_PREINTAKE:
Expand Down Expand Up @@ -382,9 +383,9 @@ def post(self, *args, **kwargs):
self.request.user):
possible_states.append(FormState.ARCHIVED)

if result_form.form_state == FormState.CLEARANCE &\
result_form.clearance.resolution_recommendation ==\
ClearanceResolution.PENDING_FIELD_INPUT:
if (result_form.form_state == FormState.CLEARANCE) &\
(result_form.clearance.resolution_recommendation ==\
ClearanceResolution.PENDING_FIELD_INPUT):
possible_states.append(FormState.CLEARANCE)

form = safe_form_in_state(result_form, possible_states, form)
Expand Down

0 comments on commit 07e06cb

Please sign in to comment.