Refactor document indexing app
Convert half the widget to HTML widgets. Rename links and views to use the nomeclature _template_ and _instance_ to differenciate between index instances and index templates. Update URL parameters to use the "_id" form. Add more tests. Add model permission inheritance to the IndexTemplateNode, and IndexInstanceNode models. Remove the level and document count display from the instance node. Display instead the total items. Use a FilteredSelectionForm subclass to display the list of index templates to rebuild. Add missing icons. Add keyword arguments to links. Modernize tests to use the document test mixin. Update the permission requirements for the index template document type selection screen. The document type view permission is now required in addition to the index template edit permission. Use ExternalObjectMixin to reduce the code in all views. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -4,30 +4,23 @@ from django import forms
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from mayan.apps.acls.models import AccessControlList
|
||||
from mayan.apps.common.classes import ModelProperty
|
||||
from mayan.apps.common.forms import FilteredSelectionForm
|
||||
from mayan.apps.documents.models import Document
|
||||
|
||||
from .models import Index, IndexTemplateNode
|
||||
from .permissions import permission_document_indexing_rebuild
|
||||
|
||||
|
||||
class IndexListForm(forms.Form):
|
||||
indexes = forms.ModelMultipleChoiceField(
|
||||
help_text=_('Indexes to be queued for rebuilding.'),
|
||||
label=_('Indexes'), queryset=Index.objects.none(),
|
||||
required=False, widget=forms.widgets.CheckboxSelectMultiple()
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
user = kwargs.pop('user')
|
||||
super(IndexListForm, self).__init__(*args, **kwargs)
|
||||
queryset = AccessControlList.objects.restrict_queryset(
|
||||
permission=permission_document_indexing_rebuild,
|
||||
queryset=Index.objects.filter(enabled=True),
|
||||
user=user
|
||||
)
|
||||
self.fields['indexes'].queryset = queryset
|
||||
class IndexTemplateFilteredForm(FilteredSelectionForm):
|
||||
class Meta:
|
||||
allow_multiple = True
|
||||
field_name = 'index_templates'
|
||||
help_text = _('Index templates to be queued for rebuilding.')
|
||||
label = _('Index templates')
|
||||
queryset = Index.objects.filter(enabled=True)
|
||||
permission = permission_document_indexing_rebuild
|
||||
widget_attributes = {'class': 'select2'}
|
||||
|
||||
|
||||
class IndexTemplateNodeForm(forms.ModelForm):
|
||||
|
||||
Reference in New Issue
Block a user