From 853140e8be4115644d8de03991633d7ebe52b62b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 17 Jun 2019 11:13:45 +0200 Subject: [PATCH 1/4] add unique constraint to UserExternalId (#32833) --- .../migrations/0024_auto_20190617_1113.py | 29 +++++++++++++++++++ src/authentic2/models.py | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 src/authentic2/migrations/0024_auto_20190617_1113.py diff --git a/src/authentic2/migrations/0024_auto_20190617_1113.py b/src/authentic2/migrations/0024_auto_20190617_1113.py new file mode 100644 index 00000000..0168bee9 --- /dev/null +++ b/src/authentic2/migrations/0024_auto_20190617_1113.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-06-17 09:13 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('custom_user', '0016_auto_20180925_1107'), + ('authentic2', '0023_auto_20181031_0900'), + ] + + operations = [ + migrations.CreateModel( + name='LDAPUser', + fields=[ + ], + options={ + 'proxy': True, + }, + bases=('custom_user.user',), + ), + migrations.AlterUniqueTogether( + name='userexternalid', + unique_together=set([('source', 'external_id')]), + ), + ] diff --git a/src/authentic2/models.py b/src/authentic2/models.py index d22e3a6b..9f2d239b 100644 --- a/src/authentic2/models.py +++ b/src/authentic2/models.py @@ -75,6 +75,9 @@ class UserExternalId(models.Model): class Meta: verbose_name = _('user external id') verbose_name_plural = _('user external ids') + unique_together = [ + ('source', 'external_id'), + ] @six.python_2_unicode_compatible -- 2.20.1