Commit c50b2b4e authored by Christophe Siraut's avatar Christophe Siraut
Browse files

port to django 1.11 and python3

parent 19ea8d47
Pipeline #216 failed with stages
in 0 seconds
......@@ -27,7 +27,7 @@ new_translation:
done
test:
python-coverage run --source='.' manage.py test
python-coverage run --source='.' manage.py test --failfast
python-coverage report
build:
......
nuages (0.20210114) unstable; urgency=low
* New release.
-- Christophe Siraut <d@tobald.eu.org> Thu, 14 Jan 2021 13:30:07 +0100
nuages (0.20150701) UNRELEASED; urgency=low
* Initial release.
......
......@@ -4,39 +4,39 @@ Priority: optional
Maintainer: Christophe Siraut <d@tobald.eu.org>
Build-Depends: debhelper (>= 9),
dh-python,
python-all (>= 2.6.6-3~),
python-sphinx,
python-webtest,
python-django,
python-django-south,
python-django-webtest,
python-django-datetime-widget,
python-django-jsonfield,
python-django-allauth,
python-django-debug-toolbar
python3-all,
python3-sphinx,
python3-webtest,
python3-django,
python3-django-webtest,
python3-django-datetime-widget,
python3-django-jsonfield,
python3-django-allauth,
python3-django-debug-toolbar
Homepage: https://nuages.domainepublic.net
Vcs-Git: http://git.domainepublic.net/git/nuages.git/
Vcs-Browser: http://git.domainepublic.net/?p=nuages.git
Package: nuages
Architecture: all
Depends: ${python:Depends},
Depends: ${python3:Depends},
${misc:Depends},
python-nuages (= ${source:Version}),
python3-nuages (= ${source:Version}),
nginx | apache2 | httpd,
gunicorn | libapache2-mod-wsgi,
python-django (>= 1.6),
python-django-south,
python-django-webtest,
python-django-datetime-widget,
python-django-jsonfield,
python-django-allauth
python3-django (>= 1.6),
python3-django-webtest,
python3-django-datetime-widget,
python3-django-jsonfield,
python3-django-allauth,
Recommends: uwsgi,
uwsgi-plugin-python3
Description: publish online polls
Nuages aims to provide a collaborative meeting poll system.
.
This package provides all the services to run a Nuage instance.
Package: python-nuages
Package: python3-nuages
Section: python
Architecture: all
Depends: python-all (>= 2.6.6-3~),
......
......@@ -10,8 +10,7 @@ case "$1" in
fi
# Sync dthe database and collect the static files
nuages syncdb -v 0 --noinput
nuages migrate meetingpoll -v 0 --noinput
nuages migrate --noinput
nuages collectstatic -v 0 --noinput
chown -R www-data /var/lib/nuages
......
usr/lib/python2*/dist-packages/nuages
usr/lib/python2*/dist-packages/Nuages*
usr/lib/python2*/dist-packages/meetingpoll
usr/lib/python2*/dist-packages/DjangoMeetingPoll*
usr/lib/python2*/dist-packages/nuages_templates
usr/lib/python2*/dist-packages/registration_templates
usr/lib/python3*/dist-packages/nuages
usr/lib/python3*/dist-packages/Nuages*
usr/lib/python3*/dist-packages/meetingpoll
usr/lib/python3*/dist-packages/DjangoMeetingPoll*
usr/lib/python3*/dist-packages/nuages_templates
usr/lib/python3*/dist-packages/registration_templates
etc/nuages
#!/usr/bin/make -f
NAME=nuages
#export PYBUILD_NAME=$(NAME)
export PYBUILD_NAME=$(NAME)
#export DH_VERBOSE=1
%:
dh $@ --with python2,sphinxdoc --buildsystem=pybuild
dh $@ --with python3,sphinxdoc --buildsystem=pybuild
override_dh_auto_install:
dh_auto_install
......
......@@ -4,7 +4,7 @@ Nuages
''Easy poll sharing''
A collaborative meeting poll system, similar to doodle or rdvz. This application was named after Django's famous song and because computer work is easier when its cloudy. It is build in python, using the django framework and a little of javascript.
A collaborative meeting poll system, similar to doodle or rdvz. This application was named after Django's famous song and because computer work is easier when its cloudy. It is build in python3, using the django framework and a little of javascript.
Feedback and collaboration are welcome at nuages@lists.domainepublic.net. (Inscription to the mailing list is recommended before posting) We have a project page at projets.domainepublic.net.
......@@ -30,11 +30,11 @@ Python package installation
---------------------------
Using setuptools all dependencies will be installed:
# python setup.py install
# python3 setup.py install
Development installation
------------------------
Install python-django package (>=1.7)
Install python3-django package
Clone nuages archive somewhere in your home folder::
# cd
......
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2021-01-02 16:23
from __future__ import unicode_literals
from django.db import models, migrations
import __builtin__
import datetime
import jsonfield.fields
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import jsonfield.fields
import meetingpoll.models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
......@@ -18,76 +22,63 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Bulletin',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('voter', models.CharField(max_length=40, verbose_name=b'')),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('voter', models.CharField(max_length=40, verbose_name='')),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Choice',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('choice', models.DateTimeField()),
('details', models.CharField(max_length=200, blank=True)),
('votecount', models.IntegerField(default=0, blank=True)),
('details', models.CharField(blank=True, max_length=200)),
('votecount', models.IntegerField(blank=True, default=0)),
],
options={
'ordering': ['choice'],
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Poll',
fields=[
('id', models.CharField(default=b'Nrj9u', max_length=8, serialize=False, primary_key=True)),
('id', models.CharField(default=meetingpoll.models.createId, max_length=8, primary_key=True, serialize=False)),
('title', models.CharField(max_length=80, verbose_name='Title')),
('pub_date', models.DateField(default=datetime.datetime.now)),
('upd_date', models.DateField(auto_now=True)),
('description', models.CharField(max_length=300)),
('result', jsonfield.fields.JSONField(default=__builtin__.dict)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, null=True)),
('result', jsonfield.fields.JSONField(default=dict)),
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email_notifications', models.BooleanField(default=False)),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Vote',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('voice', models.BooleanField(default=False)),
('comment', models.CharField(max_length=80, blank=True)),
('bulletin', models.ForeignKey(to='meetingpoll.Bulletin')),
('choice', models.ForeignKey(to='meetingpoll.Choice')),
('comment', models.CharField(blank=True, max_length=80)),
('bulletin', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='meetingpoll.Bulletin')),
('choice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='meetingpoll.Choice')),
],
options={
'ordering': ['choice'],
},
bases=(models.Model,),
),
migrations.AddField(
model_name='choice',
name='poll',
field=models.ForeignKey(to='meetingpoll.Poll'),
preserve_default=True,
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='meetingpoll.Poll'),
),
migrations.AddField(
model_name='bulletin',
name='poll',
field=models.ForeignKey(editable=False, to='meetingpoll.Poll'),
preserve_default=True,
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='meetingpoll.Poll'),
),
]
......@@ -13,7 +13,7 @@ import jsonfield
def createId(length=5):
firstchar = string.ascii_letters
c = string.digits + string.ascii_letters
lastchars = ''.join([random.choice(c) for dummy in xrange(0, length - 1)])
lastchars = ''.join([random.choice(c) for dummy in range(0, length - 1)])
return random.choice(firstchar) + lastchars
......@@ -80,10 +80,10 @@ class Poll(models.Model):
t += 1
if v.comment:
l.append([v.bulletin.voter, v.comment])
choices.append((c.choice, c.details, t, l))
choices.append((str(c.choice), c.details, t, l))
return choices
def __unicode__(self):
def __str__(self):
return self.title
@property
......@@ -102,7 +102,7 @@ class Choice(models.Model):
class Meta:
ordering = ['choice']
def __unicode__(self):
def __str__(self):
return str(self.choice)
......@@ -110,7 +110,7 @@ class Bulletin(models.Model):
poll = models.ForeignKey(Poll, editable=False)
voter = models.CharField("", max_length=40)
def __unicode__(self):
def __str__(self):
return self.voter
if not Bulletin.objects.filter(poll=poll.id, voter=voter):
......@@ -129,5 +129,5 @@ class Vote(models.Model):
class Meta:
ordering = ['choice']
def __unicode__(self):
def __str__(self):
return str(self.voice)
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% load bulletin_results %}
......
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% load bulletin_results %}
{% load parse_date %}
......@@ -41,7 +40,7 @@
</tr>
{% for voterdict in result.voters %}
{% for voter, data in voterdict.iteritems %}
{% for voter, data in voterdict.items %}
<tr >
<td class='names'>{{ voter }}</td>
{% for voice, comment in data %}
......
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% block title %}Create a meeting{% endblock %}
......
......@@ -6,7 +6,7 @@ from django.template.defaultfilters import stringfilter
register = Library()
@stringfilter
def parse_date(date_string, format="%Y-%m-%dT%H:%M:%S"):
def parse_date(date_string, format="%Y-%m-%d %H:%M:%S"):
"""
Return a datetime corresponding to date_string, parsed according to format.
......@@ -18,6 +18,7 @@ def parse_date(date_string, format="%Y-%m-%dT%H:%M:%S"):
try:
return datetime.datetime.strptime(date_string, format)
except ValueError:
raise
return None
......
#!/usr/bin/env python
#!/usr/bin/env python3
from django.core.urlresolvers import reverse
from django_webtest import WebTest
from meetingpoll.models import createId
......
......@@ -7,6 +7,6 @@ class NewViewTest(TestCase):
client = Client()
response = client.get('/m/new/')
self.assertEqual(response.status_code, 200)
self.assertIn('<title>Create a meeting</title>', response.content)
self.assertTrue(response.content.startswith('<!DOCTYPE html>\n<html>'))
self.assertTrue(response.content.endswith('</html>\n'))
self.assertIn('<title>Create a meeting</title>', response.content.decode())
self.assertTrue(response.content.startswith(b'<!DOCTYPE html>\n<html>'))
self.assertTrue(response.content.endswith(b'</html>\n'))
from django.conf.urls import patterns, url
from django.conf.urls import url
from django.contrib.auth.decorators import login_required
from django.views.generic.edit import UpdateView
from meetingpoll.models import Poll
from meetingpoll.forms import PollForm
from meetingpoll import views
urlpatterns = patterns(
'',
url(r'^new/$', 'meetingpoll.views.new', name='new'),
urlpatterns = [
url(r'^new/$', views.new, name='new'),
url(r'^(?P<pk>\w{4,6})/edit/$',
login_required(UpdateView.as_view(
queryset=Poll.objects.all(),
......@@ -14,21 +14,21 @@ urlpatterns = patterns(
success_url='choices/')),
name="edit"),
url(r'^(?P<poll_id>\w{4,6})/$',
'meetingpoll.views.vote',
views.vote,
name='meetingpoll'),
url(r'^(?P<poll_id>\w{4,6})/delete/$',
'meetingpoll.views.delete',
views.delete,
name="delete"),
url(r'^(?P<poll_id>\w{4,6})/edit/choices/$',
'meetingpoll.views.editchoices',
views.editchoices,
name='choices'),
url(r'^(?P<poll_id>\w{4,6})/vote/$',
'meetingpoll.views.vote',
views.vote,
name='vote'),
url(r'^(?P<poll_id>\w{4,6})/csv/$',
'meetingpoll.views.exp_csv',
views.exp_csv,
name='csv'),
url(r'^(?P<poll_id>\w{4,6})/clear/',
'meetingpoll.views.clear_cookie',
views.clear_cookie,
name='clearcookie'),
)
]
......@@ -177,6 +177,8 @@ def vote(request, poll_id):
for forms in vforms:
for vorm in forms:
if not vorm.is_valid():
print(vorm.errors.as_json())
if vorm.is_valid():
try:
choice = Choice.objects.get(choice=vorm.cleaned_data['choice'], poll=poll)
......@@ -318,7 +320,7 @@ def profile(request):
if request.method == 'POST':
form = UserProfileForm(request.POST)
if form.is_valid():
for k, v in form.cleaned_data.iteritems():
for k, v in form.cleaned_data.items():
setattr(request.user.userprofile, k, v)
request.user.userprofile.save()
return HttpResponseRedirect(reverse('home'))
......
from settings import INSTALLED_APPS, DEBUG
from nuages.settings import INSTALLED_APPS, DEBUG, MIDDLEWARE
import os
PROJECT_DIR = os.path.dirname(os.path.dirname(__file__))
DEBUG = True
TEMPLATE_DEBUG = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'http'
......@@ -32,3 +31,7 @@ STATIC_ROOT = os.path.join(PROJECT_DIR, 'staticroot')
INSTALLED_APPS += (
'debug_toolbar',
)
MIDDLEWARE += [
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
#!/usr/bin/env python
#!/usr/bin/env python3
# coding: utf-8
# Django settings for Nuages
import os
......@@ -7,9 +7,9 @@ from django.conf import global_settings
import django
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ['.%s' % '.'.join(socket.getfqdn().split('.')[1:])]
#ALLOWED_HOSTS = ['.%s' % '.'.join(socket.getfqdn().split('.')[1:])]
ALLOWED_HOSTS = ['*']
ADMINS = (
('Nuages', 'nuages@domainepublic.net'),
......@@ -99,14 +99,8 @@ STATICFILES_FINDERS = (
# Make this unique, and don't share it with anybody.
SECRET_KEY = '3qm&amp;@6264-=st16)7_xa*ds+31e0mqqs@+*!ud7gzt$tq!b^qn'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
#'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
......@@ -114,24 +108,25 @@ MIDDLEWARE_CLASSES = (
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
#'request.middleware.RequestMiddleware',
)
]
ROOT_URLCONF = 'nuages.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
# Required by allauth template tags
"django.core.context_processors.request",
# allauth specific context processors
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
......@@ -167,6 +162,6 @@ INSTALLED_APPS = (
)
try:
from local_settings import *
except ImportError, e:
from nuages.local_settings import *
except ImportError:
pass
Supports Markdown
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