add KBCategory.name, improve KBCategory admin

This commit is contained in:
Petr Dlouhý 2020-02-25 14:25:24 +01:00
parent 07d6ee7f87
commit 5a594b7436
3 changed files with 45 additions and 3 deletions

View File

@ -93,6 +93,10 @@ class IgnoreEmailAdmin(admin.ModelAdmin):
list_display = ('name', 'queue_list', 'email_address', 'keep_in_mailbox') list_display = ('name', 'queue_list', 'email_address', 'keep_in_mailbox')
@admin.register(KBCategory)
class KBCategoryAdmin(admin.ModelAdmin):
list_display = ('name', 'title', 'slug', )
admin.site.register(PreSetReply) admin.site.register(PreSetReply)
admin.site.register(EscalationExclusion) admin.site.register(EscalationExclusion)
admin.site.register(KBCategory)

View File

@ -0,0 +1,33 @@
# Generated by Django 2.2.10 on 2020-02-25 11:21
from django.db import migrations, models
def copy_title(apps, schema_editor):
KBCategory = apps.get_model("helpdesk", "KBCategory")
KBCategory.objects.update(name=models.F('title'))
class Migration(migrations.Migration):
dependencies = [
('helpdesk', '0029_kbcategory_public'),
]
operations = [
migrations.AddField(
model_name='kbcategory',
name='name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Name of the category'),
),
migrations.AlterField(
model_name='kbcategory',
name='title',
field=models.CharField(max_length=100, verbose_name='Title on knowledgebase page'),
),
migrations.RunPython(copy_title, migrations.RunPython.noop),
migrations.AlterField(
model_name='kbcategory',
name='name',
field=models.CharField(blank=False, max_length=100, null=False, verbose_name='Name of the category'),
),
]

View File

@ -1215,8 +1215,13 @@ class KBCategory(models.Model):
listing of questions & answers. listing of questions & answers.
""" """
name = models.CharField(
_('Name of the category'),
max_length=100,
)
title = models.CharField( title = models.CharField(
_('Title'), _('Title on knowledgebase page'),
max_length=100, max_length=100,
) )
@ -1242,7 +1247,7 @@ class KBCategory(models.Model):
) )
def __str__(self): def __str__(self):
return '%s' % self.title return '%s' % self.name
class Meta: class Meta:
ordering = ('title',) ordering = ('title',)