From f31925387f13f954360b605e1f954900ec5057a3 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Tue, 30 Jun 2015 02:37:57 +0200 Subject: [PATCH] Updated python requirements. This included django 1.8 --- make/commands.py | 30 +++++-------------- .../migrations/0002_auto_20150630_0144.py | 16 ++++++++++ openslides/agenda/models.py | 3 +- openslides/global_settings.py | 1 - openslides/motions/models.py | 7 +++-- openslides/urls.py | 2 +- .../migrations/0002_auto_20150630_0143.py | 28 +++++++++++++++++ requirements_production.txt | 14 ++++----- tests/integration/assignments/test_viewset.py | 3 +- tests/old/motions/test_models.py | 10 ------- tests/old/utils/test_main.py | 3 -- 11 files changed, 67 insertions(+), 50 deletions(-) create mode 100644 openslides/agenda/migrations/0002_auto_20150630_0144.py create mode 100644 openslides/users/migrations/0002_auto_20150630_0143.py diff --git a/make/commands.py b/make/commands.py index ec338213c..ac31e5114 100644 --- a/make/commands.py +++ b/make/commands.py @@ -14,8 +14,12 @@ def test(args=None): Runs the tests. """ module = getattr(args, 'module', '') + if module == '': + module = 'tests' + else: + module = 'tests.{}'.format(module) return call("DJANGO_SETTINGS_MODULE='tests.settings' coverage run " - "./manage.py test tests.%s" % module) + "./manage.py test {}".format(module)) @argument('--plain', action='store_true') @@ -84,10 +88,10 @@ def min_requirements(args=None): Uses requirements_production.txt by default. """ - from pip.req import parse_requirements + import pip def get_lowest_versions(requirements_file): - for line in parse_requirements(requirements_file): + for line in pip.req.parse_requirements(requirements_file, session=pip.download.PipSession()): yield '%s==%s' % (line.req.key, line.req.specs[0][1]) print('pip install %s' % ' '.join(get_lowest_versions(args.requirements))) @@ -95,7 +99,7 @@ def min_requirements(args=None): @command('clear', help='Deletes unneeded files and folders') -def clear(args=None): +def clean(args=None): """ Deletes all .pyc and .orig files and empty folders. """ @@ -103,24 +107,6 @@ def clear(args=None): call('find -name "*.orig" -delete') call('find -type d -empty -delete') -@command('po', - help="Generates the po-file for javascript") -def po(args=None): - # TODO: in the value "" there has to be the entry: - # "plural_forms: nplurals=2; plural=(n != 1);" - call('find openslides/ -iname "*.js" -or -iname "*.html" | ' - 'xargs xgettext --from-code=UTF-8 --language=JavaScript ' - '--output=openslides/locale/en/javascript.po') - - -@argument('-l', '--language') -@command('po2json', - help="Generates json for a translated po file") -def po2json(args=None): - lang = args.language - call('node_modules/.bin/po2json openslides/locale/%s/javascript.po openslides/static/i18n/%s.json' % - (lang, lang)) - @command('isort', help='Sorts all imports in all python files.') diff --git a/openslides/agenda/migrations/0002_auto_20150630_0144.py b/openslides/agenda/migrations/0002_auto_20150630_0144.py new file mode 100644 index 000000000..5fca6f5c4 --- /dev/null +++ b/openslides/agenda/migrations/0002_auto_20150630_0144.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='type', + field=models.IntegerField(verbose_name='Type', choices=[(1, 'Agenda item'), (2, 'Organizational item')], default=1), + ), + ] diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 253ec9d47..705e47983 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -120,8 +120,7 @@ class Item(RESTModelMixin, models.Model): Flag, if the item is finished. """ - type = models.IntegerField(max_length=1, choices=ITEM_TYPE, - default=AGENDA_ITEM, verbose_name=ugettext_lazy("Type")) + type = models.IntegerField(choices=ITEM_TYPE, default=AGENDA_ITEM, verbose_name=ugettext_lazy("Type")) """ Type of the agenda item. diff --git a/openslides/global_settings.py b/openslides/global_settings.py index 7a1ba0a40..7b87d62d8 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -83,7 +83,6 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.humanize', 'haystack', # full-text-search - 'ckeditor', 'rest_framework', 'openslides.poll', # TODO: try to remove this line 'openslides.agenda', diff --git a/openslides/motions/models.py b/openslides/motions/models.py index 170e4f586..79201c50a 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -179,7 +179,6 @@ class Motion(RESTModelMixin, models.Model): use_version.version_number = version_number + 1 # Necessary line if the version was set before the motion got an id. - # This is probably a Django bug. use_version.motion = use_version.motion use_version.save() @@ -339,7 +338,11 @@ class Motion(RESTModelMixin, models.Model): attributes, it is populated with the data from the last version object if such object exists. """ - new_version = MotionVersion(motion=self, **kwargs) + if self.pk is None: + # Do not reference the MotionVersion object to an unsaved motion + new_version = MotionVersion(**kwargs) + else: + new_version = MotionVersion(motion=self, **kwargs) if self.versions.exists(): last_version = self.get_last_version() else: diff --git a/openslides/urls.py b/openslides/urls.py index b5b23ce22..cd83c4801 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -5,7 +5,7 @@ from openslides.utils.rest_api import router urlpatterns = patterns( '', - url(r'^(?P.*[^/])$', RedirectView.as_view(url='/%(url)s/')), + url(r'^(?P.*[^/])$', RedirectView.as_view(url='/%(url)s/', permanent=True)), url(r'^rest/', include(router.urls)), url(r'^agenda/', include('openslides.agenda.urls')), url(r'^assignments/', include('openslides.assignments.urls')), diff --git a/openslides/users/migrations/0002_auto_20150630_0143.py b/openslides/users/migrations/0002_auto_20150630_0143.py new file mode 100644 index 000000000..f37c215e7 --- /dev/null +++ b/openslides/users/migrations/0002_auto_20150630_0143.py @@ -0,0 +1,28 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='groups', + field=models.ManyToManyField( + verbose_name='groups', + related_query_name='user', + to='auth.Group', + related_name='user_set', + help_text='The groups this user belongs to. A user will get all ' + 'permissions granted to each of their groups.', + blank=True), + ), + migrations.AlterField( + model_name='user', + name='last_login', + field=models.DateTimeField(verbose_name='last login', blank=True, null=True), + ), + ] diff --git a/requirements_production.txt b/requirements_production.txt index 5acb5af9f..b8539344e 100644 --- a/requirements_production.txt +++ b/requirements_production.txt @@ -1,16 +1,14 @@ # Requirements for OpenSlides in production in alphabetical order -Django>=1.7,<1.8 +Django>=1.7.1,<1.9 beautifulsoup4>=4.1,<4.4 bleach>=1.4,<1.5 -django-ckeditor-updated>=4.2.3,<4.4 -django-haystack>=2.1,<2.4 +django-haystack>=2.1,<2.5 djangorestframework>=3.0.5,<3.2.0 jsonfield>=0.9.19,<1.1 -natsort>=3.2,<3.6 -reportlab>=3.0,<3.2 +natsort>=3.2,<4.1 +reportlab>=3.0,<3.3 roman>=2.0,<2.1 -setuptools>=2.2,<18.0 +setuptools>=2.2,<19.0 sockjs-tornado>=1.0,<1.1 -tornado>=2.1,<4.1 -whoosh>=2.5.6,<2.6 +whoosh>=2.5.6,<2.8 diff --git a/tests/integration/assignments/test_viewset.py b/tests/integration/assignments/test_viewset.py index 4ab6abd4b..6f8b5d005 100644 --- a/tests/integration/assignments/test_viewset.py +++ b/tests/integration/assignments/test_viewset.py @@ -268,7 +268,8 @@ class MarkElectedOtherUser(TestCase): self.assertTrue(Assignment.objects.get(pk=self.assignment.pk).elected.filter(username='test_user_Oonei3rahji5jugh1eev').exists()) def test_mark_unelected(self): - self.assignment.set_elected(get_user_model().objects.get(username='test_user_Oonei3rahji5jugh1eev')) + user = get_user_model().objects.get(username='test_user_Oonei3rahji5jugh1eev') + self.assignment.set_elected(user) response = self.client.delete( reverse('assignment-mark-elected', args=[self.assignment.pk]), {'user': self.user.pk}) diff --git a/tests/old/motions/test_models.py b/tests/old/motions/test_models.py index 2eaee8c31..d284a9c20 100644 --- a/tests/old/motions/test_models.py +++ b/tests/old/motions/test_models.py @@ -1,5 +1,3 @@ -from unittest import skip - from openslides.core.config import config from openslides.motions.exceptions import WorkflowError from openslides.motions.models import Motion, State, Workflow @@ -56,14 +54,6 @@ class ModelTest(TestCase): self._title self.assertEqual(motion.title, 'v3') - @skip - def test_absolute_url(self): - motion_id = self.motion.id - - self.assertEqual(self.motion.get_absolute_url('detail'), '/motions/%d/' % motion_id) - self.assertEqual(self.motion.get_absolute_url('update'), '/motions/%d/edit/' % motion_id) - self.assertEqual(self.motion.get_absolute_url('delete'), '/motions/%d/del/' % motion_id) - def test_supporter(self): self.assertFalse(self.motion.is_supporter(self.test_user)) self.motion.supporters.add(self.test_user) diff --git a/tests/old/utils/test_main.py b/tests/old/utils/test_main.py index cc3b78a67..f1903c044 100644 --- a/tests/old/utils/test_main.py +++ b/tests/old/utils/test_main.py @@ -87,9 +87,6 @@ class TestFunctions(TestCase): inner_function() browser_mock.open.assert_called_with('http://localhost:8234') - def test_get_database_path_from_settings_memory(self): - self.assertEqual(main.get_database_path_from_settings(), ':memory:') - def test_translate_customizable_strings(self): self.assertEqual(config['general_event_description'], 'Presentation and assembly system') main.translate_customizable_strings('de')