topic name should be unique *per site*

This commit is contained in:
Élie Bouttier 2016-07-11 22:58:46 +02:00
parent 28f7fb782c
commit 97c47a279d
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-11 20:58
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('proposals', '0003_auto_20160711_1933'),
]
operations = [
migrations.AlterField(
model_name='topic',
name='name',
field=models.CharField(max_length=128, verbose_name='Name'),
),
migrations.AlterUniqueTogether(
name='topic',
unique_together=set([('site', 'name')]),
),
]

View File

@ -18,11 +18,14 @@ class Topic(PonyConfModel):
site = models.ForeignKey(Site, on_delete=models.CASCADE)
name = models.CharField(max_length=128, verbose_name='Name', unique=True)
name = models.CharField(max_length=128, verbose_name='Name')
slug = AutoSlugField(populate_from='name', unique=True)
reviewers = models.ManyToManyField(User, blank=True)
class Meta:
unique_together = ('site', 'name')
def __str__(self):
return self.name