Remove name field. Rename title field to label.
This commit is contained in:
@@ -15,7 +15,7 @@ class IndexTemplateNodeInline(admin.StackedInline):
|
|||||||
class IndexAdmin(admin.ModelAdmin):
|
class IndexAdmin(admin.ModelAdmin):
|
||||||
filter_horizontal = ('document_types',)
|
filter_horizontal = ('document_types',)
|
||||||
inlines = [IndexTemplateNodeInline]
|
inlines = [IndexTemplateNodeInline]
|
||||||
list_display = ('name', 'title', 'enabled', 'get_document_types')
|
list_display = ('label', 'enabled', 'get_document_types')
|
||||||
|
|
||||||
def get_document_types(self, instance):
|
def get_document_types(self, instance):
|
||||||
return ', '.join(['"{0}"'.format(document_type) for document_type in instance.document_types.all()]) or _('None')
|
return ', '.join(['"{0}"'.format(document_type) for document_type in instance.document_types.all()]) or _('None')
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('document_indexing', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='index',
|
||||||
|
name='name',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('document_indexing', '0002_remove_index_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='index',
|
||||||
|
old_name='title',
|
||||||
|
new_name='label',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -15,10 +15,8 @@ from .managers import IndexManager
|
|||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Index(models.Model):
|
class Index(models.Model):
|
||||||
name = models.CharField(unique=True, max_length=64, verbose_name=_('Name'), help_text=_('Internal name used to reference this index.'))
|
label = models.CharField(max_length=128, unique=True, verbose_name=_('Label'))
|
||||||
# TODO: normalize 'title' to 'label'
|
enabled = models.BooleanField(default=True, help_text=_('Causes this index to be visible and updated when document data changes.'), verbose_name=_('Enabled'))
|
||||||
title = models.CharField(unique=True, max_length=128, verbose_name=_('Title'), help_text=_('The name that will be visible to users.'))
|
|
||||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'), help_text=_('Causes this index to be visible and updated when document data changes.'))
|
|
||||||
document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types'))
|
document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types'))
|
||||||
|
|
||||||
objects = IndexManager()
|
objects = IndexManager()
|
||||||
@@ -32,7 +30,7 @@ class Index(models.Model):
|
|||||||
return self.template_root.node_instance.get()
|
return self.template_root.node_instance.get()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.label
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
try:
|
try:
|
||||||
@@ -48,9 +46,6 @@ class Index(models.Model):
|
|||||||
def get_document_types_names(self):
|
def get_document_types_names(self):
|
||||||
return ', '.join([unicode(document_type) for document_type in self.document_types.all()] or ['None'])
|
return ', '.join([unicode(document_type) for document_type in self.document_types.all()] or ['None'])
|
||||||
|
|
||||||
def natural_key(self):
|
|
||||||
return (self.name,)
|
|
||||||
|
|
||||||
def get_instance_node_count(self):
|
def get_instance_node_count(self):
|
||||||
try:
|
try:
|
||||||
return self.instance_root.get_descendant_count()
|
return self.instance_root.get_descendant_count()
|
||||||
|
|||||||
@@ -30,5 +30,5 @@ class IndexSerializer(serializers.ModelSerializer):
|
|||||||
instance_root = IndexInstanceNodeSerializer(read_only=True)
|
instance_root = IndexInstanceNodeSerializer(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = ('id', 'name', 'title', 'enabled', 'document_types', 'node_templates', 'instance_root')
|
fields = ('id', 'label', 'enabled', 'document_types', 'node_templates', 'instance_root')
|
||||||
model = Index
|
model = Index
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class IndexTestCase(TestCase):
|
|||||||
DocumentTypeMetadataType.objects.create(document_type=self.document_type, metadata_type=metadata_type)
|
DocumentTypeMetadataType.objects.create(document_type=self.document_type, metadata_type=metadata_type)
|
||||||
|
|
||||||
# Create empty index
|
# Create empty index
|
||||||
index = Index.objects.create(name='test', title='test')
|
index = Index.objects.create(label='test')
|
||||||
self.failUnlessEqual(list(Index.objects.all()), [index])
|
self.failUnlessEqual(list(Index.objects.all()), [index])
|
||||||
|
|
||||||
# Add our document type to the new index
|
# Add our document type to the new index
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ class SetupIndexListView(SingleObjectListView):
|
|||||||
'title': _('Indexes'),
|
'title': _('Indexes'),
|
||||||
'hide_object': True,
|
'hide_object': True,
|
||||||
'extra_columns': [
|
'extra_columns': [
|
||||||
{'name': _('Name'), 'attribute': 'name'},
|
{'name': _('Label'), 'attribute': 'label'},
|
||||||
{'name': _('Title'), 'attribute': 'title'},
|
|
||||||
{'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
|
{'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -384,7 +383,7 @@ def rebuild_index_instances(request):
|
|||||||
return render_to_response('appearance/generic_confirm.html', {
|
return render_to_response('appearance/generic_confirm.html', {
|
||||||
'previous': previous,
|
'previous': previous,
|
||||||
'next': next,
|
'next': next,
|
||||||
'title': _('Are you sure you wish to rebuild all indexes?'),
|
'title': _('Rebuild all indexes?'),
|
||||||
'message': _('On large databases this operation may take some time to execute.'),
|
'message': _('On large databases this operation may take some time to execute.'),
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user