Commit 71dfe7e1 authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Switch to auto increment field in peers with configurable managemement

parent fb5ebbe2
......@@ -318,6 +318,14 @@ TINYMCE_DEFAULT_CONFIG = {
import _version
SW_VERSION = _version.VERSION
LOG_FILE_LOCATION = here("../log")
LOG_FILE_LOCATION = "/var/log/fod"
# Change the following values only if you know what you are doing!!!
# To integrate FoD with tables (Peer, Networks, Contacts)
# from your CRM platform, set the following values to False and create the views that are
# exact matches of the tables in peers/models.py
PEER_MANAGED_TABLE = True
PEER_RANGE_MANAGED_TABLE = True
PEER_TECHC_MANAGED_TABLE = True
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'PeerRange'
db.create_table(u'peer_range', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('network', self.gf('django.db.models.fields.CharField')(max_length=128)),
))
db.send_create_signal('peers', ['PeerRange'])
# Adding model 'TechcEmail'
db.create_table('techc_email', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('email', self.gf('django.db.models.fields.CharField')(max_length=352, db_column='email')),
))
db.send_create_signal('peers', ['TechcEmail'])
# Adding model 'Peer'
db.create_table(u'peer', (
('peer_id', self.gf('django.db.models.fields.IntegerField')(primary_key=True)),
('peer_name', self.gf('django.db.models.fields.CharField')(max_length=128)),
('peer_as', self.gf('django.db.models.fields.IntegerField')()),
('peer_tag', self.gf('django.db.models.fields.CharField')(max_length=64)),
('domain_name', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)),
))
db.send_create_signal('peers', ['Peer'])
# Adding M2M table for field networks on 'Peer'
db.create_table(u'peer_networks', (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('peer', models.ForeignKey(orm['peers.peer'], null=False)),
('peerrange', models.ForeignKey(orm['peers.peerrange'], null=False))
))
db.create_unique(u'peer_networks', ['peer_id', 'peerrange_id'])
# Adding M2M table for field techc_emails on 'Peer'
db.create_table(u'peer_techc_emails', (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('peer', models.ForeignKey(orm['peers.peer'], null=False)),
('techcemail', models.ForeignKey(orm['peers.techcemail'], null=False))
))
db.create_unique(u'peer_techc_emails', ['peer_id', 'techcemail_id'])
def backwards(self, orm):
# Deleting model 'PeerRange'
db.delete_table(u'peer_range')
# Deleting model 'TechcEmail'
db.delete_table('techc_email')
# Deleting model 'Peer'
db.delete_table(u'peer')
# Removing M2M table for field networks on 'Peer'
db.delete_table('peer_networks')
# Removing M2M table for field techc_emails on 'Peer'
db.delete_table('peer_techc_emails')
models = {
'peers.peer': {
'Meta': {'ordering': "['peer_name']", 'object_name': 'Peer', 'db_table': "u'peer'"},
'domain_name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'networks': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['peers.PeerRange']", 'null': 'True', 'blank': 'True'}),
'peer_as': ('django.db.models.fields.IntegerField', [], {}),
'peer_id': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}),
'peer_name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'peer_tag': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'techc_emails': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['peers.TechcEmail']", 'null': 'True', 'blank': 'True'})
},
'peers.peerrange': {
'Meta': {'ordering': "['network']", 'object_name': 'PeerRange', 'db_table': "u'peer_range'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'network': ('django.db.models.fields.CharField', [], {'max_length': '128'})
},
'peers.techcemail': {
'Meta': {'object_name': 'TechcEmail', 'db_table': "'techc_email'"},
'email': ('django.db.models.fields.CharField', [], {'max_length': '352', 'db_column': "'email'"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['peers']
\ No newline at end of file
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Changing field 'Peer.peer_id'
db.alter_column(u'peer', 'peer_id', self.gf('django.db.models.fields.AutoField')(primary_key=True))
def backwards(self, orm):
# Changing field 'Peer.peer_id'
db.alter_column(u'peer', 'peer_id', self.gf('django.db.models.fields.IntegerField')(primary_key=True))
models = {
'peers.peer': {
'Meta': {'ordering': "['peer_name']", 'object_name': 'Peer', 'db_table': "u'peer'"},
'domain_name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'networks': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['peers.PeerRange']", 'null': 'True', 'blank': 'True'}),
'peer_as': ('django.db.models.fields.IntegerField', [], {}),
'peer_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'peer_name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'peer_tag': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
'techc_emails': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['peers.TechcEmail']", 'null': 'True', 'blank': 'True'})
},
'peers.peerrange': {
'Meta': {'ordering': "['network']", 'object_name': 'PeerRange', 'db_table': "u'peer_range'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'network': ('django.db.models.fields.CharField', [], {'max_length': '128'})
},
'peers.techcemail': {
'Meta': {'object_name': 'TechcEmail', 'db_table': "'techc_email'"},
'email': ('django.db.models.fields.CharField', [], {'max_length': '352', 'db_column': "'email'"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
}
}
complete_apps = ['peers']
\ No newline at end of file
......@@ -19,6 +19,7 @@
from django.db import models
from utils.whois import *
from django.contrib.auth.models import User
from django.conf import settings
class PeerRange(models.Model):
network = models.CharField(max_length=128)
......@@ -27,6 +28,7 @@ class PeerRange(models.Model):
class Meta:
db_table = u'peer_range'
ordering = ['network']
managed = settings.PEER_RANGE_MANAGED_TABLE
class TechcEmail(models.Model):
email = models.CharField(max_length=352, db_column="email")
......@@ -34,9 +36,10 @@ class TechcEmail(models.Model):
return self.email
class Meta:
db_table="techc_email"
managed = settings.PEER_TECHC_MANAGED_TABLE
class Peer(models.Model):
peer_id = models.IntegerField(primary_key=True)
peer_id = models.AutoField(primary_key=True)
peer_name = models.CharField(max_length=128)
peer_as = models.IntegerField()
peer_tag = models.CharField(max_length=64)
......@@ -49,6 +52,7 @@ class Peer(models.Model):
class Meta:
db_table = u'peer'
ordering = ['peer_name']
managed = settings.PEER_MANAGED_TABLE
def fill_networks(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment