def setUp(self): from history.api import register_history_type from .events import (HISTORY_DOCUMENT_CREATED, HISTORY_DOCUMENT_EDITED, HISTORY_DOCUMENT_DELETED) self.admin_user = User.objects.create_superuser(username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD) self.client = Client() # There events are registered upon loading documents/__init__.py # while Django's test DB is still not created, so we created them by # hand. register_history_type(HISTORY_DOCUMENT_CREATED) register_history_type(HISTORY_DOCUMENT_EDITED) register_history_type(HISTORY_DOCUMENT_DELETED)
document_type_filename_create, document_type_filename_edit, document_type_filename_delete) from .models import (Document, DocumentPage, DocumentPageTransformation, DocumentType, DocumentTypeFilename, DocumentVersion) from .permissions import ( PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_TRANSFORM, PERMISSION_DOCUMENT_EDIT, PERMISSION_DOCUMENT_VERSION_REVERT, PERMISSION_DOCUMENT_NEW_VERSION) from .statistics import DocumentStatistics, DocumentUsageStatistics from .urls import api_urls from .widgets import document_thumbnail # History setup register_history_type(HISTORY_DOCUMENT_CREATED) register_history_type(HISTORY_DOCUMENT_EDITED) register_history_type(HISTORY_DOCUMENT_DELETED) # Register document type links register_links(DocumentType, [document_type_edit, document_type_delete, document_type_filename_list]) register_links(DocumentTypeFilename, [document_type_filename_edit, document_type_filename_delete]) register_links(['setup_document_type_metadata', 'document_type_filename_delete', 'document_type_create', 'document_type_filename_create', 'document_type_filename_edit', 'document_type_filename_list', 'document_type_list', 'document_type_edit', 'document_type_delete'], [document_type_list, document_type_create], menu_name='secondary_menu') register_links([DocumentTypeFilename, 'document_type_filename_list', 'document_type_filename_create'], [document_type_filename_create], menu_name='sidebar') # Register document links register_links(Document, [document_view_simple, document_edit, document_print, document_delete, document_download, document_find_duplicates, document_clear_transformations]) register_multi_item_links(['document_find_duplicates', 'folder_view', 'index_instance_node_view', 'search', 'results', 'document_group_view', 'document_list', 'document_list_recent', 'tag_tagged_item_list'], [document_multiple_clear_transformations, document_multiple_delete, document_multiple_download]) # Document Version links
document_type_edit, document_type_delete, document_type_create, document_type_filename_list, document_type_filename_create, document_type_filename_edit, document_type_filename_delete) from .models import (Document, DocumentPage, DocumentPageTransformation, DocumentType, DocumentTypeFilename, DocumentVersion) from .permissions import ( PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_TRANSFORM, PERMISSION_DOCUMENT_EDIT, PERMISSION_DOCUMENT_VERSION_REVERT, PERMISSION_DOCUMENT_NEW_VERSION) from .statistics import DocumentStatistics, DocumentUsageStatistics from .urls import api_urls from .widgets import document_thumbnail # History setup register_history_type(HISTORY_DOCUMENT_CREATED) register_history_type(HISTORY_DOCUMENT_EDITED) register_history_type(HISTORY_DOCUMENT_DELETED) # Register document type links register_links( DocumentType, [document_type_edit, document_type_delete, document_type_filename_list]) register_links(DocumentTypeFilename, [document_type_filename_edit, document_type_filename_delete]) register_links([ 'setup_document_type_metadata', 'document_type_filename_delete', 'document_type_create', 'document_type_filename_create', 'document_type_filename_edit', 'document_type_filename_list', 'document_type_list', 'document_type_edit', 'document_type_delete'
from .tasks import task_check_expired_check_outs from .events import (HISTORY_DOCUMENT_CHECKED_OUT, HISTORY_DOCUMENT_CHECKED_IN, HISTORY_DOCUMENT_AUTO_CHECKED_IN, HISTORY_DOCUMENT_FORCEFUL_CHECK_IN) def initialize_document_checkout_extra_methods(): Document.add_to_class('is_checked_out', lambda document: DocumentCheckout.objects.is_document_checked_out(document)) Document.add_to_class('check_in', lambda document, user=None: DocumentCheckout.objects.check_in_document(document, user)) Document.add_to_class('checkout_info', lambda document: DocumentCheckout.objects.document_checkout_info(document)) Document.add_to_class('checkout_state', lambda document: DocumentCheckout.objects.document_checkout_state(document)) Document.add_to_class('is_new_versions_allowed', lambda document, user=None: DocumentCheckout.objects.is_document_new_versions_allowed(document, user)) register_top_menu(name='checkouts', link=checkout_list) register_links(Document, [checkout_info], menu_name='form_header') register_links(['checkout_info', 'checkout_document', 'checkin_document'], [checkout_document, checkin_document], menu_name="sidebar") class_permissions(Document, [ PERMISSION_DOCUMENT_CHECKOUT, PERMISSION_DOCUMENT_CHECKIN, PERMISSION_DOCUMENT_CHECKIN_OVERRIDE, PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE ]) CHECK_EXPIRED_CHECK_OUTS_INTERVAL=60 # Lowest check out expiration allowed register_interval_job('task_check_expired_check_outs', _(u'Check expired check out documents and checks them in.'), task_check_expired_check_outs, seconds=CHECK_EXPIRED_CHECK_OUTS_INTERVAL) initialize_document_checkout_extra_methods() register_history_type(HISTORY_DOCUMENT_CHECKED_OUT) register_history_type(HISTORY_DOCUMENT_CHECKED_IN) register_history_type(HISTORY_DOCUMENT_AUTO_CHECKED_IN) register_history_type(HISTORY_DOCUMENT_FORCEFUL_CHECK_IN)
'checkout_state', lambda document: DocumentCheckout.objects. document_checkout_state(document)) Document.add_to_class('is_new_versions_allowed', lambda document, user=None: DocumentCheckout.objects. is_document_new_versions_allowed(document, user)) register_top_menu(name='checkouts', link=checkout_list) register_links(Document, [checkout_info], menu_name='form_header') register_links(['checkout_info', 'checkout_document', 'checkin_document'], [checkout_document, checkin_document], menu_name="sidebar") class_permissions(Document, [ PERMISSION_DOCUMENT_CHECKOUT, PERMISSION_DOCUMENT_CHECKIN, PERMISSION_DOCUMENT_CHECKIN_OVERRIDE, PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE ]) CHECK_EXPIRED_CHECK_OUTS_INTERVAL = 60 # Lowest check out expiration allowed register_interval_job( 'task_check_expired_check_outs', _(u'Check expired check out documents and checks them in.'), task_check_expired_check_outs, seconds=CHECK_EXPIRED_CHECK_OUTS_INTERVAL) initialize_document_checkout_extra_methods() register_history_type(HISTORY_DOCUMENT_CHECKED_OUT) register_history_type(HISTORY_DOCUMENT_CHECKED_IN) register_history_type(HISTORY_DOCUMENT_AUTO_CHECKED_IN) register_history_type(HISTORY_DOCUMENT_FORCEFUL_CHECK_IN)