From 2a73d9f7eeff3841eeba24f1d7d0829c3e7ed929 Mon Sep 17 00:00:00 2001 From: Andy Kittner Date: Tue, 12 Nov 2013 21:39:03 +0100 Subject: [PATCH 1/4] Set reuse address option (fixes #1043) When the server is killed there may still be client-sockets connected in the TIME_WAIT state, causing the bind() call to fail. With the REUSEADDR option we can reuse the address immediately unless another process is actually *listening* on the same address. that we want to reuse the address --- openslides/utils/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openslides/utils/main.py b/openslides/utils/main.py index e111fe062..210347a44 100644 --- a/openslides/utils/main.py +++ b/openslides/utils/main.py @@ -296,6 +296,7 @@ def get_port(address, port): """ s = socket.socket() try: + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((address, port)) s.listen(-1) except socket.error: From 5f948f9e79f98033b7a4ef379aebad7f58c9f80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 13 Nov 2013 19:29:54 +0100 Subject: [PATCH 2/4] Verbose name of Assignment inserted, fixed #1036 It is neccessary to refresh the database table for the content types, e. g. by deleting the database and runing syncdb. --- openslides/assignment/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index 574df51de..b1607b901 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -62,6 +62,7 @@ class Assignment(SlideMixin, models.Model): ('can_manage_assignment', ugettext_noop('Can manage assignments')), # TODO: Add plural s also to the codestring ) ordering = ('name',) + verbose_name = ugettext_noop('Assignment') def __unicode__(self): return self.name From 879e0734783537bdea2494bd995d988a54ffa3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 13 Nov 2013 19:36:19 +0100 Subject: [PATCH 3/4] Sort requirements, fix #1031. --- requirements.txt | 4 ++-- requirements_production.txt | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index 104db9277..70c53d1cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,13 @@ # Requirements for OpenSlides in production -r requirements_production.txt -# Requirements for development and tests +# Requirements for development and tests in alphabetical order Fabric==1.8.0 coverage==3.7 flake8==2.0 mock==1.0.1 -# Requirements for OpenSlides handbook/documentation +# Requirements for OpenSlides handbook/documentation in alphabetical order Sphinx==1.2b3 sphinx-bootstrap-theme==0.2.4 diff --git a/requirements_production.txt b/requirements_production.txt index 515ce7a74..2c6adee5a 100644 --- a/requirements_production.txt +++ b/requirements_production.txt @@ -1,10 +1,11 @@ +# Requirements for OpenSlides in production in alphabetical order Django==1.6.0 -django-mptt==0.6.0 -reportlab==2.7 -pillow==2.2.1 -tornado==3.1.1 -sockjs-tornado==1.0.0 -bleach==1.2.2 beautifulsoup4==4.3.2 +bleach==1.2.2 django-haystack==2.1.0 +django-mptt==0.6.0 +pillow==2.2.1 +reportlab==2.7 +sockjs-tornado==1.0.0 +tornado==3.1.1 whoosh==2.5.4 From 881fd562a1e371b9d247878a558da7fda65a84be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Thu, 14 Nov 2013 19:29:08 +0100 Subject: [PATCH 4/4] Add tests according to issue #931. --- tests/agenda/tests.py | 27 +++++++++++++++++++++++++++ tests/core/test_views.py | 7 +++++++ 2 files changed, 34 insertions(+) diff --git a/tests/agenda/tests.py b/tests/agenda/tests.py index f04b9424a..77fe1ce33 100644 --- a/tests/agenda/tests.py +++ b/tests/agenda/tests.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType from django.test.client import Client from mock import patch @@ -220,6 +222,31 @@ class ViewTest(TestCase): self.assertRedirects(response, '/agenda/') self.assertTrue(Item.objects.filter(pk=self.item1.pk).exists()) + def test_orga_item_permission(self): + # Prepare + self.item1.type = Item.ORGANIZATIONAL_ITEM + self.item1.save() + user = User.objects.create(username='testuser_EeBoPh5uyookoowoodii') + user.reset_password('default') + client = Client() + client.login(username='testuser_EeBoPh5uyookoowoodii', password='default') + # Test view with permission + self.assertTrue(user.has_perm('agenda.can_see_orga_items')) + self.assertContains(client.get('/agenda/1/'), 'item1') + # Remove permission + orga_perm = Permission.objects.get( + content_type=ContentType.objects.get_for_model(Item), + codename='can_see_orga_items') + user.groups.get(name='Registered').permissions.remove(orga_perm) + # Reload user + user = User.objects.get(username=user.username) + # Test view without permission + self.assertFalse(user.has_perm('agenda.can_see_orga_items')) + response = client.get('/agenda/1/') + self.assertEqual(response.status_code, 403) + response = client.get('/agenda/2/') + self.assertEqual(response.status_code, 200) + class ConfigTest(TestCase): def setUp(self): diff --git a/tests/core/test_views.py b/tests/core/test_views.py index 605876e6a..31796be81 100644 --- a/tests/core/test_views.py +++ b/tests/core/test_views.py @@ -5,6 +5,7 @@ from mock import MagicMock, patch from openslides import get_version from openslides.agenda.models import Item +from openslides.config.api import config from openslides.participant.models import User from openslides.utils.test import TestCase @@ -51,3 +52,9 @@ class SearchViewTest(TestCase): response = self.client.get('/search/?q=agenda_item_bnghfd') text = 'agenda_item_bnghfdjkgndkjdfg' self.assertContains(response, text) + + def test_anonymous(self): + self.assertFalse(config['system_enable_anonymous']) + self.assertEqual(Client().get('/search/').status_code, 403) + config['system_enable_anonymous'] = True + self.assertEqual(Client().get('/search/').status_code, 200)