Backdoor testing url for contest form
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 5 Nov 2013 11:22:07 +0000 (12:22 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 15 Jan 2014 10:18:54 +0000 (11:18 +0100)
wtem/urls.py
wtem/views.py

index 1dded94..c78e8bd 100644 (file)
@@ -1,8 +1,9 @@
 from django.conf.urls import patterns, url
 from django.conf import settings
 from django.conf.urls import patterns, url
 from django.conf import settings
-from .views import main, form
+from .views import main, form, form_during
 
 urlpatterns = patterns('',
     url(r'^$', main, name = 'wtem_main'),
 
 urlpatterns = patterns('',
     url(r'^$', main, name = 'wtem_main'),
+    url(r'^_test/(?P<key>.*)/$', form_during),
     url(r'^(?P<key>.*)/$', form, name = 'wtem_form')
 )
     url(r'^(?P<key>.*)/$', form, name = 'wtem_form')
 )
index 1647f09..89bf6c1 100644 (file)
@@ -24,6 +24,11 @@ def form_after(request, key):
     return render(request, 'wtem/main_after.html')
 
 def form_during(request, key):
     return render(request, 'wtem/main_after.html')
 
 def form_during(request, key):
+
+    if WTEM_CONTEST_STAGE != 'during':
+        if request.META['REMOTE_ADDR'] != getattr(settings, 'WTEM_CONTEST_IP_ALLOW', 'xxx'):
+            raise Http404
+
     try:
         submission = Submission.objects.get(key = key)
     except Submission.DoesNotExist:
     try:
         submission = Submission.objects.get(key = key)
     except Submission.DoesNotExist: