Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted to portable app; removed site-specific components #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions manage.py

This file was deleted.

2 changes: 1 addition & 1 deletion survey/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AnswerIntegerInline(AnswerBaseInline):
model= AnswerInteger

class ResponseAdmin(admin.ModelAdmin):
list_display = ('interview_uuid', 'interviewer', 'created')
list_display = ('interview_uuid', 'created')
inlines = [AnswerTextInline, AnswerRadioInline, AnswerSelectInline, AnswerSelectMultipleInline, AnswerIntegerInline]
# specifies the order as well as which fields to act on
readonly_fields = ('survey', 'created', 'updated', 'interview_uuid')
Expand Down
2 changes: 1 addition & 1 deletion survey/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def render(self):
class ResponseForm(models.ModelForm):
class Meta:
model = Response
fields = ('interviewer', 'interviewee', 'conditions', 'comments')
fields = ()

def __init__(self, *args, **kwargs):
# expects a survey object to be passed in initially
Expand Down
11 changes: 7 additions & 4 deletions survey/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse

class Survey(models.Model):
name = models.CharField(max_length=400)
Expand All @@ -13,6 +14,8 @@ def questions(self):
return Question.objects.filter(survey=self.pk)
else:
return None
def get_absolute_url(self):
return reverse ('survey_detail', kwargs={'id': self.pk})

class Category(models.Model):
name = models.CharField(max_length=400)
Expand Down Expand Up @@ -77,10 +80,10 @@ class Response(models.Model):
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
survey = models.ForeignKey(Survey)
interviewer = models.CharField('Name of Interviewer', max_length=400)
interviewee = models.CharField('Name of Interviewee', max_length=400)
conditions = models.TextField('Conditions during interview', blank=True, null=True)
comments = models.TextField('Any additional Comments', blank=True, null=True)
# interviewer = models.CharField('Name of Interviewer', max_length=400)
# interviewee = models.CharField('Name of Interviewee', max_length=400)
# conditions = models.TextField('Conditions during interview', blank=True, null=True)
# comments = models.TextField('Any additional Comments', blank=True, null=True)
interview_uuid = models.CharField("Interview unique identifier", max_length=36)

def __unicode__(self):
Expand Down
163 changes: 0 additions & 163 deletions survey/settings.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% extends 'survey/survey_base.html' %}

{% block body %}

Thanks! Your confirmation code is {{uuid}}. Use this to refer to your response. In case you have any questions, contact {{ email }}
{% endblock %}
{% endblock %}
20 changes: 20 additions & 0 deletions survey/templates/survey/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'survey/survey_base.html' %}

{% block title %}List of Surveys{% endblock %}

{% block body %}

<div id="intro">
<h1>Survey List</h1>

<p>Here is the list of surveys currently available on this website...</p>

<ul>
{% for survey in surveys %}
<a href="{{survey.get_absolute_url}}"><li>{{survey.name}}</li></a>
{% endfor %}
</ul>

</div>

{% endblock %}
59 changes: 59 additions & 0 deletions survey/templates/survey/survey.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% extends 'survey/survey_base.html' %}

{% load static %}
{% load survey_extras %}

{% block body %}

<h1>Welcome to {{survey.name|title}}</h1>
<div class="survey-description">
{{survey.description|safe}}
</div>

<div>
<form action="{% url 'survey_detail' id=survey.id %}" method="post">{% csrf_token %}

<ol class="survey-questions">
{% for category in categories %}
<h3 class="collapsible">{{category|title}}<span></span></h3>
<div class="category-container">
{% for field in response_form %}
{% if field.field.widget.attrs.category == category %}
<li class="q-item" value="{% counter %}">
{% if field.field.required %}
<div class="field-wrapper question-required">
{{ field.errors }}
<span class="asterix"> * </span><label class="label-inline">{{ field.label }}</label>
{% else %}
<div class="field-wrapper">
{{ field.errors }}
<label class="label-inline">{{ field.label }}</label>
{% endif %}
<span class="form-help-text">{{ field.help_text}}</span>
<div class="form-field-body">
{{ field }}
</div>
</div>
</li>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</ol>

<div class="submit-button"><input type="submit" value="I'm done!"></div>
</form>

</div>

{% endblock %}

{% block extrajs %}
<script src="{% static 'js/jquery.collapsible.js' %}"></script>
<script type="text/javascript">
$(document).ready(function() {
//collapsible management
$('.collapsible').collapsible({defaultOpen: 'response_metadata'});
});
</script>
{% endblock %}
35 changes: 35 additions & 0 deletions survey/templates/survey/survey_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}

<!-- Part 1: Wrap all page content here -->
{% block wrapper %}
<div id="wrap">
{% endblock %}

<div class="container" id="container-main">
{% block body %}
{% endblock %}

<div id="push"></div> <!-- #push goes inside container -->
</div> <!-- /container -->
</div> <!-- end #wrap -->

<footer class="footer">
<div class="container">
{% block footer %}
{% endblock %}
</container>
</footer>
<!-- Le javascript -->
<link rel="stylesheet" href="/media/css/flick/jquery-ui-1.9.1.custom.css" />
<script src="{% static 'js/jquery-1.8.2.js' %}"></script>
<script src="{% static 'js/jquery-ui-1.9.1.custom.js' %}"></script>
<script src="{% static 'js/bootstrap.js' %}"></script>
<script>
// use the jquery UI datepicker on all pages with the datepicker class:
$(".datepicker").datepicker({ minDate: 0});
</script>
{% block extrajs %}
{% endblock %}
{% endblock %}
24 changes: 1 addition & 23 deletions survey/urls.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
import settings

admin.autodiscover()
media_url = settings.MEDIA_URL.lstrip('/').rstrip('/')
from django.conf.urls import patterns, url

urlpatterns = patterns('',
# Examples:
url(r'^$', 'survey.views.Index', name='home'),
url(r'^survey/(?P<id>\d+)/$', 'survey.views.SurveyDetail', name='survey_detail'),
url(r'^confirm/(?P<uuid>\w+)/$', 'survey.views.Confirm', name='confirmation'),
url(r'^privacy/$', 'survey.views.privacy', name='privacy_statement'),


# 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:
url(r'^admin/', include(admin.site.urls)),
)

# media url hackery. le sigh.
urlpatterns += patterns('',
(r'^%s/(?P<path>.*)$' % media_url, 'django.views.static.serve',
{ 'document_root': settings.MEDIA_ROOT, 'show_indexes':True }),
)

Loading