Django 1.7 compatibility
This commit is contained in:
parent
7223c01042
commit
5816a6a7df
|
@ -14,7 +14,7 @@ Package: docbow
|
|||
Architecture: all
|
||||
Pre-depends: dbconfig-common, postgresql
|
||||
Depends: ${misc:Depends}, python (>= 2.6),
|
||||
python-django (>= 1.5),
|
||||
python-django (>= 1.7),
|
||||
python-django-south,
|
||||
python-django-debug-toolbar,
|
||||
python-django-grappelli,
|
|
@ -2,7 +2,7 @@ import watson
|
|||
import autocomplete_light
|
||||
from autocomplete_light.autocomplete.base import AutocompleteBase
|
||||
|
||||
from . import sql, models, views
|
||||
from . import sql, models
|
||||
|
||||
class WatsonAutocompleteBase(object):
|
||||
limit_choices = 10
|
||||
|
@ -15,6 +15,8 @@ class WatsonAutocompleteBase(object):
|
|||
def choices_for_request(self):
|
||||
q = self.request.GET.get('q', '')
|
||||
|
||||
from . import views
|
||||
|
||||
documents = sql.get_documents(models.Document.objects.all(),
|
||||
views.get_related_users(self.request), self.request.user, self.outbox,)
|
||||
search = watson.search(q, models=(documents,))
|
||||
|
|
|
@ -35,8 +35,8 @@ class RecipientField(MultipleChoiceField):
|
|||
self.user_qs = kwargs.pop('user_qs', User.objects.filter())
|
||||
self.user_qs = self.user_qs.filter(is_active=True, delegations_by__isnull=True)
|
||||
self.list_qs = kwargs.pop('list_qs', MailingList.objects.active())
|
||||
kwargs.setdefault('choices', Func2Iter(self.get_recipients_choices))
|
||||
super(RecipientField, self).__init__(*args, **kwargs)
|
||||
self._choices = self.widget.choices = Func2Iter(self.get_recipients_choices)
|
||||
|
||||
def reset_choices(self):
|
||||
'''Reset the list of choices'''
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import rfc3161
|
||||
import os.path
|
||||
import importlib
|
||||
|
||||
from django.utils import simplejson
|
||||
import json
|
||||
|
||||
from . import app_settings
|
||||
|
||||
|
@ -51,7 +50,7 @@ def decode_timestamp(encoded_tst):
|
|||
|
||||
def timestamp_json(json_dict, provider=None):
|
||||
provider = provider or app_settings.TIMESTAMP_PROVIDER
|
||||
s = simplejson.dumps(json_dict)
|
||||
s = json.dumps(json_dict)
|
||||
if s[-1] != '}':
|
||||
raise ValueError("timestamp_json takes a dictionnary as argument: %s" % s)
|
||||
tst, error = timestamp(s, provider=provider)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
import os
|
||||
import json
|
||||
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.files.storage import DefaultStorage
|
||||
from django.core.files import File
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.utils import simplejson
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
@ -45,7 +45,7 @@ def response_mimetype(request):
|
|||
class JSONResponse(HttpResponse):
|
||||
"""JSON response class."""
|
||||
def __init__(self,obj='',json_opts={},mimetype="application/json",*args,**kwargs):
|
||||
content = simplejson.dumps(obj,**json_opts)
|
||||
content = json.dumps(obj,**json_opts)
|
||||
super(JSONResponse,self).__init__(content,mimetype,*args,**kwargs)
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.conf import settings
|
|||
from django.template.loader import render_to_string
|
||||
from django.forms.util import flatatt
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.encoding import StrAndUnicode, force_unicode
|
||||
from django.utils.encoding import force_unicode
|
||||
|
||||
|
||||
from upload_views import get_files_for_id
|
||||
|
@ -239,7 +239,7 @@ if django.VERSION < (1, 6):
|
|||
final_attrs['checked'] = 'checked'
|
||||
return mark_safe(u'<input%s />' % flatatt(final_attrs))
|
||||
|
||||
class CheckboxRenderer(StrAndUnicode):
|
||||
class CheckboxRenderer(object):
|
||||
def __init__(self, name, value, attrs, choices):
|
||||
self.name, self.value, self.attrs = name, value, attrs
|
||||
self.choices = choices
|
||||
|
|
|
@ -69,7 +69,7 @@ __ENVIRONMENT_DEFAULTS = dict(
|
|||
DOCBOW_PFWB_SENDMAIL_TABELLIO_EXPEDITION_USER_ID=None,
|
||||
DOCBOW_PFWB_SENDMAIL_ATTACHED_FILE_EMAIL='dontknow@pfwb.be',
|
||||
DOCBOW_PFWB_SENDMAIL_ATTACHED_FILE_USER_ID=None,
|
||||
TEMPLATE_CONTEXT_PROCESSORS=django.conf.global_settings.TEMPLATE_CONTEXT_PROCESSORS +
|
||||
TEMPLATE_CONTEXT_PROCESSORS=tuple(django.conf.global_settings.TEMPLATE_CONTEXT_PROCESSORS) +
|
||||
('django.core.context_processors.request',
|
||||
'docbow_project.docbow.context_processors.logout_url_processor'),
|
||||
DATE_INPUT_FORMATS=('%d/%m/%Y', '%Y-%m-%d'),
|
||||
|
@ -87,6 +87,8 @@ __ENVIRONMENT_DEFAULTS = dict(
|
|||
SESSION_COOKIE_AGE=7200,
|
||||
)
|
||||
|
||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||
|
||||
for key, default in __ENVIRONMENT_DEFAULTS.iteritems():
|
||||
try:
|
||||
value = os.environ[key]
|
||||
|
@ -166,7 +168,6 @@ INSTALLED_APPS = (
|
|||
'django_tables2',
|
||||
'django_journal',
|
||||
'crispy_forms',
|
||||
'south',
|
||||
'entrouvert.djommon.humantime',
|
||||
'docbow_project.docbow',
|
||||
)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Get venv site-packages path
|
||||
DSTDIR=`python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
|
||||
|
||||
# Get not venv site-packages path
|
||||
# Remove first path (assuming that is the venv path)
|
||||
NONPATH=`echo $PATH | sed 's/^[^:]*://'`
|
||||
SRCDIR=`PATH=$NONPATH python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
|
||||
|
||||
# Clean up
|
||||
rm -f $DSTDIR/lasso.*
|
||||
rm -f $DSTDIR/_lasso.*
|
||||
|
||||
# Link
|
||||
ln -sv $SRCDIR/lasso.py $DSTDIR
|
||||
ln -sv $SRCDIR/_lasso.* $DSTDIR
|
||||
|
||||
exit 0
|
||||
|
21
jenkins.sh
21
jenkins.sh
|
@ -1,17 +1,10 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
./getm2crypto.sh
|
||||
|
||||
pip install --upgrade setuptools
|
||||
pip install --upgrade pip
|
||||
pip install --upgrade pyOpenSSL ndg-httpsclient requests pyasn1
|
||||
sed -i 's/^MAX = 64/MAX = 200/' $VIRTUAL_ENV/lib/python*/site-packages/ndg/httpsclient/subj_alt_name.py
|
||||
|
||||
pip install -v -r requirements.txt
|
||||
pip install --upgrade -I pylint pylint-django
|
||||
(pylint -f parseable --rcfile /var/lib/jenkins/pylint.django.rc docbow_project/ | tee pylint.out) || /bin/true
|
||||
|
||||
./getlasso.sh
|
||||
pip install -e .
|
||||
export SECRET_KEY=test
|
||||
|
||||
CUSTOMIZATION=pw ./docbow-ctl syncdb --noinput
|
||||
CUSTOMIZATION=pw ./docbow-ctl migrate
|
||||
CUSTOMIZATION=pw ./docbow-ctl validate
|
||||
|
@ -20,9 +13,5 @@ CUSTOMIZATION=pfwb ./docbow-ctl syncdb --noinput
|
|||
CUSTOMIZATION=pfwb ./docbow-ctl migrate
|
||||
CUSTOMIZATION=pfwb ./docbow-ctl validate
|
||||
rm docbow.db
|
||||
CUSTOMIZATION=pw ./docbow-ctl test docbow_project.docbow docbow_project.pw
|
||||
RET1=$?
|
||||
CUSTOMIZATION=pfwb ./docbow-ctl test docbow_project.docbow docbow_project.pfwb
|
||||
RET2=$?
|
||||
|
||||
[ "$RET1" == 0 -a "$RET2" == 0 ]
|
||||
tox
|
||||
./merge-junit-results.py junit-*.xml >junit.xml
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Corey Goldberg, Dec 2012
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
"""Merge multiple JUnit XML files into a single results file.
|
||||
Output dumps to sdtdout.
|
||||
example usage:
|
||||
$ python merge_junit_results.py results1.xml results2.xml > results.xml
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
if '-h' in args or '--help' in args:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
merge_results(args[:])
|
||||
|
||||
|
||||
def merge_results(xml_files):
|
||||
failures = 0
|
||||
tests = 0
|
||||
errors = 0
|
||||
time = 0.0
|
||||
cases = []
|
||||
|
||||
for file_name in xml_files:
|
||||
tree = ET.parse(file_name)
|
||||
test_suite = tree.getroot()
|
||||
failures += int(test_suite.attrib['failures'])
|
||||
tests += int(test_suite.attrib['tests'])
|
||||
errors += int(test_suite.attrib['errors'])
|
||||
time += float(test_suite.attrib['time'])
|
||||
cases.append(test_suite.getchildren())
|
||||
|
||||
new_root = ET.Element('testsuite')
|
||||
new_root.attrib['failures'] = '%s' % failures
|
||||
new_root.attrib['tests'] = '%s' % tests
|
||||
new_root.attrib['errors'] = '%s' % errors
|
||||
new_root.attrib['time'] = '%s' % time
|
||||
for case in cases:
|
||||
new_root.extend(case)
|
||||
new_tree = ET.ElementTree(new_root)
|
||||
ET.dump(new_tree)
|
||||
|
||||
|
||||
def usage():
|
||||
this_file = os.path.basename(__file__)
|
||||
print 'Usage: %s results1.xml results2.xml' % this_file
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,20 +0,0 @@
|
|||
--allow-all-external
|
||||
Django>=1.5,<1.7
|
||||
South>=1.0
|
||||
django-debug-toolbar<0.9.0
|
||||
django-grappelli<2.5.0
|
||||
django-crispy-forms>=1.3,<1.4
|
||||
BeautifulSoup<3.3.0
|
||||
rfc3161<2
|
||||
gunicorn
|
||||
django_journal>=1.23.0,<2.0.0
|
||||
django-picklefield==0.3.0
|
||||
django-tables2==0.13.0
|
||||
python-magic<0.5
|
||||
raven
|
||||
pytz
|
||||
django-mellon
|
||||
python-entrouvert
|
||||
django-watson<1.2
|
||||
django-autocomplete-light>1.999a,<3
|
||||
django-statsd-mozilla
|
114
setup.py
114
setup.py
|
@ -7,9 +7,10 @@ import sys
|
|||
from setuptools import setup, find_packages
|
||||
from setuptools.command.install_lib import install_lib as _install_lib
|
||||
from distutils.command.build import build as _build
|
||||
from distutils.command.sdist import sdist as _sdist
|
||||
from setuptools.command.sdist import sdist as _sdist
|
||||
from distutils.cmd import Command
|
||||
|
||||
|
||||
class compile_translations(Command):
|
||||
description = 'compile message catalogs to MO files via django compilemessages'
|
||||
user_options = []
|
||||
|
@ -21,19 +22,29 @@ class compile_translations(Command):
|
|||
pass
|
||||
|
||||
def run(self):
|
||||
from django.core.management.commands.compilemessages import \
|
||||
compile_messages
|
||||
for path in ['docbow_project/docbow', 'docbow_project/pfwb', 'docbow_project/pw']:
|
||||
if not os.path.exists(os.path.join(path, 'locale')):
|
||||
continue
|
||||
curdir = os.getcwd()
|
||||
os.chdir(os.path.realpath(path))
|
||||
compile_messages(sys.stderr)
|
||||
curdir = os.getcwd()
|
||||
try:
|
||||
os.environ.pop('DJANGO_SETTINGS_MODULE', None)
|
||||
from django.core.management import call_command
|
||||
for dir in ['docbow_project/docbow', 'docbow_project/pfwb', 'docbow_project/pw']:
|
||||
for path, dirs, files in os.walk(dir):
|
||||
if 'locale' not in dirs:
|
||||
continue
|
||||
os.chdir(os.path.realpath(path))
|
||||
call_command('compilemessages')
|
||||
os.chdir(curdir)
|
||||
except ImportError:
|
||||
print
|
||||
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
||||
print
|
||||
print
|
||||
os.chdir(curdir)
|
||||
|
||||
|
||||
class build(_build):
|
||||
sub_commands = [('compile_translations', None)] + _build.sub_commands
|
||||
|
||||
|
||||
class sdist(_sdist):
|
||||
sub_commands = [('compile_translations', None)] + _sdist.sub_commands
|
||||
|
||||
|
@ -50,11 +61,13 @@ class sdist(_sdist):
|
|||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
|
||||
|
||||
class install_lib(_install_lib):
|
||||
def run(self):
|
||||
self.run_command('compile_translations')
|
||||
_install_lib.run(self)
|
||||
|
||||
|
||||
def get_version():
|
||||
'''Use the VERSION, if absent generates a version with git describe, if not
|
||||
tag exists, take 0.0.0- and add the length of the commit log.
|
||||
|
@ -63,51 +76,52 @@ def get_version():
|
|||
with open('VERSION', 'r') as v:
|
||||
return v.read()
|
||||
if os.path.exists('.git'):
|
||||
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
result = p.communicate()[0]
|
||||
if p.returncode == 0:
|
||||
return result.split()[0][1:].replace('-', '.')
|
||||
else:
|
||||
return '0.0.0-%s' % len(
|
||||
subprocess.check_output(
|
||||
['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return '0.0.0-%s' % len(subprocess.check_output(
|
||||
['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return '0.0.0'
|
||||
|
||||
setup(name='docbow',
|
||||
version=get_version(),
|
||||
license='AGPL 3.0',
|
||||
description='Document box for the Wallon Parliament',
|
||||
url='https://dev.entrouvert.org/projects/docbow-pub/',
|
||||
author="Entr'ouvert",
|
||||
author_email='info@entrouvert.com',
|
||||
maintainer='Benjamin Dauvergne',
|
||||
maintainer_email='bdauvergne@entrouvert.com',
|
||||
include_package_data=True,
|
||||
scripts=('docbow-ctl',),
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'Django>=1.5,<1.7',
|
||||
'South>=1.0',
|
||||
'django-debug-toolbar<0.9.0',
|
||||
'django-grappelli<2.5.0',
|
||||
'django-crispy-forms>=1.3,<1.4',
|
||||
'BeautifulSoup<3.3.0',
|
||||
'rfc3161==0.1.9',
|
||||
'gunicorn',
|
||||
'django_journal<2.0.0',
|
||||
'django-picklefield==0.3.0',
|
||||
'python-entrouvert>=2',
|
||||
'django-tables2==0.13.0',
|
||||
'raven',
|
||||
'python-magic',
|
||||
'django-watson',
|
||||
'django-autocomplete-light>1.999a',
|
||||
'django-statsd-mozilla',
|
||||
],
|
||||
setup_requires=[
|
||||
'Django>=1.5,<1.7',
|
||||
],
|
||||
cmdclass={'build': build, 'install_lib': install_lib,
|
||||
'compile_translations': compile_translations,
|
||||
'sdist': sdist})
|
||||
version=get_version(),
|
||||
license='AGPL 3.0',
|
||||
description='Document box for the Wallon Parliament',
|
||||
url='https://dev.entrouvert.org/projects/docbow-pub/',
|
||||
author="Entr'ouvert",
|
||||
author_email='info@entrouvert.com',
|
||||
maintainer='Benjamin Dauvergne',
|
||||
maintainer_email='bdauvergne@entrouvert.com',
|
||||
include_package_data=True,
|
||||
scripts=('docbow-ctl',),
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'Django>=1.7,<1.8',
|
||||
'django-debug-toolbar<0.9.0',
|
||||
'django-grappelli<2.5.0',
|
||||
'django-crispy-forms>=1.3,<1.4',
|
||||
'BeautifulSoup<3.3.0',
|
||||
'rfc3161',
|
||||
'gunicorn',
|
||||
'django_journal>=1.23.0,<2.0.0',
|
||||
'django-picklefield==0.3.0',
|
||||
'python-entrouvert>=2',
|
||||
'django-tables2',
|
||||
'raven',
|
||||
'python-magic',
|
||||
'django-watson<1.2',
|
||||
'django-autocomplete-light>1.999a,<3',
|
||||
'django-statsd-mozilla',
|
||||
'django-mellon',
|
||||
],
|
||||
setup_requires=[
|
||||
'Django>=1.7',
|
||||
],
|
||||
cmdclass={
|
||||
'build': build,
|
||||
'install_lib': install_lib,
|
||||
'compile_translations': compile_translations,
|
||||
'sdist': sdist})
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
[tox]
|
||||
envlist = pw,pfwb
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
deps =
|
||||
pytest
|
||||
pytest-django
|
||||
setenv =
|
||||
SECRET_KEY=changeme
|
||||
pw: CUSTOMIZATION=pw
|
||||
pfwb: CUSTOMIZATION=pfwb
|
||||
DJANGO_SETTINGS_MODULE=docbow_project.settings
|
||||
commands =
|
||||
./getlasso.sh
|
||||
pw: {posargs:py.test --junitxml=junit-{envname}.xml docbow_project/docbow/tests.py docbow_project/pw/tests.py}
|
||||
pfwb: {posargs:py.test --junitxml=junit-{envname}.xml docbow_project/docbow/tests.py docbow_project/pfwb/tests.py}
|
Loading…
Reference in New Issue