Permalink
Browse files

First few steps towards Django 1.6 compatibility. Took care of most d…

…eprecrated features and converted builder.py to class based views
  • Loading branch information...
carsongee committed Nov 30, 2013
1 parent e3c9f49 commit 073f2eef907effdb061a74ad8ff7383e0f658dc2
Showing with 993 additions and 796 deletions.
  1. +59 −0 .gitignore
  2. +2 −2 formunculous/__init__.py
  3. +15 −11 formunculous/admin.py
  4. +1 −1 formunculous/fields.py
  5. +1 −1 formunculous/forms.py
  6. +21 −0 formunculous/mixins.py
  7. +3 −3 formunculous/models.py
  8. +1 −1 formunculous/storage.py
  9. +4 −4 formunculous/templates/base.html
  10. +1 −1 formunculous/templates/formunculous/ajax_add_subform.html
  11. +2 −2 formunculous/templates/formunculous/ajax_copy_ad.html
  12. +2 −2 formunculous/templates/formunculous/apply.html
  13. +1 −1 formunculous/templates/formunculous/builder_ad_form.html
  14. +3 −3 formunculous/templates/formunculous/builder_base.html
  15. +9 −9 formunculous/templates/formunculous/builder_edit_fields.html
  16. +10 −10 formunculous/templates/formunculous/builder_index.html
  17. +2 −2 formunculous/templates/formunculous/completed.html
  18. +2 −2 formunculous/templates/formunculous/confirm.html
  19. +1 −1 formunculous/templates/formunculous/denied.html
  20. +1 −1 formunculous/templates/formunculous/includes/sub_app_table.html
  21. +2 −2 formunculous/templates/formunculous/index.html
  22. +3 −3 formunculous/templates/formunculous/notify_reviewers_email.html
  23. +4 −4 formunculous/templates/formunculous/review_application.html
  24. +6 −6 formunculous/templates/formunculous/review_index.html
  25. +3 −3 formunculous/templates/formunculous/review_index_incomplete.html
  26. +4 −4 formunculous/templates/formunculous/review_statistics.html
  27. +1 −1 formunculous/templates/formunculous/tag_apply.html
  28. +1 −1 formunculous/templatetags/__init__.py
  29. +1 −1 formunculous/templatetags/csrf_backport.py
  30. +1 −1 formunculous/templatetags/formunculous_tags.py
  31. +1 −1 formunculous/templatetags/widget_type.py
  32. +104 −35 formunculous/urls.py
  33. +279 −279 formunculous/utils/digg_paginator.py
  34. +1 −1 formunculous/views/__init__.py
  35. +1 −1 formunculous/views/apply.py
  36. +358 −273 formunculous/views/builder.py
  37. +1 −1 formunculous/views/reviewer.py
  38. +2 −2 formunculous/widgets.py
  39. +7 −8 harness/manage.py
  40. +55 −86 harness/settings.py
  41. +3 −26 harness/urls.py
  42. +14 −0 harness/wsgi.py
View
@@ -0,0 +1,59 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
# Django stuff:
*.log
*.pot
# Sphinx documentation
docs/_build/
# etags
TAGS
# Django database
db.sqlite3
Vagrantfile
.vagrant
View
@@ -12,10 +12,10 @@
#
# You should have received a copy of the GNU General Public License
# along with formunculous. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
# This file is part of formunculous.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
VERSION = (2, 2, 5, 'final', 0 )
View
@@ -12,13 +12,15 @@
#
# You should have received a copy of the GNU General Public License
# along with formunculous. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
from django.conf.urls import patterns, url
from django.contrib import admin
from django.conf.urls.defaults import *
from formunculous.models import Form
from django.utils.functional import lazy
from django.core.urlresolvers import reverse
from django.utils.functional import lazy
from django.views.generic import RedirectView
from formunculous.models import Form
reverse_lazy = lazy(reverse, unicode)
@@ -29,15 +31,17 @@ class FormAdmin(admin.ModelAdmin):
"""
def get_urls(self):
urls = patterns('django.views.generic.simple',
url(r'^$', 'redirect_to',
{'url': reverse_lazy('builder-index')},
name="formunculous_applicationdefinition_changelist"),
urls = patterns('',
url(r'^$',
RedirectView.as_view(url=reverse_lazy('builder-index')),
name="formunculous_applicationdefinition_changelist",
),
url(r'^add/$', 'redirect_to',
{'url': reverse_lazy('builder-add-ad')},
name="formunculous_applicationdefinition_add"),
url(r'^add/$',
RedirectView.as_view(url=reverse_lazy('builder-add-ad')),
name="formunculous_applicationdefinition_add",
)
)
return urls
admin.site.register(Form, FormAdmin)
View
@@ -12,7 +12,7 @@
#
# You should have received a copy of the GNU General Public License
# along with formunculous. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
from django.forms import Field, FileField, MultipleChoiceField
from django.forms import ValidationError
View
@@ -12,7 +12,7 @@
#
# You should have received a copy of the GNU General Public License
# along with formunculous. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
from django import forms
from django.db import models
View
@@ -0,0 +1,21 @@
"""
Useful mixins classes for views
"""
from django.contrib.auth.decorators import permission_required
from django.utils.decorators import method_decorator
class ChangeFormMixin(object):
@method_decorator(permission_required('formunculous.change_form'))
def dispatch(self, request, *args, **kwargs):
return super(ChangeFormMixin, self).dispatch(request, *args, **kwargs)
class AddFormMixin(object):
@method_decorator(permission_required('formunculous.add_form'))
def dispatch(self, request, *args, **kwargs):
return super(AddFormMixin, self).dispatch(request, *args, **kwargs)
class DeleteFormMixin(object):
@method_decorator(permission_required('formunculous.delete_form'))
def dispatch(self, request, *args, **kwargs):
return super(DeleteFormMixin, self).dispatch(request, *args, **kwargs)
View
@@ -12,15 +12,15 @@
#
# You should have received a copy of the GNU General Public License
# along with formunculous. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
from django.db import models
from django.contrib.auth.models import User, Group
from django.contrib.sites.models import Site
from django.contrib.contenttypes.models import ContentType
from django.contrib.localflavor.us.forms import USStateSelect
from django.contrib.localflavor.us.models import PhoneNumberField
from localflavor.us.forms import USStateSelect
from localflavor.us.models import PhoneNumberField
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
View
@@ -12,7 +12,7 @@
#
# You should have received a copy of the GNU General Public License
# along with formunculous. If not, see <http://www.gnu.org/licenses/>.
# Copyright 2009-2011 Carson Gee
# Copyright 2009-2013 Carson Gee
from django.core.files.storage import FileSystemStorage
from django.conf import settings
@@ -22,17 +22,17 @@
<body id="{% block body_id %}{% endblock %}">
<div id="formunculous_navigation">
<ul>
<li><a href="{% url formunculous-index %}">Forms</a></li>
<li><a href="{% url 'formunculous-index' %}">Forms</a></li>
{% if perms.formunculous.change_form %}
<li>
<a href="{% url builder-index %}">Builder</a></li>
<a href="{% url 'builder-index' %}">Builder</a></li>
{% endif %}
</ul>
</div>
{% if user.is_authenticated %}
<div id="formunculous_auth"><a href="{% url formunculous-logout %}?next={% url formunculous-index %}">Logout</a></div>
<div id="formunculous_auth"><a href="{% url 'formunculous-logout' %}?next={% url 'formunculous-index' %}">Logout</a></div>
{% else %}
<div id="formunculous_auth"><a href="{% url formunculous-login %}?next={{ request.path }}">Login</a></div>
<div id="formunculous_auth"><a href="{% url 'formunculous-login' %}?next={{ request.path }}">Login</a></div>
{% endif %}
{% block body %}
@@ -6,7 +6,7 @@
<td>{{ subform.max_entries }}</td>
<td>{{ subform.extras }}</td>
<td><a href="" class="formunculous_changelink" onclick="javascript:show_change_dialog({{subform.app_definition.id}});">Change</a></td>
<td><a href="{% url builder-edit-fields subform.app_definition.slug %}" class="formunculous_changelink">Edit Form</a></td>
<td><a href="{% url 'builder-edit-fields' subform.app_definition.slug %}" class="formunculous_changelink">Edit Form</a></td>
<td>
<a href="#" class="formunculous_deletelink"
onclick="javascript:show_delete_dialog({{ subform.app_definition.id }});">
@@ -11,8 +11,8 @@
{{ ad.stop_date|date:"D d M Y" }}
{{ ad.stop_date|time:"g:i A" }}
</td>
<td><a href="{% url builder-edit-ad ad.slug %}" class="formunculous_changelink">Change</a></td>
<td><a href="{% url builder-edit-fields ad.slug %}" class="formunculous_changelink">Edit Form</a></td>
<td><a href="{% url 'builder-edit-ad' ad.slug %}" class="formunculous_changelink">Change</a></td>
<td><a href="{% url 'builder-edit-fields' ad.slug %}" class="formunculous_changelink">Edit Form</a></td>
<td><a href="#" class="formunculous_copylink" onclick="javascript:show_copy_dialog({{ad.id}},'{{ad.slug}}');">Copy</a></td>
<td><a href="#" class="formunculous_previewlink" onclick="javascript:show_preview_dialog({{ad.id}});">Preview</a></td>
<td><a href="#" class="formunculous_deletelink" onclick="javascript:show_delete_dialog({{ad.id}});">Delete</a></td>
@@ -36,7 +36,7 @@
<script type="text/javascript" src="{{ MEDIA_URL }}formunculous/js/csrf.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}formunculous/js/history.js"></script>
<script type="text/javascript">
var historyURL = '{% url formunculous-apply-history %}'
var historyURL = '{% url 'formunculous-apply-history' %}'
</script>
{% endif %}
{% endif %}
@@ -86,7 +86,7 @@
<div class="apply_messages">{{ message }}</div>
{% endif %}
<form method="post" action="{% url formunculous-apply ad.slug %}"{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
<form method="post" action="{% url 'formunculous-apply' ad.slug %}"{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}
{% if form.errors %}
@@ -22,7 +22,7 @@
{% block content %}
<h1>{% if add %}{% trans "New Form Definition" %}{% else %}{% trans "Modifying" %} &mdash; {{ ad.name }}{% endif %}</h1>
<form method="post" action="{% if add %}{% url builder-add-ad %}{% else %}{% url builder-edit-ad form.instance.slug %}{% endif %}">{% csrf_token %}
<form method="post" action="{% if add %}{% url 'builder-add-ad' %}{% else %}{% url 'builder-edit-ad' form.instance.slug %}{% endif %}">{% csrf_token %}
{% if form.errors %}
<div class="apply_field_errors">{% trans "There are errors in your form, please correct them" %}</div>
{% endif %}
@@ -1,16 +1,16 @@
{% extends "admin/base_site.html" %}
{% load i18n %}
{% block extrahead %}{{ block.super }}
{% url admin:jsi18n as jsi18nurl %}
{% url 'admin:jsi18n' as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
{% endblock %}
{% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}<a href="{% url admin:password_change %}">{% trans 'Change password' %}</a> / <a href="{% url admin:logout %}">{% trans 'Log out' %}</a>{% endblock %}
{% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url admin:index %}">Home</a>
<a href="{% url 'admin:index' %}">Home</a>
{% if breadcrumbs %}
{% for crumb in breadcrumbs %}
&#187;
@@ -53,20 +53,20 @@
function show_preview_dialog(id)
{
current_app_id = id;
jQuery("#prev_dialog").html('<iframe height="98%" frameborder="0" width="100%" style="border: 0;" src="{% url builder-preview-ad %}?ad=' + current_app_id + '">Your browser does not support iframes</iframe>');
jQuery("#prev_dialog").html('<iframe height="98%" frameborder="0" width="100%" style="border: 0;" src="{% url 'builder-preview-ad' %}?ad=' + current_app_id + '">Your browser does not support iframes</iframe>');
jQuery("#prev_dialog").dialog('open');
}
// These are rendered with the template for use in the field_edit.js
// and add_subform.js scripts
var new_form_url = "{% url builder-add-field ad.slug %}";
var drop_down_url = "{% url builder-add-dropdown %}";
var new_subapp_url = "{% url builder-add-subapp %}";
var delete_subapp_url = "{% url builder-delete-ad %}";
var change_subapp_url = "{% url builder-change-subapp %}";
var builder_index_url = "{% url builder-index %}";
var new_form_url = "{% url 'builder-add-field' ad.slug %}";
var drop_down_url = "{% url 'builder-add-dropdown' %}";
var new_subapp_url = "{% url 'builder-add-subapp' %}";
var delete_subapp_url = "{% url 'builder-delete-ad' %}";
var change_subapp_url = "{% url 'builder-change-subapp' %}";
var builder_index_url = "{% url 'builder-index' %}";
</script>
@@ -115,11 +115,11 @@ <h4 style="line-height: 1.1em;margin:0;padding:0;">{% trans "Field Types" %}</h4
<div id="ajax_results"></div>
<div id="formunculous-previewdiv">
{% if not is_parent %}
<a href="{% url builder-edit-fields ad.parent.slug %}" class="formunculous_uplink">
<a href="{% url 'builder-edit-fields' ad.parent.slug %}" class="formunculous_uplink">
{% trans "Edit Parent Form" %}
</a>
{% endif %}
<a href="{% if is_parent %}{% url builder-edit-ad ad.slug %}{% else %}{% url builder-edit-ad ad.parent.slug %}{% endif %}" class="formunculous_changelink">
<a href="{% if is_parent %}{% url 'builder-edit-ad' ad.slug %}{% else %}{% url 'builder-edit-ad' ad.parent.slug %}{% endif %}" class="formunculous_changelink">
{% trans "Edit Form Definition" %}
</a>
<a href="#" class="formunculous_previewlink" onclick="javascript:show_preview_dialog({% if is_parent %}{{ ad.id }}{% else %}{{ ad.parent.id }}{% endif %});">
@@ -24,7 +24,7 @@
width: 300,
buttons: {
"OK": function() {
$('#ajax_results').load( '{% url builder-delete-ad %}',
$('#ajax_results').load( '{% url 'builder-delete-ad' %}',
{ ad: current_app_id},
function() {
$('#' + current_app_id).fadeOut(1000,
@@ -52,14 +52,14 @@
// Copy and redirect to ad edit form
"Copy and Edit": function() {
$.ajax({
url: '{% url builder-copy-ad %}',
url: '{% url 'builder-copy-ad' %}',
type: "POST",
data: { ad: current_app_id,
slug: $('#id_copy_slug').attr('value'),
name: $('#id_copy_name').attr('value')},
datatype: "html",
success: function() {
window.location = '{% url builder-index %}/edit/' + $('#id_copy_slug').attr('value');
window.location = '{% url 'builder-index' %}/edit/' + $('#id_copy_slug').attr('value');
},
error: function() {
$('#copy_dialog').dialog('close');
@@ -71,7 +71,7 @@
// Copy and add to AD table
"Copy and Close": function() {
$.ajax({
url: '{% url builder-copy-ad %}',
url: '{% url 'builder-copy-ad' %}',
type: "POST",
data: { ad: current_app_id,
slug: $('#id_copy_slug').attr('value'),
@@ -138,7 +138,7 @@
function show_preview_dialog(id)
{
current_app_id = id;
jQuery("#prev_dialog").html('<iframe height="98%" width="100%" frameborder="0" style="border: 0;" src="{% url builder-preview-ad %}?ad=' + current_app_id + '">Your browser does not support iframes</iframe>');
jQuery("#prev_dialog").html('<iframe height="98%" width="100%" frameborder="0" style="border: 0;" src="{% url 'builder-preview-ad' %}?ad=' + current_app_id + '">Your browser does not support iframes</iframe>');
jQuery("#prev_dialog").dialog('open');
}
@@ -169,7 +169,7 @@ <h1>{% trans "Form Definitions" %}</h1>
<div id="copy_dialog" title="{% trans "Copy Form Definition" %}">
<form method="post" action="{% url builder-copy-ad %}">{% csrf_token %}
<form method="post" action="{% url 'builder-copy-ad' %}">{% csrf_token %}
<fieldset class="apply_fieldset">
<p>
<label for="id_copy_name">New Name: </label><input type="text" id="id_copy_name" name="name" />
@@ -185,8 +185,8 @@ <h1>{% trans "Form Definitions" %}</h1>
<div id="ajax_results">
</div>
<div class="fr">
<a class="formunculous_addlink" href="{% url builder-add-ad %}">{% trans "Create Form Definition" %}</a>
<a class="formunculous_offsitelink" style="margin-left: 10px;" href="{% url formunculous-index %}">{% trans "Form Index" %}</a>
<a class="formunculous_addlink" href="{% url 'builder-add-ad' %}">{% trans "Create Form Definition" %}</a>
<a class="formunculous_offsitelink" style="margin-left: 10px;" href="{% url 'formunculous-index' %}">{% trans "Form Index" %}</a>
</div>
<div style="clear:right"></div>
@@ -227,8 +227,8 @@ <h1>{% trans "Form Definitions" %}</h1>
<td>
{{ ad.stop_date|date:"D d M Y" }}
</td>
<td><a href="{% url builder-edit-ad ad.slug %}" class="formunculous_changelink">Change</a></td>
<td><a href="{% url builder-edit-fields ad.slug %}" class="formunculous_changelink">Edit Form</a></td>
<td><a href="{% url 'builder-edit-ad' ad.slug %}" class="formunculous_changelink">Change</a></td>
<td><a href="{% url 'builder-edit-fields' ad.slug %}" class="formunculous_changelink">Edit Form</a></td>
<td><a href="#" class="formunculous_copylink" onclick="javascript:show_copy_dialog({{ad.id}}, '{{ad.slug}}');">Copy</a></td>
<td><a href="#" class="formunculous_previewlink" onclick="javascript:show_preview_dialog({{ad.id}});">Preview</a></td>
<td><a href="#" class="formunculous_deletelink" onclick="javascript:show_delete_dialog({{ad.id}});">Delete</a></td>
Oops, something went wrong.

0 comments on commit 073f2ee

Please sign in to comment.