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

Making survey more confugurable #2

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1d72eee
* Removing privacy page
Sep 4, 2013
cecce3f
* Improved code (using 4 spaces indentation, etc)
Sep 4, 2013
ed3bcc5
* Improved urls handling
Sep 4, 2013
8500ed0
* Added some translations (fr-FR)
Sep 4, 2013
cc00975
* Separated the app (survey) from the project (survey_test) (It was t…
Sep 4, 2013
c595972
* Updated run server command in readme.md
Sep 5, 2013
a99da01
Merge branch 'master' of https://github.com/jessykate/django-survey
Sep 5, 2013
cc19e84
* Added ImageSelect widget and field type (allow to user to select a …
Sep 20, 2013
8b27c56
* added a field to specify if a survey MUST be filled by a logged user
Sep 21, 2013
586d08f
* Saving the form at the last step for the step by step form.
Oct 3, 2013
266e769
* Added setup.py
Oct 3, 2013
c7f14df
* Updated template path
Oct 3, 2013
3b9bc6d
handling the case where someone has already taken as survey who need …
Oct 10, 2013
5e5adbf
* Added signal to django-survey
Oct 13, 2013
b69090d
* allow to override redirect with session
Aug 3, 2014
f22f5f5
* Deleting session key before redirect
Aug 4, 2014
387f725
* Specific template for one page survey
Aug 4, 2014
6dd049d
* Making sure that dict key exists before deleting it
Aug 5, 2014
3ea8952
* Updated survey
Sep 21, 2014
2e565f1
* Using dynamic login url
Sep 22, 2014
2a3fd9d
* Using dynamic login url (typo)
Sep 22, 2014
7be8c8c
* Updated readme
Aug 18, 2015
77c3d22
* Commit from guillaume
Sep 10, 2015
178e27f
* Moving migrations to south migrations
Sep 10, 2015
65a0981
* Improved setup.py
Sep 10, 2015
89bb3b5
* Creating new Django migrations
Sep 10, 2015
e4606b7
* Adding template field to survey
Sep 10, 2015
97bbec2
* Using survey template if available
Sep 10, 2015
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ media/data
local_settings.py
survey.db

survey.egg-info
13 changes: 7 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Django survey

install requirements using `pip install -r requirements.txt`

then run using `./manage.py runserver`
then run using `./survey_test/manage.py runserver`

## about
## About

Using the admin interface you can create surveys, add questions, give questions
categories, and mark them as required or not. the front-end survey view then
Expand All @@ -11,7 +13,8 @@ admin interface.

Submitted responses can also be viewed via the admin backend.

## credits
## Credits

some inspiration came from an older
[django-survey](https://github.com/flynnguy/django-survey) app, but this app
uses a different model architecture and different mechanism for dynamic form
Expand All @@ -21,6 +24,4 @@ generation.

this code is licensed under the [affero general public license](http://www.gnu.org/licenses/agpl-3.0.html).

The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public... The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a
network server to provide the source code of the modified version running there to the users of that server.
The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public... The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server.
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from setuptools import setup, find_packages

setup(
name="survey",
version="0.1.1",
author="Jessy Kate Schingler",
author_email="[email protected]",
license="AGPL",
url="https://github.com/jessykate/django-survey",
packages=find_packages(exclude=[]),
include_package_data=True,
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Framework :: Django",
]
)
14 changes: 14 additions & 0 deletions survey/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.utils.translation import ungettext, ugettext_lazy

# Actions
def make_published(modeladmin, request, queryset):
"""
Mark the given survey as published
"""
count = queryset.update(is_published=True)
message = ungettext(
u'%(count)d survey was successfully marked as published.',
u'%(count)d surveys were successfully marked as published',
count) % {'count': count,}
modeladmin.message_user(request, message)
make_published.short_description = ugettext_lazy(u"Mark selected surveys as published")
70 changes: 46 additions & 24 deletions survey/admin.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,70 @@
from survey.models import Question, Category, Survey, Response, AnswerText, AnswerRadio, AnswerSelect, AnswerInteger, AnswerSelectMultiple
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

from .models import Question, Category, Survey, Response, AnswerText
from .models import AnswerRadio, AnswerSelect
from .models import AnswerInteger, AnswerSelectMultiple
from .actions import make_published


class QuestionInline(admin.TabularInline):
model = Question
ordering = ('category',)
extra = 0
model = Question
ordering = ('category', 'order',)
extra = 1


class CategoryInline(admin.TabularInline):
model = Category
extra = 0
model = Category
extra = 0


class SurveyAdmin(admin.ModelAdmin):
inlines = [CategoryInline, QuestionInline]
list_display = ('name', 'is_published', 'need_logged_user', 'template')
list_filter = ('is_published', 'need_logged_user')
inlines = [CategoryInline, QuestionInline]
actions = [make_published]


class AnswerBaseInline(admin.StackedInline):
fields = ('question', 'body')
readonly_fields = ('question',)
extra = 0
fields = ('question', 'body')
readonly_fields = ('question',)
extra = 0


class AnswerTextInline(AnswerBaseInline):
model= AnswerText
model = AnswerText


class AnswerRadioInline(AnswerBaseInline):
model= AnswerRadio
model = AnswerRadio


class AnswerSelectInline(AnswerBaseInline):
model= AnswerSelect
model = AnswerSelect


class AnswerSelectMultipleInline(AnswerBaseInline):
model= AnswerSelectMultiple
model = AnswerSelectMultiple


class AnswerIntegerInline(AnswerBaseInline):
model= AnswerInteger
model = AnswerInteger


class ResponseAdmin(admin.ModelAdmin):
list_display = ('interview_uuid', 'interviewer', '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')
list_display = ('interview_uuid', 'survey', 'created', 'user')
list_filter = ('survey', 'created')
date_hierarchy = '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', 'user'
)

#admin.site.register(Question, QuestionInline)
#admin.site.register(Category, CategoryInline)
admin.site.register(Survey, SurveyAdmin)

# admin.site.register(Question, QuestionInline)
# admin.site.register(Category, CategoryInline)
admin.site.register(Survey, SurveyAdmin)
admin.site.register(Response, ResponseAdmin)
Loading