Merge pull request #111 from dannybrowne86/master

added database-level enforcement of unique user+primary pair in Avatar model
This commit is contained in:
Grant McConnaughey 2015-10-23 08:54:34 -05:00
commit b6edb17824
2 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('avatar', '0001_initial'),
]
operations = [
migrations.AlterUniqueTogether(
name='avatar',
unique_together=set([('user', 'primary')]),
),
]

View file

@ -72,6 +72,7 @@ class Avatar(models.Model):
class Meta:
app_label = 'avatar'
unique_together = ('user', 'primary')
def __unicode__(self):
return _(six.u('Avatar for %s')) % self.user