Commit 21252129 authored by Christophe Siraut's avatar Christophe Siraut

Use class-based generic views.

parent b481507f
......@@ -2,7 +2,7 @@
Nuages - Easy poll sharing
==========================
Nuages aims to provide a collaborative meeting poll system, similar to doodle or rdvz. It is build in python, using the django framework and a little of javascript. This application was named after Django's famous song. Feedback and collaboration are welcome at nuages lists.domainepublic.net
Nuages aims to provide a collaborative meeting poll system, similar to doodle or rdvz. It is build in python, using the django framework and a little of javascript. This application was named after Django's famous song. Feedback and collaboration are welcome at nuages @lists.domainepublic.net
The project uses the following django application:
- django-registration: https://bitbucket.org/ubernostrum/django-registration
......@@ -126,6 +126,6 @@ When models change, we need to perform some manual steps to keep existing data.
# APPS="account auth meetingpoll poll"
# for APP in $APPS; do ./manage.py dumpdata $APP --indent=2 > fixtures/$APP.json; done
# git pull
# ./manage.py reset poll
# ./manage.py flush poll
# ./manage.py loaddata fixtures/*.json
......@@ -10,7 +10,6 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response, render
from django.template import RequestContext
from django.utils.translation import ugettext_lazy as _
from django.views.generic.create_update import update_object
from account.forms import UserProfileForm
from account.views import email_notify
from meetingpoll.forms import PollForm, ChoiceForm, VoteForm, BulletinForm
......@@ -37,16 +36,6 @@ def new(request):
{'form': form},
context_instance=RequestContext(request))
@login_required
def secure_update_object(*args, **kwargs):
"""
Souldn't we provide a better object to the generic view: object_id=poll
and then simple the template
# joe = str(request.user)
# if Poll.objects.get(id=object_id, author=joe):
"""
return update_object(*args, **kwargs)
def get_ordereditem_formset(form, formset=BaseInlineFormSet, **kwargs):
return inlineformset_factory(Poll, Choice, form, formset, **kwargs)
......
from django.conf.urls.defaults import patterns, include, url
from django.conf.urls.i18n import i18n_patterns
from django.contrib.auth.views import login, logout
from django.contrib.auth.decorators import login_required
from django.views.generic import TemplateView, ListView
from django.views.generic.edit import UpdateView
from meetingpoll.models import Poll
from meetingpoll.forms import PollForm
# Uncomment the next two lines to enable the admin:
# Enable the admin:
from django.contrib import admin
admin.autodiscover()
info_dict = {
'queryset': Poll.objects.all(),
}
poll_dict = {
#'model' : Poll,
'form_class' : PollForm,
'post_save_redirect' : '/'
}
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^$', 'django.views.generic.list_detail.object_list', dict(info_dict, template_name='index.html'), name='home'),
url(r'^nuages/$', 'django.views.generic.simple.direct_to_template', {'template': 'nuages.html'}, name='documentation'),
url(r'^languages/$', 'django.views.generic.simple.direct_to_template', {'template': 'languages.html'}, name='languages'),
#url(r'^(?P<lang_id>\w{2})/nuages$', 'meetingpoll.views.translation'),
url(r'^$', ListView.as_view(queryset=Poll.objects.all(), template_name='index.html'), name='home'),
url(r'^nuages/$', TemplateView.as_view(template_name='nuages.html'), name='documentation'),
url(r'^languages/$', TemplateView.as_view(template_name='languages.html'), name='languages'),
url(r'^(?P<poll_id>\w{4})/$', 'meetingpoll.views.vote'),
url(r'^new/$', 'meetingpoll.views.new', name='new'),
url(r'^(?P<object_id>\w+)/edit/$', 'meetingpoll.views.secure_update_object', dict(poll_dict, post_save_redirect='choices/')),
url(r'^(?P<pk>\w+)/edit/$', login_required(UpdateView.as_view(
queryset=Poll.objects.all(),
form_class=PollForm,
success_url='choices/'))),
url(r'^(?P<poll_id>\w+)/delete/$', 'meetingpoll.views.delete'),
url(r'^(?P<poll_id>\w+)/edit/choices/$', 'meetingpoll.views.editchoices', name='choices'),
url(r'^(?P<poll_id>\w{4})/vote/$', 'meetingpoll.views.vote', name='vote'),
......@@ -37,9 +29,11 @@ urlpatterns = patterns('',
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^(?P<poll_id>\w{4})/clear/', 'meetingpoll.userviews.clear_cookie'),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)
urlpatterns += i18n_patterns('',
url(r'^nuages/$', 'django.views.generic.simple.direct_to_template', {'template': 'nuages.html'}, name='documentation_translated'),
url(r'^$', 'django.views.generic.list_detail.object_list', dict(info_dict, template_name='index.html'), name='home_translated'),
url(r'^nuages/$', TemplateView.as_view(template_name='nuages.html'), name='documentation_translated'),
url(r'^$', ListView.as_view(queryset=Poll.objects.all(), template_name='index.html'), name='home_translated'),
)
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% block content %}
......@@ -7,7 +8,7 @@
<p>{% trans "Account successfully activated" %}</p>
<p><a href="{% url auth_login %}">{% trans "Log in" %}</a></p>
<p><a href="{% url 'auth_login' %}">{% trans "Log in" %}</a></p>
{% else %}
......
{% load i18n %}
{% load url from future %}
{% trans "Activate account at" %} {{ site.name }}:
http://{{ site.domain }}{% url registration_activate activation_key %}
http://{{ site.domain }}{% url 'registration_activate activation_key' %}
{% blocktrans %}Link is valid for {{ expiration_days }} days.{% endblocktrans %}
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% block content %}
......@@ -10,6 +11,6 @@
<input type="hidden" name="next" value="{{ next }}" />
</form>
<br />
<p>{% trans "Forgot password" %}? <a href="{% url auth_password_reset %}">{% trans "Reset it" %}</a>!</p>
<p>{% trans "Not member" %}? <a href="{% url registration_register %}">{% trans "Register" %}</a>!</p>
<p>{% trans "Forgot password" %}? <a href="{% url 'auth_password_reset' %}">{% trans "Reset it" %}</a>!</p>
<p>{% trans "Not member" %}? <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>!</p>
{% endblock %}
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% block content %}
<p>{% trans "Password reset successfully" %}</p>
<p><a href="{% url auth_login %}">{% trans "Log in" %}</a></p>
<p><a href="{% url 'auth_login' %}">{% trans "Log in" %}</a></p>
{% endblock %}
{% load i18n %}
{% load url from future %}
{% blocktrans %}Reset password at {{ site_name }}{% endblocktrans %}:
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url auth_password_reset_confirm uidb36=uid, token=token %}
{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uidb36=uid, token=token %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment