From 97c47a279dde0c598141445a7b01bb9f04294163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Mon, 11 Jul 2016 22:58:46 +0200 Subject: [PATCH] topic name should be unique *per site* --- .../migrations/0004_auto_20160711_2058.py | 24 +++++++++++++++++++ proposals/models.py | 5 +++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 proposals/migrations/0004_auto_20160711_2058.py diff --git a/proposals/migrations/0004_auto_20160711_2058.py b/proposals/migrations/0004_auto_20160711_2058.py new file mode 100644 index 0000000..3fcf144 --- /dev/null +++ b/proposals/migrations/0004_auto_20160711_2058.py @@ -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')]), + ), + ] diff --git a/proposals/models.py b/proposals/models.py index 8c2cb9e..4d80ea2 100644 --- a/proposals/models.py +++ b/proposals/models.py @@ -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