feat: add interactive verification test portal and transaction feed
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 31s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 31s
This commit is contained in:
parent
1ff0bd9f93
commit
97435c42ea
7 changed files with 1374 additions and 2 deletions
|
|
@ -50,7 +50,7 @@ ROOT_URLCONF = "docverify.urls"
|
|||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [],
|
||||
"DIRS": [BASE_DIR / "templates"],
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ Including another URLconf
|
|||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from verifier.views import PortalView
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/', include('verifier.urls')),
|
||||
path('', PortalView.as_view(), name='portal_root'),
|
||||
]
|
||||
|
||||
|
|
|
|||
1308
templates/verifier/portal.html
Normal file
1308
templates/verifier/portal.html
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -28,6 +28,8 @@ class VendorAttemptLogSerializer(serializers.ModelSerializer):
|
|||
"vendor_name",
|
||||
"status",
|
||||
"is_success",
|
||||
"data",
|
||||
"raw_response",
|
||||
"error_code",
|
||||
"error_message",
|
||||
"latency_ms",
|
||||
|
|
|
|||
|
|
@ -599,3 +599,23 @@ class VerificationAPITests(TestCase):
|
|||
self.assertEqual(detail_res.data["reference_id"], str(ref_id))
|
||||
self.assertEqual(len(detail_res.data["attempts"]), 1)
|
||||
|
||||
# Verify GET /api/transactions/ (List endpoint)
|
||||
list_url = reverse("verifier:transaction_list")
|
||||
list_res = self.client.get(list_url)
|
||||
self.assertEqual(list_res.status_code, status.HTTP_200_OK)
|
||||
self.assertGreaterEqual(list_res.data["count"], 1)
|
||||
|
||||
def test_portal_view_renders(self):
|
||||
"""Test GET / and /api/portal/ render the verification playground portal."""
|
||||
# Test root path
|
||||
res_root = self.client.get("/")
|
||||
self.assertEqual(res_root.status_code, status.HTTP_200_OK)
|
||||
self.assertContains(res_root, "Tradhox Document Verification Studio")
|
||||
self.assertContains(res_root, "PAN Verification (v5 Recommended)")
|
||||
|
||||
# Test /api/portal/
|
||||
res_portal = self.client.get(reverse("verifier:portal"))
|
||||
self.assertEqual(res_portal.status_code, status.HTTP_200_OK)
|
||||
self.assertContains(res_portal, "Test Execution Console")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,18 @@
|
|||
from django.urls import path
|
||||
from .views import DocumentVerifyView, VendorListView, TransactionDetailView
|
||||
from .views import (
|
||||
DocumentVerifyView,
|
||||
VendorListView,
|
||||
TransactionDetailView,
|
||||
TransactionListView,
|
||||
PortalView,
|
||||
)
|
||||
|
||||
app_name = "verifier"
|
||||
|
||||
urlpatterns = [
|
||||
path("verify/", DocumentVerifyView.as_view(), name="verify_document"),
|
||||
path("vendors/", VendorListView.as_view(), name="list_vendors"),
|
||||
path("transactions/", TransactionListView.as_view(), name="transaction_list"),
|
||||
path("transactions/<uuid:reference_id>/", TransactionDetailView.as_view(), name="transaction_detail"),
|
||||
path("portal/", PortalView.as_view(), name="portal"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -144,3 +144,35 @@ class TransactionDetailView(APIView):
|
|||
|
||||
serializer = VerificationTransactionSerializer(tx)
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
class TransactionListView(APIView):
|
||||
"""
|
||||
GET /api/transactions/
|
||||
Lists recent verification transactions (up to 50) for dashboard/portal monitoring.
|
||||
"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
limit = min(int(request.query_params.get("limit", 25)), 50)
|
||||
txs = VerificationTransaction.objects.prefetch_related("attempts").all()[:limit]
|
||||
serializer = VerificationTransactionSerializer(txs, many=True)
|
||||
return Response({"count": len(serializer.data), "results": serializer.data})
|
||||
|
||||
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class PortalView(TemplateView):
|
||||
"""
|
||||
Renders the interactive testing & inspection studio for all verification features.
|
||||
"""
|
||||
template_name = "verifier/portal.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
vendors = registry.get_all_vendors()
|
||||
context["vendors"] = vendors
|
||||
context["active_vendor_count"] = sum(1 for v in vendors if v.is_active)
|
||||
context["recent_transactions"] = VerificationTransaction.objects.prefetch_related("attempts").all()[:10]
|
||||
return context
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue