Skip to content

Commit 5505477

Browse files
committed
Add option for viewing result form data
1 parent b4d3688 commit 5505477

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

tally_ho/apps/tally/templates/workflow/recall_request_form.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ <h3>{% trans 'Result Form Details' %}</h3>
4949
<br>
5050
<div class="form-actions">
5151
<button type="submit" class="btn btn-primary">{% trans "Submit Recall Request" %}</button>
52+
<a href="{% url 'view_result_form_details_recall' tally_id=tally_id result_form_pk=result_form.pk %}" class="btn btn-info">{% trans "View Form Details" %}</a>
5253
<a href="{% url 'audit_dashboard' tally_id %}" class="btn btn-danger">{% trans "Cancel" %}</a>
5354
</div>
5455
</form>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends 'base.html' %}
2+
{% load i18n %}
3+
4+
{% block content %}
5+
6+
<h1>{% blocktrans with barcode=result_form.barcode %}Details for Result Form: {{ barcode }}{% endblocktrans %}</h1>
7+
8+
{# Display Reconciliation Section if available #}
9+
{% if reconciliation_form %}
10+
<div class="well">
11+
{% include 'quality_control/reconciliation.html' with form=reconciliation_form %}
12+
</div>
13+
{% else %}
14+
<div class="alert alert-info">
15+
{% trans "No reconciliation data available for this form." %}
16+
</div>
17+
{% endif %}
18+
19+
{# Display Results Section #}
20+
<div class="well">
21+
{% include 'quality_control/results.html' with results=results header_text=header_text %}
22+
</div>
23+
24+
{# Back Button #}
25+
<div class="form-actions">
26+
<a href="{% url 'create_recall_request' tally_id=tally_id %}" class="btn btn-secondary">{% trans "Back to Recall Request" %}</a>
27+
</div>
28+
29+
{% endblock %}

tally_ho/apps/tally/views/workflow.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
from django import forms
1010

1111
from tally_ho.apps.tally.forms.barcode_form import BarcodeForm
12+
from tally_ho.apps.tally.forms.recon_form import ReconForm
1213
from tally_ho.apps.tally.forms.workflow_request_forms import (
1314
ApprovalForm, RequestRecallForm
1415
)
1516
from tally_ho.apps.tally.models import ResultForm, WorkflowRequest
1617
from tally_ho.apps.tally.models.audit import Audit
18+
from tally_ho.apps.tally.views.quality_control import result_form_results
1719
from tally_ho.libs.models.enums.form_state import FormState
1820
from tally_ho.libs.models.enums.request_status import RequestStatus
1921
from tally_ho.libs.models.enums.request_type import RequestType
@@ -185,6 +187,41 @@ def get_success_url(self, **kwargs):
185187
return reverse(self.success_url_name, kwargs=kwargs)
186188

187189

190+
class ViewResultFormDetailsView(LoginRequiredMixin,
191+
mixins.TallyAccessMixin,
192+
DetailView):
193+
"""Displays Recon and Results details for a specific ResultForm."""
194+
model = ResultForm
195+
template_name = 'workflow/view_result_form_details.html'
196+
context_object_name = 'result_form'
197+
pk_url_kwarg = 'result_form_pk' # Use result_form_pk from URL
198+
199+
def get_queryset(self):
200+
# Ensure the result form belongs to the correct tally
201+
return super().get_queryset().filter(
202+
tally__id=self.kwargs.get('tally_id'))
203+
204+
def get_context_data(self, **kwargs):
205+
context = super().get_context_data(**kwargs)
206+
result_form = self.get_object()
207+
tally_id = self.kwargs.get('tally_id')
208+
209+
context['tally_id'] = tally_id
210+
context['header_text'] = _('Result Form Details') # Generic header
211+
212+
# Get ReconciliationForm data if available
213+
context['reconciliation_form'] = \
214+
ReconForm(data=forms.model_to_dict(
215+
result_form.reconciliationform
216+
)) if result_form.reconciliationform else None
217+
218+
# Get Results data
219+
# Assuming results are needed similarly to quality control dashboard
220+
context['results'] = result_form_results(result_form=result_form)
221+
222+
return context
223+
224+
188225
class RecallRequestDetailView(LoginRequiredMixin,
189226
WorkflowPermissionMixin,
190227
mixins.TallyAccessMixin,

tally_ho/urls.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
from tally_ho.apps.tally.views.workflow import (
4949
InitiateRecallView,
5050
CreateRecallRequestView,
51-
RecallRequestDetailView
51+
RecallRequestDetailView,
52+
ViewResultFormDetailsView # Import the new view
5253
)
5354

5455
admin.autodiscover()
@@ -1030,6 +1031,11 @@
10301031
re_path(r'^tally/(?P<tally_id>\d+)/workflow/recall/(?P<request_pk>\d+)/$',
10311032
RecallRequestDetailView.as_view(),
10321033
name='recall_request_detail'),
1034+
# New URL for viewing result form details during recall
1035+
re_path(r'^tally/(?P<tally_id>\d+)/workflow/recall/view_details/(?P<result_form_pk>\d+)/$',
1036+
ViewResultFormDetailsView.as_view(),
1037+
name='view_result_form_details_recall'),
1038+
10331039
path('operation-not-allowed',
10341040
home.suspicious_error,
10351041
name='suspicious-error'),

0 commit comments

Comments
 (0)