diff --git a/opentech/apply/templates/apply/demo_workflow.html b/opentech/apply/templates/apply/demo_workflow.html new file mode 100644 index 0000000000000000000000000000000000000000..bead52923569fb3eb4cda89ea3e90dd022e69412 --- /dev/null +++ b/opentech/apply/templates/apply/demo_workflow.html @@ -0,0 +1,34 @@ +<head> + <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic"> + <link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css"> + <link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css"> +</head> +<body> + <main class="wrapper"> + <nav> + <section class="container"> + <a class="button button-clear" href="{% url 'workflow_demo' 1 %}">Single Stage</a> + <a class="button button-clear" href="{% url 'workflow_demo' 2 %}">Double Stage</a> + </section> + </nav> + <section class="container"> + <h1>Demo of interacting with the workflow</h1> + </section> + <section class="container"> + <h2>{{ workflow}}</h2> + <h3>{{ phase }}</h3> + <form method="post"> + {% csrf_token %} + <input id="current" type="hidden" name="current" value="{{ phase }}" /> + {% for action in phase.action_names %} + <button id="action" name="action" value="{{ action }}">{{ action }}</button> + {% empty %} + <h4>There are no actions</h4> + {% endfor %} + </form> + </section> + <section class="container"> + <a class="button" href="">Reset</a> + </section> + </main> +</body> diff --git a/opentech/apply/urls.py b/opentech/apply/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..9d1bd77962f3ed7588235332bf0f14ffedc8e163 --- /dev/null +++ b/opentech/apply/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import url + +from .views import demo_workflow + +urlpatterns = [ + url(r'^demo/(?P<wf_id>[1-2])/$', demo_workflow, name="workflow_demo") +] diff --git a/opentech/apply/views.py b/opentech/apply/views.py index fd0e0449559b2e00e226cc9f96df7caed44172aa..8d8d5097ccad4628cd6829b532378ed4208f4168 100644 --- a/opentech/apply/views.py +++ b/opentech/apply/views.py @@ -1,3 +1,24 @@ -# from django.shortcuts import render +from django.shortcuts import render +from django.template.response import TemplateResponse + +from .workflow import single_stage, two_stage + + +workflows = [single_stage, two_stage] + + +def demo_workflow(request, wf_id): + workflow = workflows[int(wf_id)-1] + current_phase = request.POST.get('current') + if request.POST: + phase = workflow.process(current_phase, request.POST['action']) + else: + phase = workflow.current(current_phase) + + context = { + 'workflow': workflow, + 'phase': phase, + } + return TemplateResponse(request, 'apply/demo_workflow.html', context) + -# Create your views here. diff --git a/opentech/urls.py b/opentech/urls.py index 9170ff6011991dac7f1b35c16beaf574bf762c50..4adc24202baca49bb2c2af00948994ab85ba87fb 100644 --- a/opentech/urls.py +++ b/opentech/urls.py @@ -10,6 +10,7 @@ from wagtail.wagtailadmin import urls as wagtailadmin_urls from wagtail.wagtailcore import urls as wagtail_urls from wagtail.wagtaildocs import urls as wagtaildocs_urls +from opentech.apply import urls as apply_urls from opentech.esi import views as esi_views from opentech.search import views as search_views @@ -22,6 +23,8 @@ urlpatterns = [ url(r'^search/$', search_views.search, name='search'), url(r'^esi/(.*)/$', esi_views.esi, name='esi'), url('^sitemap\.xml$', sitemap), + + url(r'^apply/', include(apply_urls)), ]