Skip to content

Commit

Permalink
✨ Voter eligibility check (#352) (#353)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#234
  • Loading branch information
Findeton authored Aug 8, 2024
1 parent 3d49a2e commit 8849a35
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions iam/api/migrations/0055_force_census_query.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
2 changes: 2 additions & 0 deletions iam/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions iam/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions iam/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8849a35

Please sign in to comment.