diff --git a/CHANGES b/CHANGES index 0968efe..0f6e49b 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ Version 0.7.3 * Missing context variable in catalog list (Issue #87 - Thanks @kunitoki) * Added support for Yandex translation API (Issue #89 - Thanks @BlackWizard) See supported languages and limitations here: https://github.com/mbi/django-rosetta/pull/89 * Removed support for the signed_cookies SESSION_ENGINE + SessionRosettaStorage in Django 1.6, because serialization of POFiles would fail +* Simplified the group membership test (Issue #90 - Thanks @dotsbb) Version 0.7.2 ------------- diff --git a/rosetta/access.py b/rosetta/access.py index b3641bc..6cc511f 100644 --- a/rosetta/access.py +++ b/rosetta/access.py @@ -28,9 +28,4 @@ def is_superuser_staff_or_in_translators_group(user): elif user.is_superuser and user.is_staff: return True else: - try: - from django.contrib.auth.models import Group - translators = Group.objects.get(name='translators') - return translators in user.groups.all() - except Group.DoesNotExist: - return False + return user.groups.filter(name='translators').exists() diff --git a/rosetta/conf/settings.py b/rosetta/conf/settings.py index 0c9ace3..38df0db 100644 --- a/rosetta/conf/settings.py +++ b/rosetta/conf/settings.py @@ -60,3 +60,7 @@ STORAGE_CLASS = getattr(settings, 'ROSETTA_STORAGE_CLASS', 'rosetta.storage.Cach ROSETTA_CACHE_NAME = getattr(settings, 'ROSETTA_CACHE_NAME', 'default' if settings.CACHES.get('rosetta', None) is None else 'rosetta') + +# Require users to be authenticated (and Superusers or in group "translators"). +# Set this to False at your own risk +ROSETTA_REQUIRES_AUTH = getattr(settings, 'ROSETTA_REQUIRES_AUTH', True) diff --git a/rosetta/tests/tests.py b/rosetta/tests/tests.py index 2a126e1..d731883 100644 --- a/rosetta/tests/tests.py +++ b/rosetta/tests/tests.py @@ -57,6 +57,7 @@ class RosettaTestCase(TestCase): self.__session_engine = settings.SESSION_ENGINE self.__storage_class = rosetta_settings.STORAGE_CLASS + self.__require_auth = rosetta_settings.ROSETTA_REQUIRES_AUTH shutil.copy(self.dest_file, self.dest_file + '.orig') @@ -64,6 +65,7 @@ class RosettaTestCase(TestCase): settings.LANGUAGES = self.__old_settings_languages settings.SESSION_ENGINE = self.__session_engine rosetta_settings.STORAGE_CLASS = self.__storage_class + rosetta_settings.ROSETTA_REQUIRES_AUTH = self.__require_auth shutil.move(self.dest_file + '.orig', self.dest_file) def test_1_ListLoading(self): @@ -581,7 +583,7 @@ class RosettaTestCase(TestCase): r = self.client.get(reverse('rosetta-pick-file')) self.assertTrue('