Commit bf4358d5 authored by Christophe Siraut's avatar Christophe Siraut

Change applications names and models. Breaky.

parent 22720d0c
*.sqlite
*.pyc
*~
fix*
settings.py
fixture
staticroot
local_settings.py
......@@ -16,5 +16,5 @@ translation:
lint:
#django-lint
pylint --generated-members=objects,_meta,id sondage
pylint --generated-members=objects,_meta,id meetingpoll
pylint --generated-members=objects,_meta,id accounts
......@@ -4,15 +4,14 @@ 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 nuage@ domainepublic.net
The project uses the following django applications:
The project uses the following django application:
- django-registration: https://bitbucket.org/ubernostrum/django-registration
- django-voting: https://github.com/brosner/django-voting.git
On debian they can be installed as follow:
# aptitude install python-django-registration python-django-voting
# aptitude install python-django-registration
The project uses the following javascripts:
The project uses and provides the following javascripts:
- jquery, jquery-ui: http://www.jquery.com/
- jquery-dynamic-formset: http://code.google.com/p/django-dynamic-formset/
- jquery timepicker addon: https://github.com/trentrichardson/jQuery-Timepicker-Addon
......@@ -129,10 +128,10 @@ Migration
When models change, we need to perform some manual steps to keep existing data:
# mkdir fixture
# ./manage.py dumpdata sondage --indent=2 > fixture/sondage.json
# ./manage.py dumpdata meetingpoll --indent=2 > fixture/meetingpoll.json
# ./manage.py dumpdata accounts --indent=2 > fixture/accounts.json
# git pull
# ./manage.py reset sondage accounts
# ./manage.py reset meetingpoll accounts
# ./manage.py syncdb
# ./manage.py loaddata < fixture/*.json
from accounts.models import UserProfile
from account.models import UserProfile
from django.contrib import admin
admin.site.register(UserProfile)
from django.forms import ModelForm
from accounts.models import UserProfile
from account.models import UserProfile
class UserProfileForm(ModelForm):
class Meta:
......
......@@ -3,7 +3,7 @@ from django.shortcuts import render, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext_lazy
from accounts.forms import UserProfileForm
from account.forms import UserProfileForm
def _(string):
"""ugettext_lazy shortcut"""
......
from sondage.models import Poll, Choice, Bulletin, Vote
from meetingpoll.models import Poll, Choice, Bulletin, Vote
from django.contrib import admin
admin.site.register(Poll)
......
......@@ -6,7 +6,7 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _
def _createId():
# Generate a 4 caracters id
# Random 4 caracters string
return hexlify(os.urandom(2))
class Poll(models.Model):
......@@ -15,9 +15,8 @@ class Poll(models.Model):
title = models.CharField(_('Title'), max_length=80)
pub_date = models.DateField(auto_now_add=True)
upd_date = models.DateField(auto_now=True)
author = models.CharField(max_length=40)
description = models.CharField(max_length=300)
user = models.ForeignKey(User, blank=True, null=True)
user = models.ForeignKey(User, null=True)
def __unicode__(self):
return self.title
......
......@@ -19,6 +19,6 @@ def register(request):
def clear_cookie(request, poll_id):
request.session.clear()
return HttpResponseRedirect(reverse('sondage.views.vote', args=(poll_id,)))
return HttpResponseRedirect(reverse('vote', args=(poll_id,)))
from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404, render_to_response
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.forms.formsets import formset_factory
from django.forms.models import inlineformset_factory, BaseInlineFormSet
from sondage.models import Poll, Choice, Vote, Bulletin
from sondage.forms import PollForm, ChoiceForm, VoteForm, BulletinForm
from django.core.exceptions import ObjectDoesNotExist
from django.views.generic.create_update import update_object
from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from accounts.views import email_notify
from accounts.forms import UserProfileForm
from django.core.exceptions import ObjectDoesNotExist
from meetingpoll.models import Poll, Choice, Vote, Bulletin
from meetingpoll.forms import PollForm, ChoiceForm, VoteForm, BulletinForm
from account.views import email_notify
from account.forms import UserProfileForm
def new(request):
if request.method == 'POST':
if request.user.is_authenticated():
instance = Poll(author=str(request.user), user=request.user)
else:
instance = Poll(author=str(request.user))
form = PollForm(request.POST, instance=instance)
form = PollForm(request.POST)
if form.is_valid():
new_poll = Poll(**form.cleaned_data).save()
key = 'is_' + new_poll.id + '_author'
request.session[key] = True # This writes cookie
redir = '/' + str(new_poll.id) + '/edit/choices/'
return HttpResponseRedirect(redir)
poll = Poll(**form.cleaned_data)
if request.user.is_authenticated():
poll.user = request.user
poll.save()
key = 'is_' + poll.id + '_author'
request.session[key] = True # This writes cookie??
return HttpResponseRedirect(reverse('choices', args=(str(poll.id),)))
else:
form = PollForm() # An unbound form
return render_to_response('sondage/poll_form.html',
{'form': form}, context_instance=RequestContext(request))
form = PollForm()
return render_to_response(
'meetingpoll/poll_form.html',
{'form': form},
context_instance=RequestContext(request))
@login_required
def secure_update_object(*args, **kwargs):
......@@ -55,15 +55,13 @@ def editchoices(request, poll_id):
poll = get_object_or_404(Poll.objects.all(), id=poll_id)
language_code = request.LANGUAGE_CODE
error_message = ''
if poll.author == 'AnonymousUser': # Anonymous wants to edit his new poll
if request.user.is_anonymous(): # Anonymous wants to edit his new poll
key = 'is_' + poll_id + '_author'
if not request.session.get(key, False):
return HttpResponse('')
return HttpResponseRedirect(reverse('home'))
else:
if request.user.is_anonymous():
return HttpResponse('')
if request.user.username != poll.author:
return HttpResponse('')
if request.user != poll.user:
return HttpResponseRedirect(reverse('home'))
OrderedItemFormset = get_ordereditem_formset(ChoiceForm, extra=0, can_delete=True)
......@@ -108,8 +106,7 @@ def editchoices(request, poll_id):
except:
# probably an empty datefield?
pass
redir = '/' + str(poll.id) + '/'
return HttpResponseRedirect(redir)
return HttpResponseRedirect(poll.link)
else:
#vforms=OrderedItemFormset(request.POST, instance=poll)
error_message = _("There are some errors in the form you posted.")
......@@ -123,7 +120,7 @@ def editchoices(request, poll_id):
else:
vforms = OrderedItemFormset(instance=poll)
return render_to_response('sondage/choice_form.html', {'object': poll, 'vforms': vforms, 'error_message' : error_message, 'language_code': language_code,}, context_instance=RequestContext(request))
return render_to_response('meetingpoll/choice_form.html', {'object': poll, 'vforms': vforms, 'error_message' : error_message, 'language_code': language_code,}, context_instance=RequestContext(request))
@login_required
......@@ -131,7 +128,7 @@ def delete(request, poll_id):
poll = get_object_or_404(Poll.objects.all(), id=poll_id)
if poll.author == str(request.user):
if poll.user == request.user:
poll.delete()
return HttpResponseRedirect('/')
......@@ -142,13 +139,11 @@ def make_buletin_form(poll, **kwargs):
def vote(request, poll_id):
error_message = None
poll = get_object_or_404(Poll.objects.all(), id=poll_id)
error_message = None
has_voted = False
if request.method == 'POST':
form = BulletinForm(request.POST, initial={'poll': poll.id,})
vforms = [ [VoteForm(request.POST, prefix=choice, instance=choice) ] for choice in Choice.objects.filter(poll=poll.id) ]
......@@ -278,7 +273,7 @@ def vote(request, poll_id):
form = BulletinForm(instance=poll,initial={'voter': voter})
#form = BulletinForm(instance=poll)
current_site = settings.SITE + poll.id
return render_to_response('sondage/poll_detail.html', {'object': poll, 'form': form, 'vforms':vforms, 'error_message':error_message, 'has_voted': has_voted, 'current_site': current_site}, context_instance=RequestContext(request))
return render_to_response('meetingpoll/poll_detail.html', {'object': poll, 'form': form, 'vforms':vforms, 'error_message':error_message, 'has_voted': has_voted, 'current_site': current_site}, context_instance=RequestContext(request))
def exp_csv(request, poll_id):
import csv
......
......@@ -127,9 +127,8 @@ INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'voting',
'accounts',
'sondage',
'account',
'meetingpoll',
)
try:
......
......@@ -13,7 +13,7 @@
{% block chapeau %}
<h1>{{object}}</h1>
<p class="info">
{{object.description}} <br /> {% trans "Posted by" %} <code> {{object.author}} </code> {% trans "on" %} <code> {{object.pub_date|date:"d F"}}. </code><br /> {% trans "Shared address" %}: <input type="text" name="link" style="border:0;" value="{{ current_site }}/" readonly="readonly" class='adresse' />
{{object.description}} <br /> {% trans "Posted by" %} <code> {% if object.user %}{{object.user}}{% else %}{% trans 'Anonymous' %}{% endif %} </code> {% trans "on" %} <code> {{object.pub_date|date:"d F"}}. </code><br /> {% trans "Shared address" %}: <input type="text" name="link" style="border:0;" value="{{ current_site }}/" readonly="readonly" class='adresse' />
</p>
{% endblock %}
......
from django.conf.urls.defaults import *
from django.contrib.auth.views import login, logout
from sondage.models import Poll
from sondage.forms import PollForm
from meetingpoll.models import Poll
from meetingpoll.forms import PollForm
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
......@@ -23,17 +23,17 @@ urlpatterns = patterns('',
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'^(?P<lang_id>\w{2})/nuages$', 'sondage.views.translation'),
url(r'^(?P<poll_id>\w{4})/$', 'sondage.views.vote'),
url(r'^new/$', 'sondage.views.new', name='new'),
url(r'^(?P<object_id>\w+)/edit/$', 'sondage.views.secure_update_object', dict(poll_dict, post_save_redirect='choices/')),
url(r'^(?P<poll_id>\w+)/delete/$', 'sondage.views.delete'),
url(r'^(?P<poll_id>\w+)/edit/choices/$', 'sondage.views.editchoices'),
url(r'^(?P<poll_id>\w{4})/vote/$', 'sondage.views.vote'),
url(r'^(?P<poll_id>\w+)/csv/$', 'sondage.views.exp_csv'),
url(r'^(?P<lang_id>\w{2})/nuages$', 'meetingpoll.views.translation'),
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<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'),
url(r'^(?P<poll_id>\w+)/csv/$', 'meetingpoll.views.exp_csv'),
url(r'^accounts/profile/$', 'accounts.views.profile', name='profile'),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^(?P<poll_id>\w{4})/clear/', 'sondage.userviews.clear_cookie'),
url(r'^(?P<poll_id>\w{4})/clear/', 'meetingpoll.userviews.clear_cookie'),
)
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