Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions tally_ho/apps/tally/models/result_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,107 @@ def candidates(self):
def get_action_button(self):
return get_result_form_edit_delete_links(self) if self else None

@classmethod
def get_pending_intake_for_station(
cls, tally_id, center_code, station_number):
"""
Returns a queryset of forms pending intake for a specific station.

:param tally_id: The ID of the tally.
:param center_code: The code of the center.
:param station_number: The station number.

:returns: A queryset of forms pending intake for the specific station.
"""
if not center_code or station_number is None:
return cls.objects.none()
return cls.objects.filter(
tally__id=tally_id,
center__code=center_code,
station_number=station_number,
form_state=FormState.UNSUBMITTED
).select_related(
'ballot', 'ballot__electrol_race'
).order_by('ballot__number')

@classmethod
def get_intaken_for_station(cls, tally_id, center_code, station_number):
"""
Returns a queryset of forms already intaken for a specific station.

:param tally_id: The ID of the tally.
:param center_code: The code of the center.
:param station_number: The station number.

:returns: A queryset of forms already intaken for the specific station.
"""
if not center_code or station_number is None:
return cls.objects.none()
intaken_states = [
FormState.DATA_ENTRY_1,
FormState.DATA_ENTRY_2,
FormState.CORRECTION,
FormState.QUALITY_CONTROL,
FormState.ARCHIVED,
FormState.AUDIT
]
return cls.objects.filter(
tally__id=tally_id,
center__code=center_code,
station_number=station_number,
form_state__in=intaken_states
).select_related(
'ballot', 'ballot__electrol_race'
).order_by('ballot__number')

@classmethod
def get_pending_intake_for_center(cls, tally_id, center_code):
"""
Returns a queryset of forms pending intake for a specific center.

:param tally_id: The ID of the tally.
:param center_code: The code of the center.

:returns: A queryset of forms pending intake for the specific center.
"""
if not center_code:
return cls.objects.none()
return cls.objects.filter(
tally__id=tally_id,
center__code=center_code,
form_state=FormState.UNSUBMITTED
).select_related(
'ballot', 'ballot__electrol_race', 'center', 'office'
).order_by('station_number', 'ballot__number')

@classmethod
def get_intaken_for_center(cls, tally_id, center_code):
"""
Returns a queryset of forms already intaken for a specific center.

:param tally_id: The ID of the tally.
:param center_code: The code of the center.

:returns: A queryset of forms already intaken for the specific center.
"""
if not center_code:
return cls.objects.none()
intaken_states = [
FormState.DATA_ENTRY_1,
FormState.DATA_ENTRY_2,
FormState.CORRECTION,
FormState.QUALITY_CONTROL,
FormState.ARCHIVED,
FormState.AUDIT
]
return cls.objects.filter(
tally__id=tally_id,
center__code=center_code,
form_state__in=intaken_states
).select_related(
'ballot', 'ballot__electrol_race', 'center', 'office'
).order_by('station_number', 'ballot__number')

@classmethod
def distinct_filter(self, qs, tally_id=None):
"""Add a distinct filter onto a queryset.
Expand Down
101 changes: 50 additions & 51 deletions tally_ho/apps/tally/templates/center_details.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
{% load i18n %}

<div class="row">
<div class="container">

<div class="container">
<h3>{% trans 'Polling Center Details' %}</h3>
<hr>

<table class="table table-bordered pull-left infotable">
<tr>
<td width="40%">
{% trans 'Barcode:' %}
</td>
<td>
{{ result_form.barcode }}
</td>
</tr>
<tr>
<td width="40%">{% trans 'Region Name:' %}</td>
<td width="">{{ result_form.center.office.region.name }}</td>
</tr>
<tr>
<td width="40%">{% trans 'Office Name:' %}</td>
<td width="">{{ result_form.center.office.name }}</td>
</tr>
<tr>
<td>{% trans 'Center Name:' %}</td>
<td>{{ result_form.center.name }}</td>
</tr>
<tr>
<td>{% trans 'Election Level:' %}</td>
<td>{{ result_form.ballot.electrol_race.election_level }}</td>
</tr>
<tr>
<td>{% trans 'Sub Race Type:' %}</td>
<td>{{ result_form.ballot.electrol_race.ballot_name }}</td>
</tr>
</table>
<table class="table table-bordered pull-right infotable">
<tr>
<td width="40%">
{% trans 'Voting District:' %}
</td>
<td>
{{ result_form.center.sc_code }}
</td>
</tr>
<tr>
<td width="40%">{% trans 'Center Code:' %}</td>
<td>{{ result_form.center.code }}</td>
</tr>
<tr>
<td>{% trans 'Station Code:' %}</td>
<td>{{ result_form.station_number }}</td>
</tr>
</table>
</div>
<table class="table table-bordered pull-left infotable">
<tr>
<td width="40%">
{% trans 'Barcode:' %}
</td>
<td>
{{ result_form.barcode }}
</td>
</tr>
<tr>
<td width="40%">{% trans 'Region Name:' %}</td>
<td width="">{{ result_form.center.office.region.name }}</td>
</tr>
<tr>
<td width="40%">{% trans 'Office Name:' %}</td>
<td width="">{{ result_form.center.office.name }}</td>
</tr>
<tr>
<td>{% trans 'Center Name:' %}</td>
<td>{{ result_form.center.name }}</td>
</tr>
<tr>
<td>{% trans 'Election Level:' %}</td>
<td>{{ result_form.ballot.electrol_race.election_level }}</td>
</tr>
<tr>
<td>{% trans 'Sub Race Type:' %}</td>
<td>{{ result_form.ballot.electrol_race.ballot_name }}</td>
</tr>
</table>
<table class="table table-bordered pull-right infotable">
<tr>
<td width="40%">
{% trans 'Voting District:' %}
</td>
<td>
{{ result_form.center.sc_code }}
</td>
</tr>
<tr>
<td width="40%">{% trans 'Center Code:' %}</td>
<td>{{ result_form.center.code }}</td>
</tr>
<tr>
<td>{% trans 'Station Code:' %}</td>
<td>{{ result_form.station_number }}</td>
</tr>
</table>
</div>
Loading
Loading