Skip to content

Commit

Permalink
Django survey form added
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsaw committed Aug 11, 2016
1 parent ae8802d commit 412cace
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 0 deletions.
Empty file.
Binary file added AdamJacobs/Django/survey_form/__init__.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions AdamJacobs/Django/survey_form/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Binary file added AdamJacobs/Django/survey_form/admin.pyc
Binary file not shown.
7 changes: 7 additions & 0 deletions AdamJacobs/Django/survey_form/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import unicode_literals

from django.apps import AppConfig


class SurveyFormConfig(AppConfig):
name = 'survey_form'
Empty file.
Binary file not shown.
5 changes: 5 additions & 0 deletions AdamJacobs/Django/survey_form/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import unicode_literals

from django.db import models

# Create your models here.
Binary file added AdamJacobs/Django/survey_form/models.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#main{
margin:0px auto;
width:300px;
border:1px solid black;
padding-left:20px;
}
30 changes: 30 additions & 0 deletions AdamJacobs/Django/survey_form/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Survey Form</title>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'survey_form/css/style.css' %}">
</head>
<body>
<div id='main'>
<form action='/process' method='post'>
{% csrf_token %}
<p>Your Name:<input type='text' name='name'></p>
<p>Dojo Location:<select name='location'>
<option value='Seattle'>Seattle</option>
<option value='Washington, D.C.'>Washington, D.C.</option>
<option value='Somehwere in Cali'>Somewhere in Cali</option>
</select></p>
<p>Favorite Language:<select name='language'>
<option value='java'>java</option>
<option value='python'>python</option>
<option value='ruby'>ruby</option>
</select></p>
<p>Comment(optional:)</p>
<textarea name='comment'>
</textarea>
<input type='submit' value='submit'>
</form>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions AdamJacobs/Django/survey_form/templates/results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Results</title>
</head>
<body>
<div id='infobox'>
<p>Thanks for submitting this form! You have submitted this form {{ request.session.run }} times now.</p>
</div>
<div id='submission'>
<h4>Submitted Information</h4>
<p>Name: {{ request.session.name }}</p>
<p>Dojo Location: {{ request.session.location }}</p>
<p>Favorite Language: {{ request.session.language }}</p>
<p>Comment: {{ request.session.comment }}</p>
</div>
<p><a href='/survey'>Go Back</a></p>
</body>
</html>
3 changes: 3 additions & 0 deletions AdamJacobs/Django/survey_form/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
8 changes: 8 additions & 0 deletions AdamJacobs/Django/survey_form/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.conf.urls import url
from . import views

urlpatterns = [
url(r'^survey$', views.index),
url(r'^survey/results$', views.results),
url(r'^process$', views.process)
]
Binary file added AdamJacobs/Django/survey_form/urls.pyc
Binary file not shown.
26 changes: 26 additions & 0 deletions AdamJacobs/Django/survey_form/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.shortcuts import render, redirect

# Create your views here.
def index(request):
if 'run' in request.session:
pass
else:
request.session['run'] = 0
return render(request, 'index.html')

def results(request):
return render(request, 'results.html')

def process(request):
if request.method == 'POST':
request.session['name'] = request.POST['name']
request.session['location'] = request.POST['location']
request.session['language'] = request.POST['language']
if request.POST['comment']:
request.session['comment'] = request.POST['comment']
else:
request.session['comment'] = None
request.session['run'] += 1
return redirect('/survey/results')
else:
return redirect('/survey')
Binary file added AdamJacobs/Django/survey_form/views.pyc
Binary file not shown.

0 comments on commit 412cace

Please sign in to comment.