Commit a0243761 authored by stammy31's avatar stammy31

Add PeerNotify model. It is useful for keeping track of notifications have...

Add PeerNotify model. It is useful for keeping track of notifications have been sent to peers due to actions of their users.
parent 278d9eca
......@@ -19,7 +19,7 @@
from django.contrib import admin
from peers.models import PeerRange, TechcEmail, Peer
from peers.models import PeerRange, TechcEmail, Peer, PeerNotify
from django import forms
from django.forms import ModelForm
from django.contrib.admin.widgets import FilteredSelectMultiple
......@@ -55,6 +55,11 @@ class TechcEmailAdmin(admin.ModelAdmin):
search_fields = ['email']
class PeerNotifyAdmin(admin.ModelAdmin):
search_fields = ['peer', 'user']
admin.site.register(Peer, PeerAdmin)
admin.site.register(PeerRange, PeerRangeAdmin)
admin.site.register(TechcEmail, TechcEmailAdmin)
admin.site.register(PeerNotify, PeerNotifyAdmin)
# encoding: 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 'PeerNotify'
db.create_table('peers_peernotify', (
('peer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['peers.Peer'])),
('peer_activation_notified', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),
))
db.send_create_signal('peers', ['PeerNotify'])
# Changing field 'Peer.peer_as'
db.alter_column(u'peer', 'peer_as', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True))
def backwards(self, orm):
# Deleting model 'PeerNotify'
db.delete_table('peers_peernotify')
# Changing field 'Peer.peer_as'
db.alter_column(u'peer', 'peer_as', self.gf('django.db.models.fields.IntegerField')())
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2015, 9, 30, 11, 3, 45, 718326)'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2015, 9, 30, 11, 3, 45, 718278)'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'contenttypes.contenttype': {
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'peers.peer': {
'Meta': {'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', [], {'null': 'True', 'blank': 'True'}),
'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.peernotify': {
'Meta': {'object_name': 'PeerNotify'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'peer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['peers.Peer']"}),
'peer_activation_notified': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
},
'peers.peerrange': {
'Meta': {'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']
......@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from django.contrib.auth.models import User
from django.db import models
from utils.whois import *
from django.conf import settings
......@@ -48,7 +49,7 @@ class TechcEmail(models.Model):
class Peer(models.Model):
peer_id = models.AutoField(primary_key=True)
peer_name = models.CharField(max_length=128)
peer_as = models.IntegerField()
peer_as = models.IntegerField(null=True, blank=True)
# This needs to be converted to slug and an info message needs to be added.
peer_tag = models.CharField(max_length=64)
domain_name = models.CharField(max_length=128, null=True, blank=True)
......@@ -74,3 +75,12 @@ class Peer(models.Model):
networks_list.append(range)
self.networks = networks_list
self.save()
class PeerNotify(models.Model):
peer = models.ForeignKey(Peer)
user = models.ForeignKey(User)
peer_activation_notified = models.BooleanField(default=True)
def __unicode__(self):
return self.peer_activation_notified
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