From 9139e6beb0bf32ec0d475464b443a54aaac577ee Mon Sep 17 00:00:00 2001 From: JOHNMWASHUMA Date: Thu, 14 Nov 2024 14:09:46 +0200 Subject: [PATCH] Remove total of field 5 and 7 from form to be handled by quarantine trigger --- tally_ho/apps/tally/forms/recon_form.py | 22 ------------------- .../apps/tally/tests/forms/test_recon_form.py | 17 -------------- 2 files changed, 39 deletions(-) diff --git a/tally_ho/apps/tally/forms/recon_form.py b/tally_ho/apps/tally/forms/recon_form.py index 6ce23cc9b..b1df999bd 100644 --- a/tally_ho/apps/tally/forms/recon_form.py +++ b/tally_ho/apps/tally/forms/recon_form.py @@ -1,7 +1,5 @@ -from django import forms from django.forms import ModelForm from tally_ho.apps.tally.models import ReconciliationForm -from django.utils.translation import gettext_lazy as _ disable_copy_input = { @@ -54,23 +52,3 @@ def __init__(self, *args, **kwargs): class_str, self.fields[field].widget.attrs.get('class')) self.fields[field].widget.attrs['class'] = class_str - def clean(self): - """Verify that the total of field number_cancelled_ballots and - field number_ballots_inside_box match the value of field - total_of_cancelled_ballots_and_ballots_inside_box - """ - if self.is_valid(): - cleaned_data = super(ReconForm, self).clean() - number_cancelled_ballots =\ - cleaned_data.get('number_cancelled_ballots') - number_ballots_inside_box =\ - cleaned_data.get('number_ballots_inside_box') - total_of_cancelled_ballots_and_ballots_inside_box =\ - cleaned_data.get( - 'total_of_cancelled_ballots_and_ballots_inside_box') - - if (number_cancelled_ballots + number_ballots_inside_box) !=\ - total_of_cancelled_ballots_and_ballots_inside_box: - raise forms.ValidationError( - _('Total of fied 5 and 7 is incorrect')) - return cleaned_data diff --git a/tally_ho/apps/tally/tests/forms/test_recon_form.py b/tally_ho/apps/tally/tests/forms/test_recon_form.py index 36e0a2bc3..c31a96ace 100644 --- a/tally_ho/apps/tally/tests/forms/test_recon_form.py +++ b/tally_ho/apps/tally/tests/forms/test_recon_form.py @@ -1,7 +1,6 @@ from tally_ho.libs.tests.test_base import TestBase, create_result_form from tally_ho.libs.permissions import groups from tally_ho.apps.tally.forms.recon_form import ReconForm -from django.utils.translation import gettext_lazy as _ class ReconFormTest(TestBase): def setUp(self): @@ -47,22 +46,6 @@ def test_missing_required_fields(self): self.assertFalse(form.is_valid()) self.assertIn('number_valid_votes', form.errors) - def test_custom_clean_validation(self): - """Test that custom validation in clean method raises error with - incorrect totals.""" - invalid_data = self.valid_data.copy() - invalid_data['total_of_cancelled_ballots_and_ballots_inside_box'] =\ - 999 # Invalid total - form = ReconForm(data=invalid_data) - self.assertFalse(form.is_valid()) - - # Convert the error messages to strings for comparison - error_messages = [str(err) for err in form.errors['__all__']] - - # Check if the expected error message is in the error messages - self.assertIn( - str(_('Total of fied 5 and 7 is incorrect')), error_messages) - def test_disable_copy_paste_attributes(self): """Test that the copy/paste attributes are disabled on all form fields."""