mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Merge pull request #111 from dannybrowne86/master
added database-level enforcement of unique user+primary pair in Avatar model
This commit is contained in:
commit
b6edb17824
2 changed files with 19 additions and 0 deletions
18
avatar/migrations/0002_add_user_primary_unique_together.py
Executable file
18
avatar/migrations/0002_add_user_primary_unique_together.py
Executable 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')]),
|
||||
),
|
||||
]
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue