Beispiel #1
0
def home(request):
    document_search = SearchModel.get('documents.Document')

    context = {
        'object_navigation_links': FrontPageButton.get_all(),
        'query_string': request.GET,
        'hide_links': True,
        'search_results_limit': 100,
    }

    if request.GET:
        queryset, ids, timedelta = document_search.search(request.GET, request.user)

        # Update the context with the search results
        context.update({
            'object_list': queryset,
            'time_delta': timedelta,
            'title': _('Results'),
        })

    return render_to_response('main/home.html', context, context_instance=RequestContext(request))
Beispiel #2
0
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'))
document_search.add_related_field('comments', 'Comment', 'comment', 'object_pk', label=_(u'Comments'))

namespace = StatisticNamespace(name='documents', label=_(u'Documents'))
namespace.add_statistic(DocumentStatistics(name='document_stats', label=_(u'Document tendencies')))
namespace.add_statistic(DocumentUsageStatistics(name='document_usage', label=_(u'Document usage')))

endpoint = APIEndPoint('documents')
Beispiel #3
0
])

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'))
project_search.add_model_field('projectinfo__goals__label', label=_(u'goals'))
project_search.add_model_field('projectinfo__needs', label=_(u'needs'))
project_search.add_model_field('projectinfo__expected_results', label=_(u'expected results'))
project_search.add_model_field('projectinfo__methodology__label', label=_(u'methodology'))
Beispiel #4
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_metadata_type_view

metadata_type_search = SearchModel(
    app_label='metadata', model_name='MetadataType',
    permission=permission_metadata_type_view,
    serializer_string='metadata.serializers.MetadataTypeSerializer'
)

metadata_type_search.add_model_field(
    field='name', label=_('Name')
)
metadata_type_search.add_model_field(
    field='label', label=_('Label')
)
metadata_type_search.add_model_field(
    field='default', label=_('Default')
)
metadata_type_search.add_model_field(
    field='lookup', label=_('Lookup')
)
metadata_type_search.add_model_field(
    field='validation', label=_('Validator')
)
metadata_type_search.add_model_field(
    field='parser', label=_('Parser')
Beispiel #5
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_role_view

role_search = SearchModel(
    app_label='permissions', model_name='Role',
    permission=permission_role_view,
    serializer_string='permissions.serializers.RoleSerializer'
)

role_search.add_model_field(
    field='label', label=_('Label')
)

role_search.add_model_field(
    field='groups__name', label=_('Group name')
)
Beispiel #6
0
from __future__ import absolute_import, unicode_literals

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_group_view, permission_user_view

user_app, user_model = settings.AUTH_USER_MODEL.split('.')

user_search = SearchModel(
    app_label=user_app, model_name=user_model,
    permission=permission_user_view,
    serializer_string='user_management.serializers.UserSerializer'
)

user_search.add_model_field(
    field='first_name', label=_('First name')
)
user_search.add_model_field(
    field='email', label=_('Email')
)
user_search.add_model_field(
    field='groups__name', label=_('Groups')
)
user_search.add_model_field(
    field='last_name', label=_('Last name')
)
user_search.add_model_field(
    field='username', label=_('username')
Beispiel #7
0
])

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'))
document_search.add_model_field('tags__label', label=_('Tags'))

namespace = StatisticNamespace(name='documents', label=_('Documents'))
namespace.add_statistic(DocumentStatistics(name='document_stats', label=_('Document tendencies')))
namespace.add_statistic(DocumentUsageStatistics(name='document_usage', label=_('Document usage')))
Beispiel #8
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_document_view

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

document_search.add_model_field(
    field='document_type__label', label=_('Document type')
)
document_search.add_model_field(
    field='versions__mimetype', label=_('MIME type')
)
document_search.add_model_field(field='label', label=_('Label'))
document_search.add_model_field(field='description', label=_('Description'))
Beispiel #9
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_cabinet_view

cabinet_search = SearchModel(
    app_label='cabinets', model_name='Cabinet',
    permission=permission_cabinet_view,
    serializer_string='cabinets.serializers.CabinetSerializer'
)

cabinet_search.add_model_field(
    field='label', label=_('Label')
)
Beispiel #10
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_tag_view

tag_search = SearchModel(
    app_label='tags', model_name='Tag',
    permission=permission_tag_view,
    serializer_string='tags.serializers.TagSerializer'
)

tag_search.add_model_field(
    field='label', label=_('Label')
)

tag_search.add_model_field(
    field='color', label=_('Color')
)
Beispiel #11
0
        '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'))
Beispiel #12
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_document_view

document_search = SearchModel(
    app_label='documents',
    model_name='Document',
    permission=permission_document_view,
    serializer_string='documents.serializers.DocumentSerializer')

document_search.add_model_field(field='document_type__label',
                                label=_('Document type'))
document_search.add_model_field(field='versions__mimetype',
                                label=_('MIME type'))
document_search.add_model_field(field='label', label=_('Label'))
document_search.add_model_field(field='description', label=_('Description'))

document_page_search = SearchModel(
    app_label='documents',
    model_name='DocumentPageResult',
    permission=permission_document_view,
    serializer_string='documents.serializers.DocumentPageSerializer')

document_page_search.add_model_field(
    field='document_version__document__document_type__label',
    label=_('Document type'))
document_page_search.add_model_field(
Beispiel #13
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_document_view

document_search = SearchModel(
    app_label='documents', model_name='Document',
    permission=permission_document_view,
    serializer_string='documents.serializers.DocumentSerializer'
)

document_search.add_model_field(
    field='document_type__label', label=_('Document type')
)
document_search.add_model_field(
    field='versions__mimetype', label=_('MIME type')
)
document_search.add_model_field(field='label', label=_('Label'))
document_search.add_model_field(field='description', label=_('Description'))
document_search.add_model_field(
    field='versions__checksum', label=_('Checksum')
)

document_page_search = SearchModel(
    app_label='documents', model_name='DocumentPageResult',
    permission=permission_document_view,
    serializer_string='documents.serializers.DocumentPageSerializer'
)
Beispiel #14
0
from __future__ import absolute_import, unicode_literals

from django.utils.translation import ugettext_lazy as _

from dynamic_search.classes import SearchModel

from .permissions import permission_cabinet_view

cabinet_search = SearchModel(
    app_label='cabinets',
    model_name='Cabinet',
    permission=permission_cabinet_view,
    serializer_string='cabinets.serializers.CabinetSerializer')

cabinet_search.add_model_field(field='label', label=_('Label'))