From 077240aed664e9875fb96e8f82ceb9511f99111a Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Fri, 19 Jan 2018 12:31:21 +0000
Subject: [PATCH] Hide the round page behind the fund page and allow previewing

---
 opentech/apply/funds/models.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py
index 271e3f157..c5cd0cceb 100644
--- a/opentech/apply/funds/models.py
+++ b/opentech/apply/funds/models.py
@@ -3,6 +3,7 @@ from datetime import date
 from django.core.exceptions import ValidationError
 from django.db import models
 from django.db.models import Q
+from django.http import Http404
 from django.utils.text import mark_safe
 
 from modelcluster.fields import ParentalKey
@@ -66,6 +67,14 @@ class FundType(AbstractStreamForm):
         InlinePanel('forms', label="Forms"),
     ]
 
+    def serve(self, request):
+        if hasattr(request, 'is_preview'):
+            return super().serve(request)
+
+        # delegate to the open_round to use the latest form instances
+        request.show_page = True
+        return self.open_round.serve(request)
+
 
 class FundForm(Orderable):
     form = models.ForeignKey('ApplicationForm')
@@ -150,3 +159,11 @@ class Round(AbstractStreamForm):
                 error['end_date'] = error_message
 
             raise ValidationError(error)
+
+    def serve(self, request):
+        if hasattr(request, 'is_preview') or hasattr(request, 'show_page'):
+            return super().serve(request)
+
+        # We hide the round as only the open round is used which is displayed through the
+        # fund page
+        raise Http404()
-- 
GitLab