Commit 93504538 authored by Jitka Novotna's avatar Jitka Novotna

models with slug

parent f31272fc
......@@ -30,7 +30,7 @@
<li><a href="#your-languages" data-toggle="tab">{% trans "Your languages" %}</a></li>
<li><a href="#your-subscriptions" data-toggle="tab">{% trans "Your subscriptions" %}</a></li>
{% for componentlist in componentlists %}
<li><a href="#todo" data-toggle="tab">{{ componentlist.title }}</a></li>
<li><a href="#todo" data-toggle="tab">{{ componentlist.name }}</a></li>
{% endfor %}
</ul>
</li>
......
......@@ -229,7 +229,7 @@ class WhiteboardAdmin(admin.ModelAdmin):
class ComponentListAdmin(admin.ModelAdmin):
list_display = ['title']
list_display = ['name']
class AdvertisementAdmin(admin.ModelAdmin):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('trans', '0058_componentlist'),
]
operations = [
migrations.RemoveField(
model_name='componentlist',
name='title',
),
migrations.AddField(
model_name='componentlist',
name='name',
field=models.CharField(default='uhno', help_text='Name to display', unique=True, max_length=100, verbose_name='Component list name'),
preserve_default=False,
),
migrations.AddField(
model_name='componentlist',
name='slug',
field=models.SlugField(default='uteho', max_length=100, help_text='Name used in URLs and file names.', unique=True, verbose_name='URL slug'),
preserve_default=False,
),
]
......@@ -29,15 +29,28 @@ from django.utils.translation import ugettext_lazy as _
@python_2_unicode_compatible
class ComponentList(models.Model):
title = models.CharField(max_length=100)
name = models.CharField(
verbose_name=_('Component list name'),
max_length=100,
unique=True,
help_text=_('Name to display')
)
slug = models.SlugField(
verbose_name=_('URL slug'),
db_index=True, unique=True,
max_length=100,
help_text=_('Name used in URLs and file names.')
)
components = models.ManyToManyField('SubProject')
def clean(self):
if not self.title:
if not self.name:
raise ValidationError(_('Name must be specified'))
def __str__(self):
return self.title
return self.name
class Meta(object):
verbose_name = _('Component list')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment