1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Added uniquieness constraint to Secret

This commit is contained in:
Jeremy Stretch
2016-06-14 16:25:18 -04:00
parent a3e64a9964
commit c149dd2bd0
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-06-14 20:19
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('secrets', '0004_auto_20160407_1548'),
]
operations = [
migrations.AlterUniqueTogether(
name='secret',
unique_together=set([('device', 'role', 'name')]),
),
]

View File

@ -195,6 +195,7 @@ class Secret(models.Model):
class Meta: class Meta:
ordering = ['device', 'role', 'name'] ordering = ['device', 'role', 'name']
unique_together = ['device', 'role', 'name']
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.plaintext = kwargs.pop('plaintext', None) self.plaintext = kwargs.pop('plaintext', None)