Ejemplo n.º 1
0
    PERMISSION_FOLDER_ADD_DOCUMENT)

register_multi_item_links(['folder_view'], [folder_document_multiple_remove])

register_links(Folder, [folder_view, folder_edit, folder_delete, folder_acl_list])

register_links([Folder, 'folder_list', 'folder_create'], [folder_list, folder_create], menu_name='secondary_menu')

register_top_menu(name='folders', link=folders_main_menu_link, children_views=['folder_list', 'folder_create', 'folder_edit', 'folder_delete', 'folder_view', 'folder_document_multiple_remove'])

register_links(Document, [document_folder_list], menu_name='form_header')

register_sidebar_template(['folder_list'], 'folders_help.html')

register_links(['document_folder_list', 'folder_add_document'], [folder_add_document], menu_name="sidebar")

register_multi_item_links(['document_find_duplicates', 'folder_view', 'index_instance_node_view', 'document_type_document_list', 'search', 'results', 'document_group_view', 'document_list', 'document_list_recent', 'tag_tagged_item_list'], [folder_add_multiple_documents])

class_permissions(Folder, [
    PERMISSION_FOLDER_EDIT,
    PERMISSION_FOLDER_DELETE,
    PERMISSION_FOLDER_VIEW,
    ACLS_EDIT_ACL,
    ACLS_VIEW_ACL
])

class_permissions(Document, [
    PERMISSION_FOLDER_ADD_DOCUMENT,
    PERMISSION_FOLDER_REMOVE_DOCUMENT,
])
Ejemplo n.º 2
0
setup_document_type_metadata = {'text': _(u'default metadata'), 'view': 'setup_document_type_metadata', 'args': 'document_type.pk', 'famfam': 'xhtml', 'permissions': [PERMISSION_DOCUMENT_TYPE_EDIT]}

register_links(['metadata_add', 'metadata_edit', 'metadata_remove', 'metadata_view'], [metadata_add, metadata_edit, metadata_remove], menu_name='sidebar')
register_links(Document, [metadata_view], menu_name='form_header')
register_multi_item_links(['document_find_duplicates', 'folder_view', 'index_instance_list', 'document_type_document_list', 'search', 'results', 'document_group_view', 'document_list', 'document_list_recent'], [metadata_multiple_add, metadata_multiple_edit, metadata_multiple_remove])

register_links(MetadataType, [setup_metadata_type_edit, setup_metadata_type_delete])
register_links([MetadataType, 'setup_metadata_type_list', 'setup_metadata_type_create'], [setup_metadata_type_list, setup_metadata_type_create], menu_name='secondary_menu')

register_links(MetadataSet, [setup_metadata_set_edit, setup_metadata_set_delete])
register_links([MetadataSet, 'setup_metadata_set_list', 'setup_metadata_set_create'], [setup_metadata_set_list, setup_metadata_set_create], menu_name='secondary_menu')

register_links(DocumentType, [setup_document_type_metadata])

metadata_type_setup_views = ['setup_metadata_type_list', 'setup_metadata_type_edit', 'setup_metadata_type_delete', 'setup_metadata_type_create']
metadata_set_setup_views = ['setup_metadata_set_list', 'setup_metadata_set_edit', 'setup_metadata_set_delete', 'setup_metadata_set_create']

register_sidebar_template(['setup_metadata_type_list'], 'metadata_type_help.html')
register_sidebar_template(['setup_metadata_set_list'], 'metadata_set_help.html')

register_setup(setup_metadata_type_list)
register_setup(setup_metadata_set_list)

class_permissions(Document, [
    PERMISSION_METADATA_DOCUMENT_EDIT,
    PERMISSION_METADATA_DOCUMENT_ADD,
    PERMISSION_METADATA_DOCUMENT_REMOVE,
    PERMISSION_METADATA_DOCUMENT_VIEW,
])
Ejemplo n.º 3
0
register_links(Document, [document_view_simple], menu_name='form_header', position=0)
register_links(Document, [document_view_advanced], menu_name='form_header', position=1)
register_links(Document, [document_history_view], menu_name='form_header')
register_links(Document, [document_version_list], menu_name='form_header')

if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH):
    setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp())

register_setup(document_type_setup)

class_permissions(Document, [
    PERMISSION_DOCUMENT_PROPERTIES_EDIT,
    PERMISSION_DOCUMENT_EDIT,
    PERMISSION_DOCUMENT_VIEW,
    PERMISSION_DOCUMENT_DELETE,
    PERMISSION_DOCUMENT_DOWNLOAD,
    PERMISSION_DOCUMENT_TRANSFORM,
    PERMISSION_DOCUMENT_NEW_VERSION,
    PERMISSION_DOCUMENT_VERSION_REVERT,
    PERMISSION_HISTORY_VIEW
])

document_search = SearchModel('documents', 'Document')
document_search.add_model_field('document_type__name', label=_(u'Document type'))
document_search.add_model_field('versions__mimetype', label=_(u'MIME type'))
document_search.add_model_field('versions__filename', label=_(u'Filename'))
document_search.add_model_field('metadata__metadata_type__name', label=_(u'Metadata type'))
document_search.add_model_field('metadata__value', label=_(u'Metadata value'))
document_search.add_model_field('versions__pages__content', label=_(u'Content'))
document_search.add_model_field('description', label=_(u'Description'))
document_search.add_model_field('tags__name', label=_(u'Tags'))
Ejemplo n.º 4
0
        'attribute': 'submit_date'
    },
    {
        'name': _(u'user'),
        'attribute': encapsulate(lambda x: x.user.get_full_name() if x.user.get_full_name() else x.user)
    },
    {
        'name': _(u'comment'),
        'attribute': 'comment'
    }
])

register_links(['comments_for_document', 'comment_add', 'comment_delete', 'comment_multiple_delete'], [comment_add], menu_name='sidebar')
register_links(Comment, [comment_delete])
register_links(Document, [comments_for_document], menu_name='form_header')

Document.add_to_class(
    'comments',
    generic.GenericRelation(
        Comment,
        content_type_field='content_type',
        object_id_field='object_pk'
    )
)

class_permissions(Document, [
    PERMISSION_COMMENT_CREATE,
    PERMISSION_COMMENT_DELETE,
    PERMISSION_COMMENT_VIEW
])
Ejemplo n.º 5
0
                    link_tools_profile_delete, link_tools_profile_edit,
                    link_tools_profile_view)
from .models import ToolsProfile
from .permissions import (PERMISSION_TOOLS_PROFILE_CREATE,
                          PERMISSION_TOOLS_PROFILE_DELETE,
                          PERMISSION_TOOLS_PROFILE_EDIT,
                          PERMISSION_TOOLS_PROFILE_VIEW)

Link.bind_links(
    [ToolsProfile, 'agency_tools_profile_list', 'tools_profile_create'],
    [link_tools_profile_create],
    menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_tools_profile_list])

Link.bind_links([ToolsProfile], [
    link_tools_profile_view, link_tools_profile_edit, link_tools_profile_delete
])

register_model_list_columns(ToolsProfile, [
    {
        'name': _(u'creation date and time'),
        'attribute': encapsulate(lambda x: x.datetime_created)
    },
])

#AgencyElement(link_agency_tools_profile_list)
class_permissions(Agency, [
    PERMISSION_TOOLS_PROFILE_CREATE, PERMISSION_TOOLS_PROFILE_DELETE,
    PERMISSION_TOOLS_PROFILE_EDIT, PERMISSION_TOOLS_PROFILE_VIEW
])
Ejemplo n.º 6
0
from acls.api import class_permissions
from documents.models import Document
from navigation.api import register_links

from .links import send_document_link, send_document
from .permissions import (
    PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT
)

register_links([Document], [send_document_link, send_document])

class_permissions(Document, [
    PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT
])
Ejemplo n.º 7
0
register_model_list_columns(Project, [
    {'name': _(u'name'), 'attribute': 'label'},
#    {'name': _(u'completion (%)'), 'attribute': encapsulate(lambda x: x.get_completion())},
#    {'name': _(u'fiscal year'), 'attribute': 'fiscal_year'},
#    {'name': _(u'purpose'), 'attribute': 'purpose'},
#    {'name': _(u'classification'), 'attribute': 'classification'},
])

register_model_list_columns(ProjectFile, [
    {'name': _(u'label'), 'attribute': 'label'},
    {'name': _(u'file'), 'attribute': 'get_base_filename'},
])

class_permissions(Agency, [
        PERMISSION_PROJECT_EDIT, PERMISSION_PROJECT_DELETE,
        PERMISSION_PROJECT_VIEW, PERMISSION_PROJECT_CREATE
    ]
)
'''
project_search = SearchModel('projects', 'Project')

project_search.add_model_field('label', label=_(u'label'))
project_search.add_model_field('agency__name', label=_(u'agency'))

project_search.add_model_field('projectinfo__fiscal_year__label', label=_(u'fiscal year'))
project_search.add_model_field('projectinfo__purpose__label', label=_(u'purpose'))
project_search.add_model_field('projectinfo__purpose_other', label=_(u'purpose other'))
project_search.add_model_field('projectinfo__classification__label', label=_(u'classification'))
project_search.add_model_field('projectinfo__classification_other', label=_(u'classification other'))
project_search.add_model_field('projectinfo__department__label', label=_(u'department'))
project_search.add_model_field('projectinfo__sponsor', label=_(u'sponsor'))
Ejemplo n.º 8
0
        encapsulate(lambda x: document_thumbnail(x, gallery_name='documents:document_list', title=getattr(x, 'filename', None), size=THUMBNAIL_SIZE))
    },
    {
        'name': _('Type'), 'attribute': 'document_type'
    }
])

if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH):
    setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp())

register_setup(document_type_setup)

class_permissions(Document, [
    ACLS_EDIT_ACL, ACLS_VIEW_ACL, PERMISSION_DOCUMENT_DELETE,
    PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_EDIT,
    PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_PROPERTIES_EDIT,
    PERMISSION_DOCUMENT_TRANSFORM, PERMISSION_DOCUMENT_VERSION_REVERT,
    PERMISSION_DOCUMENT_VIEW, PERMISSION_EVENTS_VIEW
])

document_search = SearchModel('documents', 'Document', permission=PERMISSION_DOCUMENT_VIEW, serializer_string='documents.serializers.DocumentSerializer')

# TODO: move these to their respective apps
# Moving these to other apps cause an ImportError; circular import?
document_search.add_model_field('document_type__name', label=_('Document type'))
document_search.add_model_field('versions__mimetype', label=_('MIME type'))
document_search.add_model_field('label', label=_('Label'))
document_search.add_model_field('metadata__metadata_type__name', label=_('Metadata type'))
document_search.add_model_field('metadata__value', label=_('Metadata value'))
document_search.add_model_field('versions__pages__content', label=_('Content'))
document_search.add_model_field('description', label=_('Description'))
Ejemplo n.º 9
0
from .models import SmartLink, SmartLinkCondition
from .permissions import (PERMISSION_SMART_LINK_DELETE,
                          PERMISSION_SMART_LINK_EDIT,
                          PERMISSION_SMART_LINK_VIEW)

register_links(Document, [smart_link_instances_for_document],
               menu_name='form_header')
register_links(SmartLink, [
    smart_link_edit, smart_link_document_types, smart_link_condition_list,
    smart_link_acl_list, smart_link_delete
])
register_links(
    [SmartLink, 'linking:smart_link_list', 'linking:smart_link_create'],
    [smart_link_list, smart_link_create],
    menu_name='secondary_menu')
register_links(SmartLinkCondition,
               [smart_link_condition_edit, smart_link_condition_delete])
register_links(ResolvedSmartLink, [smart_link_instance_view])
register_links([
    'linking:smart_link_condition_list', 'linking:smart_link_condition_create',
    'linking:smart_link_condition_edit', 'linking:smart_link_condition_delete'
], [smart_link_condition_create],
               menu_name='sidebar')

register_setup(smart_link_setup)

class_permissions(SmartLink, [
    ACLS_EDIT_ACL, ACLS_VIEW_ACL, PERMISSION_SMART_LINK_DELETE,
    PERMISSION_SMART_LINK_EDIT, PERMISSION_SMART_LINK_VIEW
])
Ejemplo n.º 10
0
Link.bind_links(['agency_software_list', 'data_create', AgencySoftware],
                [link_agency_software_create],
                menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_software_list])
Link.bind_links([AgencySoftware], [
    link_agency_software_view, link_agency_software_edit,
    link_agency_software_delete
])

register_model_list_columns(AgencySoftware, [
    {
        'name': _(u'type'),
        'attribute': 'software.software_type'
    },
    {
        'name': _(u'label'),
        'attribute': 'software.label'
    },
    {
        'name': _(u'amount'),
        'attribute': 'amount'
    },
])

#AgencyElement(link_agency_tools_profile_list)
class_permissions(Agency, [
    PERMISSION_AGENCY_SOFTWARE_CREATE, PERMISSION_AGENCY_SOFTWARE_DELETE,
    PERMISSION_AGENCY_SOFTWARE_EDIT, PERMISSION_AGENCY_SOFTWARE_VIEW
])
Ejemplo n.º 11
0
from __future__ import absolute_import

from acls.api import class_permissions
from acls.permissions import ACLS_VIEW_ACL, ACLS_EDIT_ACL
from documents.models import Document
from navigation.api import register_links

from .links import acl_list

register_links(Document, [acl_list], menu_name='form_header')

class_permissions(Document, [ACLS_VIEW_ACL, ACLS_EDIT_ACL])
Ejemplo n.º 12
0
from django.utils.translation import ugettext_lazy as _

from acls.api import class_permissions
#from agencies.classes import AgencyElement
from agencies.models import Agency
from common.utils import encapsulate
from navigation.api import register_top_menu, register_model_list_columns
from navigation.classes import Link

from .links import (link_agency_tools_profile_list, link_tools_profile_create,
    link_tools_profile_delete, link_tools_profile_edit, link_tools_profile_view)
from .models import ToolsProfile
from .permissions import (PERMISSION_TOOLS_PROFILE_CREATE, PERMISSION_TOOLS_PROFILE_DELETE,
    PERMISSION_TOOLS_PROFILE_EDIT, PERMISSION_TOOLS_PROFILE_VIEW)

Link.bind_links([ToolsProfile, 'agency_tools_profile_list', 'tools_profile_create'], [link_tools_profile_create], menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_tools_profile_list])

Link.bind_links([ToolsProfile], [link_tools_profile_view, link_tools_profile_edit, link_tools_profile_delete])

register_model_list_columns(ToolsProfile, [
    {'name': _(u'creation date and time'), 'attribute': encapsulate(lambda x: x.datetime_created)},
])

#AgencyElement(link_agency_tools_profile_list)
class_permissions(Agency, [
        PERMISSION_TOOLS_PROFILE_CREATE, PERMISSION_TOOLS_PROFILE_DELETE,
        PERMISSION_TOOLS_PROFILE_EDIT, PERMISSION_TOOLS_PROFILE_VIEW
    ]
)
Ejemplo n.º 13
0
from acls.api import class_permissions
#from agencies.classes import AgencyElement
from agencies.models import Agency
from common.utils import encapsulate
from navigation.api import register_top_menu, register_model_list_columns
from navigation.classes import Link

from .links import (link_agency_software_list, link_agency_software_create,
    link_agency_software_delete, link_agency_software_edit, link_agency_software_view)
from .models import Agency, AgencySoftware
from .permissions import (PERMISSION_AGENCY_SOFTWARE_CREATE, PERMISSION_AGENCY_SOFTWARE_DELETE,
    PERMISSION_AGENCY_SOFTWARE_EDIT, PERMISSION_AGENCY_SOFTWARE_VIEW)

Link.bind_links(['agency_software_list', 'data_create', AgencySoftware], [link_agency_software_create], menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_software_list])
Link.bind_links([AgencySoftware], [link_agency_software_view, link_agency_software_edit, link_agency_software_delete])

register_model_list_columns(AgencySoftware, [
    {'name': _(u'type'), 'attribute': 'software.software_type'},
    {'name': _(u'label'), 'attribute': 'software.label'},
    {'name': _(u'amount'), 'attribute': 'amount'},
])

#AgencyElement(link_agency_tools_profile_list)
class_permissions(Agency, [
        PERMISSION_AGENCY_SOFTWARE_CREATE, PERMISSION_AGENCY_SOFTWARE_DELETE,
        PERMISSION_AGENCY_SOFTWARE_EDIT, PERMISSION_AGENCY_SOFTWARE_VIEW
    ]
)
Ejemplo n.º 14
0
    else:
        return descriptor


def document_post_save_hook(instance):
    if not instance.pk:
        document_signature, created = DocumentVersionSignature.objects.get_or_create(
            document_version=instance.latest_version, )


register_links(Document, [document_verify], menu_name='form_header')
register_links([
    'signatures:document_verify', 'signatures:document_signature_upload',
    'signatures:document_signature_download',
    'signatures:document_signature_delete'
], [
    document_signature_upload, document_signature_download,
    document_signature_delete
],
               menu_name='sidebar')

DocumentVersion.register_pre_open_hook(1, document_pre_open_hook)
DocumentVersion.register_post_save_hook(1, document_post_save_hook)

class_permissions(Document, [
    PERMISSION_DOCUMENT_VERIFY,
    PERMISSION_SIGNATURE_DELETE,
    PERMISSION_SIGNATURE_DOWNLOAD,
    PERMISSION_SIGNATURE_UPLOAD,
])
Ejemplo n.º 15
0
        except GPGDecryptionError:
            # At least return the original raw content
            descriptor.seek(0)
            return descriptor
        else:
            descriptor.close()
            return StringIO(result.data)
    else:
        return descriptor


def document_post_save_hook(instance):
    if not instance.pk:
        document_signature, created = DocumentVersionSignature.objects.get_or_create(
            document_version=instance.latest_version,
        )


register_links(Document, [document_verify], menu_name='form_header')
register_links(['signatures:document_verify', 'signatures:document_signature_upload', 'signatures:document_signature_download', 'signatures:document_signature_delete'], [document_signature_upload, document_signature_download, document_signature_delete], menu_name='sidebar')

DocumentVersion.register_pre_open_hook(1, document_pre_open_hook)
DocumentVersion.register_post_save_hook(1, document_post_save_hook)

class_permissions(Document, [
    PERMISSION_DOCUMENT_VERIFY,
    PERMISSION_SIGNATURE_DELETE,
    PERMISSION_SIGNATURE_DOWNLOAD,
    PERMISSION_SIGNATURE_UPLOAD,
])
Ejemplo n.º 16
0
    DocumentType,
    [setup_document_type_metadata, setup_document_type_metadata_required])
register_links(MetadataType,
               [setup_metadata_type_edit, setup_metadata_type_delete])
register_links([
    MetadataType, 'metadata:setup_metadata_type_list',
    'metadata:setup_metadata_type_create'
], [setup_metadata_type_list, setup_metadata_type_create],
               menu_name='secondary_menu')

register_setup(setup_metadata_type_list)
register_tool(link_documents_missing_required_metadata)

class_permissions(Document, [
    PERMISSION_METADATA_DOCUMENT_ADD,
    PERMISSION_METADATA_DOCUMENT_EDIT,
    PERMISSION_METADATA_DOCUMENT_REMOVE,
    PERMISSION_METADATA_DOCUMENT_VIEW,
])

register_model_list_columns(Document, [
    {
        'name': _('Metadata'),
        'attribute': encapsulate(lambda x: get_metadata_string(x))
    },
])

APIEndPoint('metadata')
ModelAttribute(Document,
               'metadata__metadata_type__name',
               label=_('Metadata type name'),
               type_name='query')
Ejemplo n.º 17
0
from acls.api import class_permissions
from documents.models import Document
from navigation.api import register_links

from .links import send_document_link, send_document
from .permissions import PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT

register_links([Document], [send_document_link, send_document])

class_permissions(Document, [PERMISSION_MAILING_LINK, PERMISSION_MAILING_SEND_DOCUMENT])
Ejemplo n.º 18
0
Link.bind_links([Equipment], [link_equipment_view, link_equipment_edit, link_equipment_delete])

Link.bind_links(['agency_circuit_list', 'circuit_create', Circuit], [link_circuit_create], menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_circuit_list])
Link.bind_links([Circuit], [link_circuit_view, link_circuit_edit, link_circuit_delete])

register_model_list_columns(Equipment, [
    {'name': _(u'name'), 'attribute': 'label'},
])

register_model_list_columns(Circuit, [
    {'name': _(u'purpose'), 'attribute': 'purpose'},
    {'name': _(u'provider'), 'attribute': 'provider'},
    {'name': _(u'technology'), 'attribute': 'technology'},
    {'name': _(u'bandwidth'), 'attribute': encapsulate(lambda x: x.get_bandwidth_display())},
])

#AgencyElement(link_agency_equipment_list)

class_permissions(Agency, [
        PERMISSION_EQUIPMENT_CREATE, PERMISSION_EQUIPMENT_DELETE,
        PERMISSION_EQUIPMENT_EDIT, PERMISSION_EQUIPMENT_VIEW
    ]
)

class_permissions(Agency, [
        PERMISSION_CIRCUIT_CREATE, PERMISSION_CIRCUIT_DELETE,
        PERMISSION_CIRCUIT_EDIT, PERMISSION_CIRCUIT_VIEW
    ]
)
Ejemplo n.º 19
0
from common.utils import encapsulate
from documents.models import Document
from navigation.api import register_links, register_model_list_columns

from .links import comment_add, comment_delete, comments_for_document
from .permissions import (PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE,
                          PERMISSION_COMMENT_VIEW)

Document.add_to_class(
    'comments',
    generic.GenericRelation(Comment,
                            content_type_field='content_type',
                            object_id_field='object_pk'))

class_permissions(Document, [
    PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE,
    PERMISSION_COMMENT_VIEW
])

register_model_list_columns(Comment, [{
    'name': _('Date'),
    'attribute': 'submit_date'
}, {
    'name':
    _('User'),
    'attribute':
    encapsulate(lambda x: x.user.get_full_name()
                if x.user.get_full_name() else x.user)
}, {
    'name': _('Comment'),
    'attribute': 'comment'
}])
Ejemplo n.º 20
0
from django.utils.translation import ugettext_lazy as _

from documents.models import Document
from navigation.api import register_links
from acls import ACLS_VIEW_ACL, ACLS_EDIT_ACL
from acls.api import class_permissions

acl_list = {'text': _(u'ACLs'), 'view': 'document_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]}

register_links(Document, [acl_list], menu_name='form_header')

class_permissions(Document, [
    ACLS_VIEW_ACL,
    ACLS_EDIT_ACL
])
Ejemplo n.º 21
0
    link_agency_acl_details,
)
from .models import Agency
from .permissions import PERMISSION_AGENCY_VIEW, PERMISSION_AGENCY_EDIT


Link.bind_links([Agency, "agency_list"], [link_agency_list], menu_name="secondary_menu")
# Link.bind_links([Agency], [link_agency_details, link_agency_view, link_agency_edit, link_agency_delete])
Link.bind_links([Agency], [link_agency_acl_details])  # , link_agency_view, link_agency_edit])#, link_agency_delete])

register_model_list_columns(
    Agency,
    [
        # {'name': _(u'registration'), 'attribute': 'registration'},
        {"name": _(u"name"), "attribute": "name"}
    ],
)

register_top_menu("agencies", link=link_agencies, position=1)

class_permissions(Agency, [PERMISSION_AGENCY_VIEW, PERMISSION_AGENCY_EDIT, ACLS_VIEW_ACL, ACLS_EDIT_ACL])

# agency_search = SearchModel('agencies', 'Agency')

# agency_search.add_model_field('prifas', label=_(u'Prifas number'))
# agency_search.add_model_field('registration', label=_(u'Registration'))
# agency_search.add_model_field('name', label=_(u'Name'))
# agency_search.add_model_field('director', label=_(u'Director'))
# agency_search.add_model_field('physical_address', label=_(u'Physical address'))
# agency_search.add_model_field('postal_address', label=_(u'Postal address'))
Ejemplo n.º 22
0
from .links import (
    multiple_documents_selection_tag_remove,
    single_document_multiple_tag_remove, tag_acl_list, tag_attach, tag_create,
    tag_delete, tag_document_list, tag_edit, tag_list, tag_multiple_attach,
    tag_multiple_delete, tag_tagged_item_list
)
from .models import Tag
from .permissions import (
    PERMISSION_TAG_ATTACH, PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT,
    PERMISSION_TAG_REMOVE, PERMISSION_TAG_VIEW
)
from .widgets import get_tags_inline_widget_simple, single_tag_widget

class_permissions(Document, [
    PERMISSION_TAG_ATTACH, PERMISSION_TAG_REMOVE,
])
class_permissions(Tag, [
    PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT, PERMISSION_TAG_VIEW,
])

APIEndPoint('tags')

register_model_list_columns(Tag, [
    {
        'name': _('Preview'),
        'attribute': encapsulate(lambda x: single_tag_widget(x))
    },
    {
        'name': _('Tagged items'),
        'attribute': encapsulate(lambda x: x.documents.count())
Ejemplo n.º 23
0
                          PERMISSION_DATA_EDIT, PERMISSION_DATA_VIEW)

#Link.bind_links(['data_list'], [link_data_list], menu_name='secondary_menu')
Link.bind_links(['agency_data_list', 'data_create', AgencyData],
                [link_data_create],
                menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_data_list])
Link.bind_links([AgencyData],
                [link_data_view, link_data_edit, link_data_delete])

register_model_list_columns(AgencyData, [
    {
        'name': _(u'name'),
        'attribute': 'label'
    },
    {
        'name': _(u'data type'),
        'attribute': 'data_type'
    },
    {
        'name': _(u'description'),
        'attribute': 'description'
    },
])

#AgencyElement(link_agency_data_list)
class_permissions(Agency, [
    PERMISSION_DATA_CREATE, PERMISSION_DATA_DELETE, PERMISSION_DATA_EDIT,
    PERMISSION_DATA_VIEW
])
Ejemplo n.º 24
0
register_links([Folder, 'folders:folder_list', 'folders:folder_create'],
               [folder_list, folder_create],
               menu_name='secondary_menu')
register_links(['folders:document_folder_list', 'folders:folder_add_document'],
               [folder_add_document],
               menu_name="sidebar")
register_links(Document, [document_folder_list], menu_name='form_header')
register_links([Document], [
    folder_add_multiple_documents, folder_document_multiple_remove, link_spacer
],
               menu_name='multi_item_links')

register_top_menu(name='folders', link=folders_main_menu_link)

class_permissions(Folder, [
    ACLS_EDIT_ACL, ACLS_VIEW_ACL, PERMISSION_FOLDER_DELETE,
    PERMISSION_FOLDER_EDIT, PERMISSION_FOLDER_VIEW
])

class_permissions(
    Document,
    [PERMISSION_FOLDER_ADD_DOCUMENT, PERMISSION_FOLDER_REMOVE_DOCUMENT])

register_model_list_columns(Folder, [
    {
        'name': _('Created'),
        'attribute': 'datetime_created'
    },
    {
        'name': _('Documents'),
        'attribute': encapsulate(lambda x: x.documents.count())
    },
Ejemplo n.º 25
0
#    {'name': _(u'completion (%)'), 'attribute': encapsulate(lambda x: x.get_completion())},
#    {'name': _(u'fiscal year'), 'attribute': 'fiscal_year'},
#    {'name': _(u'purpose'), 'attribute': 'purpose'},
#    {'name': _(u'classification'), 'attribute': 'classification'},
])

register_model_list_columns(ProjectFile, [
    {'name': _(u'label'), 'attribute': 'label'},
    {'name': _(u'file'), 'attribute': 'get_base_filename'},
])

#AgencyElement(link_agency_project_list)

class_permissions(Agency, [
        PERMISSION_PROJECT_EDIT, PERMISSION_PROJECT_DELETE,
        PERMISSION_PROJECT_VIEW, PERMISSION_PROJECT_CREATE
    ]
)

project_search = SearchModel('projects', 'Project')

project_search.add_model_field('label', label=_(u'label'))
project_search.add_model_field('agency__name', label=_(u'agency'))

project_search.add_model_field('projectinfo__fiscal_year__label', label=_(u'fiscal year'))
project_search.add_model_field('projectinfo__purpose__label', label=_(u'purpose'))
#project_search.add_model_field('projectinfo__purpose_other', label=_(u'purpose other'))
project_search.add_model_field('projectinfo__classification__label', label=_(u'classification'))
#project_search.add_model_field('projectinfo__classification_other', label=_(u'classification other'))
project_search.add_model_field('projectinfo__department__label', label=_(u'department'))
project_search.add_model_field('projectinfo__sponsor', label=_(u'sponsor'))
Ejemplo n.º 26
0
    [SmartLink, "smart_link_list", "smart_link_create"],
    [smart_link_list, smart_link_create],
    menu_name="secondary_menu",
)

register_links(SmartLinkCondition, [smart_link_condition_edit, smart_link_condition_delete])
register_links(
    [
        "smart_link_condition_list",
        "smart_link_condition_create",
        "smart_link_condition_edit",
        "smart_link_condition_delete",
    ],
    [smart_link_condition_create],
    menu_name="sidebar",
)

register_setup(smart_link_setup)
register_sidebar_template(["smart_link_list"], "smart_links_help.html")

class_permissions(
    SmartLink,
    [
        PERMISSION_SMART_LINK_VIEW,
        PERMISSION_SMART_LINK_DELETE,
        PERMISSION_SMART_LINK_EDIT,
        ACLS_EDIT_ACL,
        ACLS_VIEW_ACL,
    ],
)
Ejemplo n.º 27
0
register_links(Document, [document_view_advanced],
               menu_name='form_header',
               position=1)
register_links(Document, [document_history_view], menu_name='form_header')
register_links(Document, [document_version_list], menu_name='form_header')

if (not validate_path(
        document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH):
    setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp())

register_setup(document_type_setup)

class_permissions(Document, [
    PERMISSION_DOCUMENT_PROPERTIES_EDIT, PERMISSION_DOCUMENT_EDIT,
    PERMISSION_DOCUMENT_VIEW, PERMISSION_DOCUMENT_DELETE,
    PERMISSION_DOCUMENT_DOWNLOAD, PERMISSION_DOCUMENT_TRANSFORM,
    PERMISSION_DOCUMENT_NEW_VERSION, PERMISSION_DOCUMENT_VERSION_REVERT,
    PERMISSION_HISTORY_VIEW
])

document_search = SearchModel('documents', 'Document')
document_search.add_model_field('document_type__name',
                                label=_(u'Document type'))
document_search.add_model_field('versions__mimetype', label=_(u'MIME type'))
document_search.add_model_field('versions__filename', label=_(u'Filename'))
document_search.add_model_field('metadata__metadata_type__name',
                                label=_(u'Metadata type'))
document_search.add_model_field('metadata__value', label=_(u'Metadata value'))
document_search.add_model_field('versions__pages__content',
                                label=_(u'Content'))
document_search.add_model_field('description', label=_(u'Description'))
Ejemplo n.º 28
0
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))


app.conf.CELERYBEAT_SCHEDULE.update({
    'check_expired_check_outs': {
        'task': 'checkouts.tasks.task_check_expired_check_outs',
        'schedule': timedelta(seconds=CHECK_EXPIRED_CHECK_OUTS_INTERVAL),
        'options': {'queue': 'checkouts'}
    },
})

class_permissions(Document, [
    PERMISSION_DOCUMENT_CHECKOUT,
    PERMISSION_DOCUMENT_CHECKIN,
    PERMISSION_DOCUMENT_CHECKIN_OVERRIDE,
    PERMISSION_DOCUMENT_RESTRICTIONS_OVERRIDE
])

initialize_document_checkout_extra_methods()

register_links(Document, [checkout_info], menu_name='form_header')
register_links(['checkouts:checkout_info', 'checkouts:checkout_document', 'checkouts:checkin_document'], [checkout_document, checkin_document], menu_name="sidebar")
register_top_menu(name='checkouts', link=checkout_list)

APIEndPoint('checkouts')
Ejemplo n.º 29
0
from acls.api import class_permissions
#from agencies.classes import AgencyElement
from agencies.models import Agency
from common.utils import encapsulate
from navigation.api import register_top_menu, register_model_list_columns
from navigation.classes import Link

from .links import (link_data_create, link_data_delete, link_data_edit,
    link_data_view, link_agency_data_list)
from .models import AgencyData
from .permissions import (PERMISSION_DATA_CREATE, PERMISSION_DATA_DELETE,
    PERMISSION_DATA_EDIT, PERMISSION_DATA_VIEW)

#Link.bind_links(['data_list'], [link_data_list], menu_name='secondary_menu')
Link.bind_links(['agency_data_list', 'data_create', AgencyData], [link_data_create], menu_name='secondary_menu')
Link.bind_links([Agency], [link_agency_data_list])
Link.bind_links([AgencyData], [link_data_view, link_data_edit, link_data_delete])

register_model_list_columns(AgencyData, [
    {'name': _(u'name'), 'attribute': 'label'},
    {'name': _(u'data type'), 'attribute': 'data_type'},
    {'name': _(u'description'), 'attribute': 'description'},
])

#AgencyElement(link_agency_data_list)
class_permissions(Agency, [
        PERMISSION_DATA_CREATE, PERMISSION_DATA_DELETE,
        PERMISSION_DATA_EDIT, PERMISSION_DATA_VIEW
    ]
)
Ejemplo n.º 30
0
                DocumentQueue.objects.queue_document(instance.document)
            except AlreadyQueued:
                pass


# Disabled because it appears Django execute signals using the same
# process of the signal emiter effectively blocking the view until
# the OCR process completes which could take several minutes :/
#@receiver(post_save, dispatch_uid='call_queue', sender=QueueDocument)
#def call_queue(sender, **kwargs):
#    if kwargs.get('created', False):
#        logger.debug('got call_queue signal: %s' % kwargs)
#        task_process_document_queues()


@receiver(post_syncdb, dispatch_uid='create_default_queue', sender=ocr_models)
def create_default_queue_signal_handler(sender, **kwargs):
    create_default_queue()


register_interval_job('task_process_document_queues',
                      _(u'Checks the OCR queue for pending documents.'),
                      task_process_document_queues,
                      seconds=QUEUE_PROCESSING_INTERVAL)

register_tool(ocr_tool_link)

class_permissions(Document, [
    PERMISSION_OCR_DOCUMENT,
])
Ejemplo n.º 31
0
    [link_agency_acl_details
     ])  #, link_agency_view, link_agency_edit])#, link_agency_delete])

register_model_list_columns(
    Agency,
    [
        #{'name': _(u'registration'), 'attribute': 'registration'},
        {
            'name': _(u'name'),
            'attribute': 'name'
        },
    ])

register_top_menu('agencies', link=link_agencies, position=1)

class_permissions(Agency, [
    PERMISSION_AGENCY_VIEW,
    PERMISSION_AGENCY_EDIT,
    ACLS_VIEW_ACL,
    ACLS_EDIT_ACL,
])

#agency_search = SearchModel('agencies', 'Agency')

#agency_search.add_model_field('prifas', label=_(u'Prifas number'))
#agency_search.add_model_field('registration', label=_(u'Registration'))
#agency_search.add_model_field('name', label=_(u'Name'))
#agency_search.add_model_field('director', label=_(u'Director'))
#agency_search.add_model_field('physical_address', label=_(u'Physical address'))
#agency_search.add_model_field('postal_address', label=_(u'Postal address'))
Ejemplo n.º 32
0
from navigation.links import link_spacer
from rest_api.classes import APIEndPoint

from .links import (multiple_documents_selection_tag_remove,
                    single_document_multiple_tag_remove, tag_acl_list,
                    tag_attach, tag_create, tag_delete, tag_document_list,
                    tag_edit, tag_list, tag_multiple_attach,
                    tag_multiple_delete, tag_tagged_item_list)
from .models import Tag
from .permissions import (PERMISSION_TAG_ATTACH, PERMISSION_TAG_DELETE,
                          PERMISSION_TAG_EDIT, PERMISSION_TAG_REMOVE,
                          PERMISSION_TAG_VIEW)
from .widgets import get_tags_inline_widget_simple, single_tag_widget

class_permissions(Document, [
    PERMISSION_TAG_ATTACH,
    PERMISSION_TAG_REMOVE,
])
class_permissions(Tag, [
    PERMISSION_TAG_DELETE,
    PERMISSION_TAG_EDIT,
    PERMISSION_TAG_VIEW,
])

APIEndPoint('tags')

register_model_list_columns(
    Tag, [{
        'name': _('Preview'),
        'attribute': encapsulate(lambda x: single_tag_widget(x))
    }, {
        'name': _('Tagged items'),
Ejemplo n.º 33
0
def document_version_ocr_submit(self):
    task_do_ocr.apply_async(args=[self.pk], queue='ocr')


@receiver(post_version_upload, dispatch_uid='post_version_upload_ocr', sender=DocumentVersion)
def post_version_upload_ocr(sender, instance, **kwargs):
    logger.debug('received post_version_upload')
    logger.debug('instance pk: %s', instance.pk)
    if instance.document.document_type.ocr:
        instance.submit_for_ocr()


Document.add_to_class('submit_for_ocr', document_ocr_submit)
DocumentVersion.add_to_class('submit_for_ocr', document_version_ocr_submit)

class_permissions(Document, [PERMISSION_OCR_DOCUMENT])

register_tool(link_entry_list)

APIEndPoint('ocr')

register_model_list_columns(DocumentVersionOCRError, [
    {
        'name': _('Document'), 'attribute': encapsulate(lambda entry: document_link(entry.document_version.document))
    },
    {
        'name': _('Added'), 'attribute': 'datetime_submitted'
    },
    {
        'name': _('Result'), 'attribute': 'result'
    },
Ejemplo n.º 34
0
        '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)