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):
|
||||
filter_horizontal = ('document_types',)
|
||||
inlines = [IndexTemplateNodeInline]
|
||||
list_display = ('name', 'title', 'enabled', 'get_document_types')
|
||||
list_display = ('label', 'enabled', 'get_document_types')
|
||||
|
||||
def get_document_types(self, instance):
|
||||
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
|
||||
class Index(models.Model):
|
||||
name = models.CharField(unique=True, max_length=64, verbose_name=_('Name'), help_text=_('Internal name used to reference this index.'))
|
||||
# TODO: normalize 'title' to 'label'
|
||||
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.'))
|
||||
label = models.CharField(max_length=128, unique=True, verbose_name=_('Label'))
|
||||
enabled = models.BooleanField(default=True, help_text=_('Causes this index to be visible and updated when document data changes.'), verbose_name=_('Enabled'))
|
||||
document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types'))
|
||||
|
||||
objects = IndexManager()
|
||||
@@ -32,7 +30,7 @@ class Index(models.Model):
|
||||
return self.template_root.node_instance.get()
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
return self.label
|
||||
|
||||
def get_absolute_url(self):
|
||||
try:
|
||||
@@ -48,9 +46,6 @@ class Index(models.Model):
|
||||
def get_document_types_names(self):
|
||||
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):
|
||||
try:
|
||||
return self.instance_root.get_descendant_count()
|
||||
|
||||
@@ -30,5 +30,5 @@ class IndexSerializer(serializers.ModelSerializer):
|
||||
instance_root = IndexInstanceNodeSerializer(read_only=True)
|
||||
|
||||
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
|
||||
|
||||
@@ -22,7 +22,7 @@ class IndexTestCase(TestCase):
|
||||
DocumentTypeMetadataType.objects.create(document_type=self.document_type, metadata_type=metadata_type)
|
||||
|
||||
# Create empty index
|
||||
index = Index.objects.create(name='test', title='test')
|
||||
index = Index.objects.create(label='test')
|
||||
self.failUnlessEqual(list(Index.objects.all()), [index])
|
||||
|
||||
# Add our document type to the new index
|
||||
|
||||
@@ -41,8 +41,7 @@ class SetupIndexListView(SingleObjectListView):
|
||||
'title': _('Indexes'),
|
||||
'hide_object': True,
|
||||
'extra_columns': [
|
||||
{'name': _('Name'), 'attribute': 'name'},
|
||||
{'name': _('Title'), 'attribute': 'title'},
|
||||
{'name': _('Label'), 'attribute': 'label'},
|
||||
{'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', {
|
||||
'previous': previous,
|
||||
'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.'),
|
||||
}, context_instance=RequestContext(request))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user