Merge pull request #1164 from normanjaeckel/Issues-1.5.1
Fix issues for 1.5.1
This commit is contained in:
commit
5c44a279fc
@ -8,6 +8,14 @@ Version 1.5.1 (unreleased)
|
||||
==========================
|
||||
[https://github.com/OpenSlides/OpenSlides/issues?milestone=15]
|
||||
|
||||
Participant:
|
||||
- Added permission to see participants also to the manager group.
|
||||
Files:
|
||||
- Fixed error when a file was removed from filesystem.
|
||||
Other:
|
||||
- Fixed http status code when requesting a non-existing static page using
|
||||
Tordado web server.
|
||||
|
||||
|
||||
Version 1.5 (2013-11-25)
|
||||
========================
|
||||
|
@ -4,6 +4,7 @@ import mimetypes
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext_lazy, ugettext_noop
|
||||
|
||||
from openslides.projector.models import SlideMixin
|
||||
@ -80,15 +81,20 @@ class Mediafile(SlideMixin, models.Model):
|
||||
|
||||
def get_filesize(self):
|
||||
"""
|
||||
Transforms Bytes to Kilobytes or Megabytes. Returns the size as string.
|
||||
Transforms bytes to kilobytes or megabytes. Returns the size as string.
|
||||
"""
|
||||
# TODO: Read http://stackoverflow.com/a/1094933 and think about it.
|
||||
size = self.mediafile.size
|
||||
if size < 1024:
|
||||
return '< 1 kB'
|
||||
if size >= 1024 * 1024:
|
||||
mB = size / 1024 / 1024
|
||||
return '%d MB' % mB
|
||||
try:
|
||||
size = self.mediafile.size
|
||||
except OSError:
|
||||
size_string = _('unknown')
|
||||
else:
|
||||
kB = size / 1024
|
||||
return '%d kB' % kB
|
||||
if size < 1024:
|
||||
size_string = '< 1 kB'
|
||||
elif size >= 1024 * 1024:
|
||||
mB = size / 1024 / 1024
|
||||
size_string = '%d MB' % mB
|
||||
else:
|
||||
kB = size / 1024
|
||||
size_string = '%d kB' % kB
|
||||
return size_string
|
||||
|
@ -27,7 +27,7 @@
|
||||
{% for mediafile in mediafile_list %}
|
||||
<tr class="{% if mediafile.is_active_slide %}activeline{% endif %}">
|
||||
<td><a href="{{ mediafile.mediafile.url }}">{{ mediafile }}</a></td>
|
||||
<td>{{ mediafile.filetype }}</td>
|
||||
<td>{% trans mediafile.filetype %}</td>
|
||||
<td>{{ mediafile.get_filesize }}</td>
|
||||
<td>{{ mediafile.timestamp }}</td>
|
||||
<td><a href="{{ mediafile.uploader|absolute_url }}">{{ mediafile.uploader }}</a></td>
|
||||
|
@ -118,6 +118,7 @@ def create_builtin_groups_and_admin(sender, **kwargs):
|
||||
|
||||
group_staff = Group.objects.create(name=ugettext_noop('Staff'), pk=4)
|
||||
group_staff.permissions.add(perm_7, perm_9, perm_10, perm_10a, perm_11, perm_12, perm_13, perm_14, perm_15, perm_15a, perm_16)
|
||||
group_staff.permissions.add(perm_6) # TODO: Remove this redundancy after cleanup of the permission system
|
||||
|
||||
# Admin user
|
||||
create_or_reset_admin_user()
|
||||
|
@ -43,10 +43,10 @@ class DjangoStaticFileHandler(StaticFileHandler):
|
||||
# a shared root prefix
|
||||
# - we do not handle self.default_filename (we do not use it and it
|
||||
# does not make much sense here anyway)
|
||||
if not os.path.exists(absolute_path):
|
||||
if absolute_path is None or not os.path.exists(absolute_path):
|
||||
raise HTTPError(404)
|
||||
if not os.path.isfile(absolute_path):
|
||||
raise HTTPError(403, "%s is not a file", self.path)
|
||||
raise HTTPError(403, 'The requested resource is not a file.')
|
||||
return absolute_path
|
||||
|
||||
|
||||
|
@ -195,4 +195,5 @@ class MediafileTest(TestCase):
|
||||
bigfile.seek(1048575)
|
||||
bigfile.write('0')
|
||||
self.assertEqual(object_4.get_filesize(), '1 MB')
|
||||
object_4.mediafile.delete()
|
||||
os.remove(mediafile_4_path)
|
||||
self.assertEqual(object_4.get_filesize(), 'unknown')
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
import re
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test.client import Client
|
||||
|
||||
from openslides.config.api import config
|
||||
from openslides.participant.api import get_registered_group
|
||||
from openslides.participant.models import get_protected_perm, Group, User
|
||||
from openslides.utils.test import TestCase
|
||||
|
||||
@ -93,7 +96,9 @@ class GroupViews(TestCase):
|
||||
class LockoutProtection(TestCase):
|
||||
"""
|
||||
Tests that a manager user can not lockout himself by doing
|
||||
something that removes his last permission to manage participants.
|
||||
something that removes his last permission to manage participants. Tests
|
||||
also that he can see the participant app (although there is no absolute
|
||||
protection).
|
||||
"""
|
||||
def setUp(self):
|
||||
self.user = User.objects.get(pk=1)
|
||||
@ -159,6 +164,17 @@ class LockoutProtection(TestCase):
|
||||
field=None,
|
||||
errors='You can not remove the permission to manage participants from the last group you are in.')
|
||||
|
||||
def test_remove_permission_can_see_participant_from_registered(self):
|
||||
self.assertTrue(self.user.has_perm('participant.can_see_participant'))
|
||||
# Remove perm from registered group
|
||||
can_see_perm = Permission.objects.get(
|
||||
content_type=ContentType.objects.get(app_label='participant', model='user'),
|
||||
codename='can_see_participant')
|
||||
get_registered_group().permissions.remove(can_see_perm)
|
||||
# Reload user
|
||||
self.user = User.objects.get(pk=1)
|
||||
self.assertTrue(self.user.has_perm('participant.can_see_participant'))
|
||||
|
||||
|
||||
class TestUserSettings(TestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user