Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Coded the use case described in #1

  • Loading branch information...
commit 9e7356821a61199b98d56890dac9cc227033fcd1 1 parent 0c4e9ce
@jpic jpic authored
View
29 test_project/templates/home.html
@@ -0,0 +1,29 @@
+{% extends 'admin/base_site.html' %}
+
+{% block content %}
+<h2>Simulate long running request</h2>
+
+Set an amount of seconds and focusout of this field:
+<input name="seconds" />
+{% endblock %}
+
+{% block footer %}
+{{ block.super }}
+<script type="text/javascript">
+ $(document).ready(function(){
+ function longRunningRequest() {
+ $.get(
+ '{% url "sleep" %}',
+ {seconds: $('input[name=seconds]').val()},
+ function(data, textStatus, jqXHR) {
+ longRunningRequest();
+ }
+ )
+ }
+
+ $('input[name=seconds]').blur(function() {
+ longRunningRequest()
+ });
+ });
+</script>
+{% endblock %}
View
20 test_project/test_project/urls.py
@@ -1,18 +1,24 @@
+import time
+
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
-urlpatterns = patterns('',
- # Examples:
- # url(r'^$', 'test_project.views.home', name='home'),
- # url(r'^test_project/', include('test_project.foo.urls')),
+from django.contrib.auth.decorators import login_required
+from django.views import generic
- # Uncomment the admin/doc line below to enable admin documentation:
- # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
- # Uncomment the next line to enable the admin:
+class SleepView(generic.TemplateView):
+ def get(self, request, *args, **kwargs):
+ time.sleep(int(request.GET.get('seconds', 0)))
+ return super(SleepView, self).get(request, *args, **kwargs)
+
+urlpatterns = patterns('',
+ url(r'^$', generic.TemplateView.as_view(template_name='home.html')),
+ url(r'^sleep/$', login_required(
+ SleepView.as_view(template_name='home.html')), name='sleep'),
url(r'^admin/', include(admin.site.urls)),
url(r'session_security/', include('session_security.urls')),
)
Please sign in to comment.
Something went wrong with that request. Please try again.