def generate_choices(entries): results = [] for namespace, permissions in itertools.groupby(entries, lambda entry: entry.namespace): permission_options = [ (unicode(permission.pk), permission) for permission in permissions ] results.append( (PermissionNamespace.get(namespace), permission_options) ) return results
class MenuClassTestCase(GenericViewTestCase): def setUp(self): super(MenuClassTestCase, self).setUp() self.add_test_view(test_object=self.group) self.namespace = PermissionNamespace( TEST_PERMISSION_NAMESPACE_NAME, TEST_PERMISSION_NAMESPACE_TEXT ) self.permission = self.namespace.add_permission( name=TEST_PERMISSION_NAME, label=TEST_PERMISSION_LABEL ) self.menu = Menu(name=TEST_MENU_NAME) self.sub_menu = Menu(name=TEST_SUBMENU_NAME) self.link = Link(text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) Permission.invalidate_cache() def tearDown(self): Menu.remove(name=TEST_MENU_NAME) Menu.remove(name=TEST_SUBMENU_NAME) super(MenuClassTestCase, self).tearDown() def test_null_source_link_unbinding(self): self.menu.bind_links(links=(self.link,)) response = self.get(TEST_VIEW_NAME) context = Context({'request': response.wsgi_request}) self.assertEqual( self.menu.resolve(context=context)[0][0].link, self.link ) self.menu.unbind_links(links=(self.link,)) self.assertEqual(self.menu.resolve(context=context), []) def test_null_source_submenu_unbinding(self): self.menu.bind_links(links=(self.sub_menu,)) response = self.get(TEST_VIEW_NAME) context = Context({'request': response.wsgi_request}) self.assertEqual(self.menu.resolve(context=context), [[self.sub_menu]]) self.menu.unbind_links(links=(self.sub_menu,)) self.assertEqual(self.menu.resolve(context=context), [])
def setUp(self): super(LinkClassTestCase, self).setUp() self.add_test_view(test_object=self.group) self.namespace = PermissionNamespace( TEST_PERMISSION_NAMESPACE_NAME, TEST_PERMISSION_NAMESPACE_TEXT ) self.permission = self.namespace.add_permission( name=TEST_PERMISSION_NAME, label=TEST_PERMISSION_LABEL ) self.link = Link(text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) Permission.invalidate_cache()
def generate_choices(entries): results = [] entries = sorted( entries, key=lambda x: ( x.get_volatile_permission().namespace.label, x.get_volatile_permission().label ) ) for namespace, permissions in itertools.groupby(entries, lambda entry: entry.namespace): permission_options = [ (force_text(permission.pk), permission) for permission in permissions ] results.append( (PermissionNamespace.get(namespace), permission_options) ) return results
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('ocr', _('OCR')) permission_ocr_document = namespace.add_permission( name='ocr_document', label=_('Submit documents for OCR')) permission_ocr_content_view = namespace.add_permission( name='ocr_content_view', label=_('View the transcribed text from document')) permission_document_type_ocr_setup = namespace.add_permission( name='ocr_document_type_setup', label=_('Change document type OCR settings'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('tags', _('Tags')) permission_tag_create = namespace.add_permission(name='tag_create', label=_('Create new tags')) permission_tag_delete = namespace.add_permission(name='tag_delete', label=_('Delete tags')) permission_tag_view = namespace.add_permission(name='tag_view', label=_('View tags')) permission_tag_edit = namespace.add_permission(name='tag_edit', label=_('Edit tags')) permission_tag_attach = namespace.add_permission( name='tag_attach', label=_('Attach tags to documents')) permission_tag_remove = namespace.add_permission( name='tag_remove', label=_('Remove tags from documents'))
class LinkClassTestCase(GenericViewTestCase): def setUp(self): super(LinkClassTestCase, self).setUp() self.add_test_view(test_object=self.group) self.namespace = PermissionNamespace( TEST_PERMISSION_NAMESPACE_NAME, TEST_PERMISSION_NAMESPACE_TEXT ) self.permission = self.namespace.add_permission( name=TEST_PERMISSION_NAME, label=TEST_PERMISSION_LABEL ) self.link = Link(text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) Permission.invalidate_cache() def test_link_resolve(self): response = self.get(TEST_VIEW_NAME) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_permission_resolve_no_permission(self): self.login_user() link = Link( permissions=(self.permission,), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME ) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertEqual(resolved_link, None) def test_link_permission_resolve_with_permission(self): self.login_user() link = Link( permissions=(self.permission,), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME ) self.role.permissions.add(self.permission.stored_permission) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_permission_resolve_with_acl(self): # ACL is tested agains the resolved_object or just {{ object }} if not self.login_user() link = Link( permissions=(self.permission,), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME ) acl = AccessControlList.objects.create( content_object=self.group, role=self.role ) acl.permissions.add(self.permission.stored_permission) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertNotEqual(resolved_link, None) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_with_unicode_querystring_request(self): url = furl(reverse(TEST_VIEW_NAME)) url.args['unicode_key'] = TEST_UNICODE_STRING self.link.keep_query = True response = self.get(path=url.url) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, url.url) def test_link_with_querystring_preservation(self): previous_url = '{}?{}'.format( reverse(TEST_VIEW_NAME), TEST_QUERYSTRING_TWO_KEYS ) self.link.keep_query = True self.link.url = TEST_URL self.link.view = None response = self.get(path=previous_url) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual( resolved_link.url, '{}?{}'.format(TEST_URL, TEST_QUERYSTRING_TWO_KEYS) ) def test_link_with_querystring_preservation_with_key_removal(self): previous_url = '{}?{}'.format( reverse(TEST_VIEW_NAME), TEST_QUERYSTRING_TWO_KEYS ) self.link.keep_query = True self.link.url = TEST_URL self.link.view = None self.link.remove_from_query = ['key2'] response = self.get(path=previous_url) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual( resolved_link.url, '{}?{}'.format(TEST_URL, TEST_QUERYSTRING_ONE_KEY) )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('metadata', _('Metadata')) permission_metadata_document_edit = namespace.add_permission( name='metadata_document_edit', label=_('Edit a document\'s metadata') ) permission_metadata_document_add = namespace.add_permission( name='metadata_document_add', label=_('Add metadata to a document')) permission_metadata_document_remove = namespace.add_permission( name='metadata_document_remove', label=_('Remove metadata from a document') ) permission_metadata_document_view = namespace.add_permission( name='metadata_document_view', label=_('View metadata from a document') ) setup_namespace = PermissionNamespace('metadata_setup', _('Metadata setup')) permission_metadata_type_edit = setup_namespace.add_permission( name='metadata_type_edit', label=_('Edit metadata types') ) permission_metadata_type_create = setup_namespace.add_permission( name='metadata_type_create', label=_('Create new metadata types') ) permission_metadata_type_delete = setup_namespace.add_permission( name='metadata_type_delete', label=_('Delete metadata types') ) permission_metadata_type_view = setup_namespace.add_permission(
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('events', _('Events')) permission_events_view = namespace.add_permission( name='events_view', label=_('Access the events of an object') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('mailing', _('Mailing')) permission_mailing_link = namespace.add_permission( name='mail_link', label=_('Send document link via email') ) permission_mailing_send_document = namespace.add_permission( name='mail_document', label=_('Send document via email') ) permission_view_error_log = namespace.add_permission( name='view_error_log', label=_('View document mailing error log') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('acls', _('Access control lists')) permission_acl_edit = namespace.add_permission( name='acl_edit', label=_('Edit ACLs') ) permission_acl_view = namespace.add_permission( name='acl_view', label=_('View ACLs') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('django_gpg', _('Key management')) permission_key_delete = namespace.add_permission(name='key_delete', label=_('Delete keys')) permission_key_download = namespace.add_permission(name='key_download', label=_('Download keys')) permission_key_receive = namespace.add_permission( name='key_receive', label=_('Import keys from keyservers')) permission_key_sign = namespace.add_permission( name='key_sign', label=_('Use keys to sign content')) permission_key_upload = namespace.add_permission(name='key_upload', label=_('Upload keys')) permission_key_view = namespace.add_permission(name='key_view', label=_('View keys')) permission_keyserver_query = namespace.add_permission( name='keyserver_query', label=_('Query keyservers'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('mailing', _('Mailing')) permission_mailing_link = namespace.add_permission( name='mail_link', label=_('Send document link via email')) permission_mailing_send_document = namespace.add_permission( name='mail_document', label=_('Send document via email')) permission_view_error_log = namespace.add_permission( name='view_error_log', label=_('View system mailing error log')) permission_user_mailer_create = namespace.add_permission( name='user_mailer_create', label=_('Create a mailing profile')) permission_user_mailer_delete = namespace.add_permission( name='user_mailer_delete', label=_('Delete a mailing profile')) permission_user_mailer_edit = namespace.add_permission( name='user_mailer_edit', label=_('Edit a mailing profile')) permission_user_mailer_view = namespace.add_permission( name='user_mailer_view', label=_('View a mailing profile')) permission_user_mailer_use = namespace.add_permission( name='user_mailer_use', label=_('Use a mailing profile'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('linking', _('Smart links')) permission_smart_link_view = namespace.add_permission( name='smart_link_view', label=_('View existing smart links')) permission_smart_link_create = namespace.add_permission( name='smart_link_create', label=_('Create new smart links')) permission_smart_link_delete = namespace.add_permission( name='smart_link_delete', label=_('Delete smart links')) permission_smart_link_edit = namespace.add_permission( name='smart_link_edit', label=_('Edit smart links'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('sources_setup', _('Sources setup')) permission_sources_setup_create = namespace.add_permission( name='sources_setup_create', label=_('Create new document sources') ) permission_sources_setup_delete = namespace.add_permission( name='sources_setup_delete', label=_('Delete document sources') ) permission_sources_setup_edit = namespace.add_permission( name='sources_setup_edit', label=_('Edit document sources') ) permission_sources_setup_view = namespace.add_permission( name='sources_setup_view', label=_('View existing document sources') ) permission_staging_file_delete = namespace.add_permission( name='sources_staging_file_delete', label=_('Delete staging files') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('installation', _('Installation')) permission_installation_details = namespace.add_permission( name='installation_details', label=_('View installation environment details'))
class LinkClassTestCase(GenericViewTestCase): def setUp(self): super(LinkClassTestCase, self).setUp() self.add_test_view(test_object=self.group) self.namespace = PermissionNamespace( TEST_PERMISSION_NAMESPACE_NAME, TEST_PERMISSION_NAMESPACE_TEXT ) self.permission = self.namespace.add_permission( name=TEST_PERMISSION_NAME, label=TEST_PERMISSION_LABEL ) self.link = Link(text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) Permission.invalidate_cache() def test_link_resolve(self): response = self.get(TEST_VIEW_NAME) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_permission_resolve_no_permission(self): self.login( username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD ) link = Link( permissions=(self.permission,), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME ) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertEqual(resolved_link, None) def test_link_permission_resolve_with_permission(self): self.login( username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD ) link = Link( permissions=(self.permission,), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME ) self.role.permissions.add(self.permission.stored_permission) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_permission_resolve_with_acl(self): # ACL is tested agains the resolved_object or just {{ object }} if not self.login( username=TEST_USER_USERNAME, password=TEST_USER_PASSWORD ) link = Link( permissions=(self.permission,), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME ) acl = AccessControlList.objects.create( content_object=self.group, role=self.role ) acl.permissions.add(self.permission.stored_permission) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertNotEqual(resolved_link, None) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('registers', _('Registro documenti')) permission_document_register_in = namespace.add_permission( name='register_in_document', label=_('Registra documenti in entrata')) permission_document_register_in_override = namespace.add_permission( name='register_in_document_override', label=_('Forza registro documenti in entrata')) permission_document_register_out = namespace.add_permission( name='register_out_document', label=_('Registra documenti in uscita')) permission_document_register_out_detail_view = namespace.add_permission( name='register_out_detail_view', label=_('Check out details view'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('task_manager', _('Task manager')) permission_task_view = namespace.add_permission( name='task_view', label=_('View tasks') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('document_states', _('Document workflows')) permission_workflow_create = namespace.add_permission( name='workflow_create', label=_('Create workflows')) permission_workflow_delete = namespace.add_permission( name='workflow_delte', label=_('Delete workflows')) permission_workflow_edit = namespace.add_permission(name='workflow_edit', label=_('Edit workflows')) permission_workflow_view = namespace.add_permission(name='workflow_view', label=_('View workflows')) # Translators: This text refers to the permission to grant user the ability to # 'transition workflows' from one state to another, to move the workflow # forwards permission_workflow_transition = namespace.add_permission( name='workflow_transition', label=_('Transition workflows'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('checkouts', _('Document checkout')) permission_document_checkin = namespace.add_permission( name='checkin_document', label=_('Check in documents') ) permission_document_checkin_override = namespace.add_permission( name='checkin_document_override', label=_('Forcefully check in documents') ) permission_document_checkout = namespace.add_permission( name='checkout_document', label=_('Check out documents') ) permission_document_checkout_detail_view = namespace.add_permission( name='checkout_detail_view', label=_('Check out details view') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('sources_setup', _('Sources setup')) permission_sources_setup_create = namespace.add_permission( name='sources_setup_create', label=_('Create new document sources')) permission_sources_setup_delete = namespace.add_permission( name='sources_setup_delete', label=_('Delete document sources')) permission_sources_setup_edit = namespace.add_permission( name='sources_setup_edit', label=_('Edit document sources')) permission_sources_setup_view = namespace.add_permission( name='sources_setup_view', label=_('View existing document sources')) permission_staging_file_delete = namespace.add_permission( name='sources_staging_file_delete', label=_('Delete staging files'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('documents', _('Documents')) permission_document_create = namespace.add_permission( name='document_create', label=_('Create documents') ) permission_document_delete = namespace.add_permission( name='document_delete', label=_('Delete documents') ) permission_document_trash = namespace.add_permission( name='document_trash', label=_('Trash documents') ) permission_document_download = namespace.add_permission( name='document_download', label=_('Download documents') ) permission_document_edit = namespace.add_permission( name='document_edit', label=_('Edit documents') ) permission_document_new_version = namespace.add_permission( name='document_new_version', label=_('Create new document versions') ) permission_document_properties_edit = namespace.add_permission( name='document_properties_edit', label=_('Edit document properties') ) permission_document_print = namespace.add_permission( name='document_print', label=_('Print documents')
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('cabinets', _('Cabinets')) # Translators: this refers to the permission that will allow users to add # documents to cabinets. permission_cabinet_add_document = namespace.add_permission( name='cabinet_add_document', label=_('Add documents to cabinets') ) permission_cabinet_create = namespace.add_permission( name='cabinet_create', label=_('Create cabinets') ) permission_cabinet_delete = namespace.add_permission( name='cabinet_delete', label=_('Delete cabinets') ) permission_cabinet_edit = namespace.add_permission( name='cabinet_edit', label=_('Edit cabinets') ) permission_cabinet_remove_document = namespace.add_permission( name='cabinet_remove_document', label=_('Remove documents from cabinets') ) permission_cabinet_view = namespace.add_permission( name='cabinet_view', label=_('View cabinets') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('motd', _('Message of the day')) permission_message_create = namespace.add_permission( name='message_create', label=_('Create messages') ) permission_message_delete = namespace.add_permission( name='message_delete', label=_('Delete messages') ) permission_message_edit = namespace.add_permission( name='message_edit', label=_('Edit messages') ) permission_message_view = namespace.add_permission( name='message_view', label=_('View messages') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('django_gpg', _('Key management')) permission_key_view = namespace.add_permission(name='key_view', label=_('View keys')) permission_key_delete = namespace.add_permission(name='key_delete', label=_('Delete keys')) permission_keyserver_query = namespace.add_permission( name='keyserver_query', label=_('Query keyservers')) permission_key_receive = namespace.add_permission( name='key_receive', label=_('Import keys from keyservers'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('document_parsing', _('Document parsing')) permission_content_view = namespace.add_permission( name='content_view', label=_('View the content of a document') ) permission_document_type_parsing_setup = namespace.add_permission( name='document_type_setup', label=_('Change document type parsing settings') ) permission_parse_document = namespace.add_permission( name='parse_document', label=_('Parse the content of a document') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('folders', _('Folders')) permission_folder_create = namespace.add_permission(name='folder_create', label=_('Create folders')) permission_folder_edit = namespace.add_permission(name='folder_edit', label=_('Edit folders')) permission_folder_delete = namespace.add_permission(name='folder_delete', label=_('Delete folders')) permission_folder_remove_document = namespace.add_permission( name='folder_remove_document', label=_('Remove documents from folders')) permission_folder_view = namespace.add_permission(name='folder_view', label=_('View folders')) # Translators: this refers to the permission that will allow users to add # documents to folders. permission_folder_add_document = namespace.add_permission( name='folder_add_document', label=_('Add documents to folders'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('task_manager', _('Task manager')) permission_task_view = namespace.add_permission(name='task_view', label=_('View tasks'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace( 'document_signatures', _('Document signatures') ) permission_document_version_sign_detached = namespace.add_permission( name='document_version_sign_detached', label=_('Sign documents with detached signatures') ) permission_document_version_sign_embedded = namespace.add_permission( name='document_version_sign_embedded', label=_('Sign documents with embedded signatures') ) permission_document_version_signature_delete = namespace.add_permission( name='document_version_signature_delete', label=_('Delete detached signatures') ) permission_document_version_signature_download = namespace.add_permission( name='document_version_signature_download', label=_('Download detached document signatures') ) permission_document_version_signature_upload = namespace.add_permission( name='document_version_signature_upload', label=_('Upload detached document signatures') ) permission_document_version_signature_verify = namespace.add_permission(
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('mailing', _('Mailing')) permission_mailing_link = namespace.add_permission( name='mail_link', label=_('Send document link via email') ) permission_mailing_send_document = namespace.add_permission( name='mail_document', label=_('Send document via email') ) permission_view_error_log = namespace.add_permission( name='view_error_log', label=_('View system mailing error log') ) permission_user_mailer_create = namespace.add_permission( name='user_mailer_create', label=_('Create a mailing profile') ) permission_user_mailer_delete = namespace.add_permission( name='user_mailer_delete', label=_('Delete a mailing profile') ) permission_user_mailer_edit = namespace.add_permission( name='user_mailer_edit', label=_('Edit a mailing profile') ) permission_user_mailer_view = namespace.add_permission( name='user_mailer_view', label=_('View a mailing profile') ) permission_user_mailer_use = namespace.add_permission( name='user_mailer_use', label=_('Use a mailing profile')
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('cabinets', _('Cabinets')) # Translators: this refers to the permission that will allow users to add # documents to cabinets. permission_cabinet_add_document = namespace.add_permission( name='cabinet_add_document', label=_('Add documents to cabinets')) permission_cabinet_create = namespace.add_permission( name='cabinet_create', label=_('Create cabinets')) permission_cabinet_delete = namespace.add_permission( name='cabinet_delete', label=_('Delete cabinets')) permission_cabinet_edit = namespace.add_permission(name='cabinet_edit', label=_('Edit cabinets')) permission_cabinet_remove_document = namespace.add_permission( name='cabinet_remove_document', label=_('Remove documents from cabinets')) permission_cabinet_view = namespace.add_permission(name='cabinet_view', label=_('View cabinets'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('smart_settings', _('Smart settings')) permission_settings_view = namespace.add_permission( name='permission_settings_view', label=_('View settings') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('statistics', _('Statistics')) permission_statistics_view = namespace.add_permission( name='statistics_view', label=_('View statistics'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('document_indexing', _('Indexing')) permission_document_indexing_create = namespace.add_permission( name='document_index_create', label=_('Create new document indexes')) permission_document_indexing_edit = namespace.add_permission( name='document_index_edit', label=_('Edit document indexes')) permission_document_indexing_delete = namespace.add_permission( name='document_index_delete', label=_('Delete document indexes')) permission_document_indexing_view = namespace.add_permission( name='document_index_view', label=_('View document indexes')) permission_document_indexing_rebuild = namespace.add_permission( name='document_rebuild_indexes', label=_('Rebuild document indexes'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('metadata', _('Metadata')) permission_metadata_document_edit = namespace.add_permission( name='metadata_document_edit', label=_('Edit a document\'s metadata')) permission_metadata_document_add = namespace.add_permission( name='metadata_document_add', label=_('Add metadata to a document')) permission_metadata_document_remove = namespace.add_permission( name='metadata_document_remove', label=_('Remove metadata from a document')) permission_metadata_document_view = namespace.add_permission( name='metadata_document_view', label=_('View metadata from a document')) setup_namespace = PermissionNamespace('metadata_setup', _('Metadata setup')) permission_metadata_type_edit = setup_namespace.add_permission( name='metadata_type_edit', label=_('Edit metadata types')) permission_metadata_type_create = setup_namespace.add_permission( name='metadata_type_create', label=_('Create new metadata types')) permission_metadata_type_delete = setup_namespace.add_permission( name='metadata_type_delete', label=_('Delete metadata types')) permission_metadata_type_view = setup_namespace.add_permission( name='metadata_type_view', label=_('View metadata types'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('motd', _('Message of the day')) permission_message_create = namespace.add_permission( name='message_create', label=_('Create messages')) permission_message_delete = namespace.add_permission( name='message_delete', label=_('Delete messages')) permission_message_edit = namespace.add_permission(name='message_edit', label=_('Edit messages')) permission_message_view = namespace.add_permission(name='message_view', label=_('View messages'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('comments', _('Comments')) permission_comment_create = namespace.add_permission( name='comment_create', label=_('Create new comments') ) permission_comment_delete = namespace.add_permission( name='comment_delete', label=_('Delete comments') ) permission_comment_view = namespace.add_permission( name='comment_view', label=_('View comments') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('installation', _('Installation')) permission_installation_details = namespace.add_permission( name='installation_details', label=_('View installation environment details') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('document_parsing', _('Document parsing')) permission_content_view = namespace.add_permission( name='content_view', label=_('View the content of a document') ) permission_parse_document = namespace.add_permission( name='parse_document', label=_('Parse the content of a document') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('document_states', _('Document workflows')) permission_workflow_create = namespace.add_permission( name='workflow_create', label=_('Create workflows') ) permission_workflow_delete = namespace.add_permission( name='workflow_delte', label=_('Delete workflows') ) permission_workflow_edit = namespace.add_permission( name='workflow_edit', label=_('Edit workflows') ) permission_workflow_view = namespace.add_permission( name='workflow_view', label=_('View workflows') ) # Translators: This text refers to the permission to grant user the ability to # 'transition workflows' from one state to another, to move the workflow # forwards permission_workflow_transition = namespace.add_permission( name='workflow_transition', label=_('Transition workflows') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('statistics', _('Statistics')) permission_statistics_view = namespace.add_permission( name='statistics_view', label=_('View statistics') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('django_gpg', _('Key management')) permission_key_view = namespace.add_permission( name='key_view', label=_('View keys') ) permission_key_delete = namespace.add_permission( name='key_delete', label=_('Delete keys') ) permission_keyserver_query = namespace.add_permission( name='keyserver_query', label=_('Query keyservers') ) permission_key_receive = namespace.add_permission( name='key_receive', label=_('Import keys from keyservers') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('checkouts', _('Document checkout')) permission_document_checkin = namespace.add_permission( name='checkin_document', label=_('Check in documents')) permission_document_checkin_override = namespace.add_permission( name='checkin_document_override', label=_('Forcefully check in documents')) permission_document_checkout = namespace.add_permission( name='checkout_document', label=_('Check out documents')) permission_document_checkout_detail_view = namespace.add_permission( name='checkout_detail_view', label=_('Check out details view'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('user_management', _('User management')) permission_group_create = namespace.add_permission( name='group_create', label=_('Create new groups') ) permission_group_delete = namespace.add_permission( name='group_delete', label=_('Delete existing groups') ) permission_group_edit = namespace.add_permission( name='group_edit', label=_('Edit existing groups') ) permission_group_view = namespace.add_permission( name='group_view', label=_('View existing groups') ) permission_user_create = namespace.add_permission( name='user_create', label=_('Create new users') ) permission_user_delete = namespace.add_permission( name='user_delete', label=_('Delete existing users') ) permission_user_edit = namespace.add_permission( name='user_edit', label=_('Edit existing users') ) permission_user_view = namespace.add_permission( name='user_view', label=_('View existing users')
class LinkClassTestCase(GenericViewTestCase): def setUp(self): super(LinkClassTestCase, self).setUp() self.add_test_view(test_object=self.group) self.namespace = PermissionNamespace(TEST_PERMISSION_NAMESPACE_NAME, TEST_PERMISSION_NAMESPACE_TEXT) self.permission = self.namespace.add_permission( name=TEST_PERMISSION_NAME, label=TEST_PERMISSION_LABEL) self.link = Link(text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) Permission.invalidate_cache() def test_link_resolve(self): response = self.get(TEST_VIEW_NAME) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_permission_resolve_no_permission(self): self.login_user() link = Link(permissions=(self.permission, ), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertEqual(resolved_link, None) def test_link_permission_resolve_with_permission(self): self.login_user() link = Link(permissions=(self.permission, ), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) self.role.permissions.add(self.permission.stored_permission) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_permission_resolve_with_acl(self): # ACL is tested agains the resolved_object or just {{ object }} if not self.login_user() link = Link(permissions=(self.permission, ), text=TEST_LINK_TEXT, view=TEST_VIEW_NAME) acl = AccessControlList.objects.create(content_object=self.group, role=self.role) acl.permissions.add(self.permission.stored_permission) response = self.get(TEST_VIEW_NAME) response.context.update({'request': response.wsgi_request}) context = Context(response.context) resolved_link = link.resolve(context=context) self.assertNotEqual(resolved_link, None) self.assertEqual(resolved_link.url, reverse(TEST_VIEW_NAME)) def test_link_with_unicode_querystring_request(self): url = furl(reverse(TEST_VIEW_NAME)) url.args['unicode_key'] = TEST_UNICODE_STRING self.link.keep_query = True response = self.get(path=url.url) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, url.url) def test_link_with_querystring_preservation(self): previous_url = '{}?{}'.format(reverse(TEST_VIEW_NAME), TEST_QUERYSTRING_TWO_KEYS) self.link.keep_query = True self.link.url = TEST_URL self.link.view = None response = self.get(path=previous_url) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, '{}?{}'.format(TEST_URL, TEST_QUERYSTRING_TWO_KEYS)) def test_link_with_querystring_preservation_with_key_removal(self): previous_url = '{}?{}'.format(reverse(TEST_VIEW_NAME), TEST_QUERYSTRING_TWO_KEYS) self.link.keep_query = True self.link.url = TEST_URL self.link.view = None self.link.remove_from_query = ['key2'] response = self.get(path=previous_url) context = Context({'request': response.wsgi_request}) resolved_link = self.link.resolve(context=context) self.assertEqual(resolved_link.url, '{}?{}'.format(TEST_URL, TEST_QUERYSTRING_ONE_KEY))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('ocr', _('OCR')) permission_ocr_document = namespace.add_permission( name='ocr_document', label=_('Submit documents for OCR') ) permission_ocr_content_view = namespace.add_permission( name='ocr_content_view', label=_('View the transcribed text from document') ) permission_document_type_ocr_setup = namespace.add_permission( name='ocr_document_type_setup', label=_('Change document type OCR settings') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace("document_signatures", _("Document signatures")) permission_document_verify = namespace.add_permission(name="document_verify", label=_("Verify document signatures")) permission_signature_delete = namespace.add_permission(name="signature_delete", label=_("Delete detached signatures")) permission_signature_download = namespace.add_permission( name="signature_download", label=_("Download detached signatures") ) permission_signature_upload = namespace.add_permission(name="signature_upload", label=_("Upload detached signatures"))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('tags', _('Tags')) permission_tag_create = namespace.add_permission( name='tag_create', label=_('Create new tags') ) permission_tag_delete = namespace.add_permission( name='tag_delete', label=_('Delete tags') ) permission_tag_view = namespace.add_permission( name='tag_view', label=_('View tags') ) permission_tag_edit = namespace.add_permission( name='tag_edit', label=_('Edit tags') ) permission_tag_attach = namespace.add_permission( name='tag_attach', label=_('Attach tags to documents') ) permission_tag_remove = namespace.add_permission( name='tag_remove', label=_('Remove tags from documents') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('django_gpg', _('Key management')) permission_key_delete = namespace.add_permission( name='key_delete', label=_('Delete keys') ) permission_key_download = namespace.add_permission( name='key_download', label=_('Download keys') ) permission_key_receive = namespace.add_permission( name='key_receive', label=_('Import keys from keyservers') ) permission_key_sign = namespace.add_permission( name='key_sign', label=_('Use keys to sign content') ) permission_key_upload = namespace.add_permission( name='key_upload', label=_('Upload keys') ) permission_key_view = namespace.add_permission( name='key_view', label=_('View keys') ) permission_keyserver_query = namespace.add_permission( name='keyserver_query', label=_('Query keyservers') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('converter', _('Converter')) permission_transformation_create = namespace.add_permission( name='transformation_create', label=_('Create new transformations') ) permission_transformation_delete = namespace.add_permission( name='transformation_delete', label=_('Delete transformations') ) permission_transformation_edit = namespace.add_permission( name='transformation_edit', label=_('Edit transformations') ) permission_transformation_view = namespace.add_permission( name='transformation_view', label=_('View existing transformations') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from permissions import PermissionNamespace namespace = PermissionNamespace('user_management', _('User management')) permission_group_create = namespace.add_permission( name='group_create', label=_('Create new groups')) permission_group_delete = namespace.add_permission( name='group_delete', label=_('Delete existing groups')) permission_group_edit = namespace.add_permission( name='group_edit', label=_('Edit existing groups')) permission_group_view = namespace.add_permission( name='group_view', label=_('View existing groups')) permission_user_create = namespace.add_permission(name='user_create', label=_('Create new users')) permission_user_delete = namespace.add_permission( name='user_delete', label=_('Delete existing users')) permission_user_edit = namespace.add_permission(name='user_edit', label=_('Edit existing users')) permission_user_view = namespace.add_permission(name='user_view', label=_('View existing users'))