Projet

Général

Profil

0002-create-unique-index-on-AccessRight.-13887.patch

Benjamin Dauvergne, 17 janvier 2017 10:29

Télécharger (1,77 ko)

Voir les différences:

Subject: [PATCH 2/3] create unique index on AccessRight.* (#13887)

It will garantee that get_or_create() calls in the BaseResource.import_json()
function will always work.
 passerelle/base/migrations/0004_auto_20170117_0326.py | 18 ++++++++++++++++++
 passerelle/base/models.py                             |  3 +++
 2 files changed, 21 insertions(+)
 create mode 100644 passerelle/base/migrations/0004_auto_20170117_0326.py
passerelle/base/migrations/0004_auto_20170117_0326.py
1
# -*- coding: utf-8 -*-
2
from __future__ import unicode_literals
3

  
4
from django.db import models, migrations
5

  
6

  
7
class Migration(migrations.Migration):
8

  
9
    dependencies = [
10
        ('base', '0003_auto_20170116_1656'),
11
    ]
12

  
13
    operations = [
14
        migrations.AlterUniqueTogether(
15
            name='accessright',
16
            unique_together=set([('codename', 'resource_type', 'resource_pk', 'apiuser')]),
17
        ),
18
    ]
passerelle/base/models.py
167 167
        permissions = (
168 168
            ('view_accessright', 'Can view access right'),
169 169
        )
170
        unique_together = (
171
            ('codename', 'resource_type', 'resource_pk', 'apiuser'),
172
        )
170 173

  
171 174
    def __unicode__(self):
172 175
        return '%s (on %s <%s>) (for %s)' % (self.codename,
173
-