Merge pull request #2 from ostcar/stable/1.2.x

Stable/1.2.x
This commit is contained in:
Oskar Hahn 2012-08-05 03:24:45 -07:00
commit 6ec3bbfe3b
5 changed files with 38 additions and 88 deletions

View File

@ -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)

View File

@ -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):
"""

View File

@ -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):

View File

@ -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 {

View File

@ -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