From 8849a359b7ca612faf5089de1b1aec850425a4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Robles?= Date: Thu, 8 Aug 2024 10:44:41 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Voter=20eligibility=20check=20(#352?= =?UTF-8?q?)=20(#353)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parent issue: https://github.com/sequentech/meta/issues/234 --- iam/api/migrations/0055_force_census_query.py | 16 ++++++++++++++++ iam/api/models.py | 2 ++ iam/api/tests.py | 1 + iam/api/views.py | 6 ++++++ 4 files changed, 25 insertions(+) create mode 100644 iam/api/migrations/0055_force_census_query.py diff --git a/iam/api/migrations/0055_force_census_query.py b/iam/api/migrations/0055_force_census_query.py new file mode 100644 index 00000000..5d340e4d --- /dev/null +++ b/iam/api/migrations/0055_force_census_query.py @@ -0,0 +1,16 @@ +# Generated by Felix Robles on 2024-07-19 15:14 + +from django.db import migrations, models + +class Migration(migrations.Migration): + dependencies = [ + ('api', '0054_token_duration'), + ] + + operations = [ + migrations.AddField( + model_name='authevent', + name='force_census_query', + field=models.BooleanField(default=False), + ), + ] \ No newline at end of file diff --git a/iam/api/models.py b/iam/api/models.py index 298fbc79..165f0ef7 100644 --- a/iam/api/models.py +++ b/iam/api/models.py @@ -535,6 +535,7 @@ class AuthEvent(models.Model): inside_authenticate_otl_period = models.BooleanField(default=False) has_ballot_boxes = models.BooleanField(default=True) allow_public_census_query = models.BooleanField(default=True) + force_census_query = models.BooleanField(default=True) # allows to hide default login lookup field during the authentication # step. For example, in email authentication it would not show the @@ -661,6 +662,7 @@ def none_list(e): 'has_ballot_boxes': self.has_ballot_boxes, 'tally_status': self.tally_status, 'allow_public_census_query': self.allow_public_census_query, + 'force_census_query': self.force_census_query, 'created': (self.created.isoformat() if hasattr(self.created, 'isoformat') else self.created), diff --git a/iam/api/tests.py b/iam/api/tests.py index 0d76db9b..1a5514ce 100644 --- a/iam/api/tests.py +++ b/iam/api/tests.py @@ -1149,6 +1149,7 @@ def test_get_authevent(self): auth_event = { 'events': { 'allow_public_census_query': False, + 'force_census_query': False, 'alternative_auth_methods': None, 'auth_method': 'email', 'created': '2018-03-29T11:20:30.656486+00:00', diff --git a/iam/api/views.py b/iam/api/views.py index e0a10f6f..80725d72 100644 --- a/iam/api/views.py +++ b/iam/api/views.py @@ -1699,6 +1699,11 @@ def post(request, pk=None): return json_response( status=400, error_codename="INVALID_PUBLIC_CENSUS_QUERY") + force_census_query = req.get('force_census_query', False) + if not isinstance(force_census_query, bool): + return json_response( + status=400, + error_codename="INVALID_FORCE_CENSUS_QUERY") based_in = req.get('based_in', None) if ( @@ -1765,6 +1770,7 @@ def post(request, pk=None): has_ballot_boxes=has_ballot_boxes, hide_default_login_lookup_field=hide_default_login_lookup_field, allow_public_census_query=allow_public_census_query, + force_census_query=force_census_query, support_otl_enabled=support_otl_enabled, alternative_auth_methods=alternative_auth_methods, scheduled_events=scheduled_events,