From bcd98301a9ce4f85e9a72198de46202b5e55442c Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 5 Aug 2012 10:59:25 +0200 Subject: [PATCH 1/4] remove mercurial_version from openslides.__init__ --- openslides/__init__.py | 55 +++--------------------------------------- 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/openslides/__init__.py b/openslides/__init__.py index 6e440cbbb..ba0c9814b 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -5,10 +5,11 @@ :license: GNU GPL, see LICENSE for more details. """ -VERSION = (1, 2, 0, 'final', 1) +VERSION = (1, 2, 1, 'alpha', 0) def get_version(version=None): """Derives a PEP386-compliant version number from VERSION.""" + # TODO: Get the Version Hash from GIT. if version is None: version = VERSION assert len(version) == 5 @@ -24,59 +25,9 @@ def get_version(version=None): sub = '' if version[3] == 'alpha' and version[4] == 0: - mercurial_version = hg_version() - if mercurial_version != 'unknown': - sub = '.dev%s' % mercurial_version - else: - sub = '.dev' + sub = '.dev' elif version[3] != 'final': sub = "-" + version[3] + str(version[4]) return main + sub - - -def hg_version(): - import socket - import os - import sys - from os.path import realpath, join, dirname - try: - from mercurial import ui as hgui - from mercurial.localrepo import localrepository - from mercurial.node import short as shorthex - from mercurial.error import RepoError - nomercurial = False - except ImportError: - return 'unknown' - - os.environ['HGRCPATH'] = '' - conts = realpath(join(dirname(__file__))) - try: - ui = hgui.ui() - repository = localrepository(ui, join(conts, '..')) - ctx = repository['.'] - if ctx.tags() and ctx.tags() != ['tip']: - version = ' '.join(ctx.tags()) - else: - version = '%(num)s:%(id)s' % { - 'num': ctx.rev(), 'id': shorthex(ctx.node()) - } - except TypeError: - version = 'unknown' - except RepoError: - return 0 - - # This value defines the timeout for sockets in seconds. Per default python - # sockets do never timeout and as such we have blocking workers. - # Socket timeouts are set globally within the whole application. - # The value *must* be a floating point value. - socket.setdefaulttimeout(10.0) - - return version - - -## import os, site -## -## SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) -## site.addsitedir(SITE_ROOT) From 4873cd71637954409b337d59693070d66b50e2b8 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 5 Aug 2012 11:28:56 +0200 Subject: [PATCH 2/4] fixted #330. Error if the related slide for an Agenda Item does not exists --- openslides/agenda/models.py | 9 ++++++++- openslides/agenda/tests.py | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index cd67de1a6..d887d553c 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -52,7 +52,14 @@ class Item(MPTTModel, SlideMixin): """ return the object, of which the item points. """ - return get_slide_from_sid(self.related_sid, True) + object = get_slide_from_sid(self.related_sid, element=True) + if object is None: + self.title = 'Item for deleted slide: %s' % self.related_sid + self.related_sid = None + self.save() + return self + else: + return object def get_related_type(self): """ diff --git a/openslides/agenda/tests.py b/openslides/agenda/tests.py index 0906eaef2..ca56e009d 100644 --- a/openslides/agenda/tests.py +++ b/openslides/agenda/tests.py @@ -15,9 +15,9 @@ from django.test.client import Client from django.contrib.auth.models import User from django.db.models.query import EmptyQuerySet -from projector.api import get_active_slide +from openslides.projector.api import get_active_slide -from agenda.models import Item +from openslides.agenda.models import Item class ItemTest(TestCase): def setUp(self): @@ -60,6 +60,10 @@ class ItemTest(TestCase): self.assertEqual(initial['parent'], 0) self.assertEqual(initial['weight'], item.weight) + def testRelated_sid(self): + self.item1.related_sid = 'foobar' + self.assertFalse(self.item1.get_related_slide() is None) + class ViewTest(TestCase): def setUp(self): From 998fb3e1eecd70a8f835db72e01d06bcd244a6d2 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 5 Aug 2012 11:48:03 +0200 Subject: [PATCH 3/4] fix #336. The admin could not edit the supporters from applications --- openslides/application/views.py | 46 ++++++++++++--------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/openslides/application/views.py b/openslides/application/views.py index 8e8fd39c7..538d57f4d 100644 --- a/openslides/application/views.py +++ b/openslides/application/views.py @@ -212,9 +212,6 @@ def edit(request, application_id=None): del_supporters = True original_supporters = [] if is_manager: - if application: # Edit application - for s in application.supporter.all(): - original_supporters.append(s) application = managerform.save(commit=False) elif application_id is None: application = Application(submitter=request.user) @@ -229,28 +226,20 @@ def edit(request, application_id=None): trivial_change = False application.save(request.user, trivial_change=trivial_change) if is_manager: - # log added supporters - supporters_added = [] - for s in application.supporter.all(): - if s not in original_supporters: - try: - supporters_added.append(unicode(s.profile)) - except Profile.DoesNotExist: - pass - if len(supporters_added) > 0: - log_added = ", ".join(supporters_added) - application.writelog(_("Supporter: +%s") % log_added, request.user) - # log removed supporters - supporters_removed = [] - for s in original_supporters: - if s not in application.supporter.all(): - try: - supporters_removed.append(unicode(s.profile)) - except Profile.DoesNotExist: - pass - if len(supporters_removed) > 0: - log_removed = ", ".join(supporters_removed) - application.writelog(_("Supporter: -%s") % log_removed, request.user) + try: + new_supporters = set(managerform.cleaned_data['supporter']) + except KeyError: + # The managerform has no field for the supporters + pass + else: + old_supporters = set(application.supporter.all()) + # add new supporters + for supporter in new_supporters.difference(old_supporters): + application.support(supporter) + # remove old supporters + for supporter in old_supporters.difference(new_supporters): + application.unsupport(supporter) + if application_id is None: messages.success(request, _('New application was successfully created.')) else: @@ -280,10 +269,9 @@ def edit(request, application_id=None): if application_id is None: initial = {'submitter': str(request.user.id)} else: - initial = {} - managerform = managerformclass(initial=initial, \ - instance=application, \ - prefix="manager") + initial = {'supporter': application.supporter.all()} + managerform = managerformclass( + initial=initial, instance=application, prefix="manager") else: managerform = None return { From 008c7436500bbb08534ea353f2982af3c66bf37e Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 5 Aug 2012 11:58:11 +0200 Subject: [PATCH 4/4] fixt #334. Let the anonymous user see the assignments by default --- openslides/config/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openslides/config/views.py b/openslides/config/views.py index 7cd479f26..07756193a 100644 --- a/openslides/config/views.py +++ b/openslides/config/views.py @@ -67,16 +67,16 @@ class GeneralConfig(FormView): anonymous = Group.objects.get(name='Anonymous') except Group.DoesNotExist: default_perms = [u'can_see_agenda', u'can_see_projector', - u'can_see_application'] + u'can_see_application', 'can_see_assignment'] anonymous = Group() anonymous.name = 'Anonymous' anonymous.save() anonymous.permissions = Permission.objects.filter( codename__in=default_perms) anonymous.save() - messages.success(self.request, - _('Anonymous access enabled. Please modify the "Anonymous" ' \ - 'group to fit your required permissions.')) + messages.success(self.request, + _('Anonymous access enabled. Please modify the "Anonymous" ' \ + 'group to fit your required permissions.')) else: config['system_enable_anonymous'] = False