diff --git a/README b/README
new file mode 100644
index 0000000..ca8bfcb
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+whoisdb
+ see own objects
+
+ list of all ASses?
diff --git a/templates/base.html b/templates/base.html
index d86a4ad..deb9d12 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -47,7 +47,7 @@
Whois DB
diff --git a/templates/whoisdb/overview.html b/templates/whoisdb/overview.html
new file mode 100644
index 0000000..3bd5375
--- /dev/null
+++ b/templates/whoisdb/overview.html
@@ -0,0 +1,35 @@
+{% extends "base.html" %}
+
+{% load crispy_forms_tags %}
+
+{% block content %}
+
+
+
+
Header
+
+ {% if mnts %}
+
+ {% else %}
+ You don't have a maintainer! Start by creating a Maintainer and a Person Object!
+
+
+ {% endif %}
+
+
+
+
+{% endblock %}
+
diff --git a/whoisdb/admin.py b/whoisdb/admin.py
index 8c38f3f..cb233a4 100644
--- a/whoisdb/admin.py
+++ b/whoisdb/admin.py
@@ -1,3 +1,9 @@
from django.contrib import admin
-# Register your models here.
+from .models import Maintainer, Contact, ASBlock, ASNumber, InetNum
+
+admin.site.register(Maintainer)
+admin.site.register(Contact)
+admin.site.register(ASBlock)
+admin.site.register(ASNumber)
+admin.site.register(InetNum)
diff --git a/whoisdb/forms.py b/whoisdb/forms.py
new file mode 100644
index 0000000..74a7d09
--- /dev/null
+++ b/whoisdb/forms.py
@@ -0,0 +1,22 @@
+from django import forms
+
+#from crispy_forms.helper import FormHelper
+#from crispy_forms.layout import Submit, Layout
+#from django.urls import reverse
+
+from .models import Maintainer, Contact
+
+class MntForm(forms.ModelForm):
+ class Meta:
+ model = Maintainer
+ fields = ['handle', 'description']
+
+class ContactForm(forms.ModelForm):
+ class Meta:
+ model = Contact
+ fields = ['handle', 'name']
+
+ def __init__(self, person=True, *args, **kwargs):
+ super(ContactForm, self).__init__(*args, **kwargs)
+ # check if this is a person
+ self.person = person
diff --git a/whoisdb/migrations/0002_auto_20170221_2240.py b/whoisdb/migrations/0002_auto_20170221_2240.py
new file mode 100644
index 0000000..304577b
--- /dev/null
+++ b/whoisdb/migrations/0002_auto_20170221_2240.py
@@ -0,0 +1,133 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-21 22:40
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+import whoisdb.validators
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('whoisdb', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ASBlock',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('handle', models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()])),
+ ('created', models.DateTimeField(auto_now_add=True)),
+ ('last_modified', models.DateTimeField(auto_now_add=True)),
+ ('description', models.CharField(blank=True, max_length=64)),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ migrations.CreateModel(
+ name='ASNumber',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('handle', models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()])),
+ ('created', models.DateTimeField(auto_now_add=True)),
+ ('last_modified', models.DateTimeField(auto_now_add=True)),
+ ('number', models.PositiveIntegerField(db_index=True, unique=True)),
+ ('volatile', models.BooleanField(default=False)),
+ ('description', models.CharField(blank=True, max_length=64)),
+ ('asblock', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='whoisdb.ASBlock')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ migrations.CreateModel(
+ name='Contact',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('handle', models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()])),
+ ('created', models.DateTimeField(auto_now_add=True)),
+ ('last_modified', models.DateTimeField(auto_now_add=True)),
+ ('name', models.CharField(max_length=128)),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ migrations.CreateModel(
+ name='InetNum',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('handle', models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()])),
+ ('created', models.DateTimeField(auto_now_add=True)),
+ ('last_modified', models.DateTimeField(auto_now_add=True)),
+ ('protocol', models.CharField(choices=[('ipv4', 'ipv4'), ('ipv6', 'ipv6')], max_length=4)),
+ ('netmask', models.PositiveIntegerField()),
+ ('description', models.CharField(blank=True, max_length=64)),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ migrations.AddField(
+ model_name='maintainer',
+ name='created',
+ field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='maintainer',
+ name='handle',
+ field=models.SlugField(default=None, max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()]),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='maintainer',
+ name='last_modified',
+ field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='inetnum',
+ name='mnt_lower',
+ field=models.ManyToManyField(to='whoisdb.Maintainer'),
+ ),
+ migrations.AddField(
+ model_name='inetnum',
+ name='parent_range',
+ field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='whoisdb.InetNum'),
+ ),
+ migrations.AddField(
+ model_name='contact',
+ name='mnt_by',
+ field=models.ManyToManyField(to='whoisdb.Maintainer'),
+ ),
+ migrations.AddField(
+ model_name='asnumber',
+ name='mnt_by',
+ field=models.ManyToManyField(to='whoisdb.Maintainer'),
+ ),
+ migrations.AddField(
+ model_name='asnumber',
+ name='mnt_lower',
+ field=models.ManyToManyField(related_name='lower_asnumber_set', to='whoisdb.Maintainer'),
+ ),
+ migrations.AddField(
+ model_name='asblock',
+ name='mnt_by',
+ field=models.ManyToManyField(to='whoisdb.Maintainer'),
+ ),
+ migrations.AddField(
+ model_name='asblock',
+ name='parent_block',
+ field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='whoisdb.ASBlock'),
+ ),
+ migrations.AddField(
+ model_name='maintainer',
+ name='admin_c',
+ field=models.ManyToManyField(to='whoisdb.Contact'),
+ ),
+ ]
diff --git a/whoisdb/migrations/0003_auto_20170222_1812.py b/whoisdb/migrations/0003_auto_20170222_1812.py
new file mode 100644
index 0000000..39e454d
--- /dev/null
+++ b/whoisdb/migrations/0003_auto_20170222_1812.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.5 on 2017-02-22 18:12
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import whoisdb.validators
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('whoisdb', '0002_auto_20170221_2240'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='maintainer',
+ name='description',
+ field=models.CharField(blank=True, max_length=64),
+ ),
+ migrations.AlterField(
+ model_name='asblock',
+ name='handle',
+ field=models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()], verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='asnumber',
+ name='handle',
+ field=models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()], verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='contact',
+ name='handle',
+ field=models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()], verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='inetnum',
+ name='handle',
+ field=models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()], verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='maintainer',
+ name='handle',
+ field=models.SlugField(max_length=32, unique=True, validators=[whoisdb.validators.HandleValidator()], verbose_name='name'),
+ ),
+ ]
diff --git a/whoisdb/models.py b/whoisdb/models.py
index c2cd3e2..f40b513 100644
--- a/whoisdb/models.py
+++ b/whoisdb/models.py
@@ -5,17 +5,18 @@ from .validators import HandleValidator
class WhoisObject(models.Model):
- handle_suffix = None
+ handle_suffix = ""
- handle = models.SlugField(max_length='32', unique=True, validators=[HandleValidator()])
- created = models.DateTimeField(auto_add_now=True)
- last_modified = models.DateTimeField(auto_add_now=True)
+ handle = models.SlugField(max_length=32, unique=True, verbose_name='handle', validators=[HandleValidator()])
+ created = models.DateTimeField(auto_now_add=True)
+ last_modified = models.DateTimeField(auto_now_add=True)
class Meta:
abstract = True
class Maintainer(WhoisObject):
auth = models.ManyToManyField(User)
+ description = models.CharField(max_length=64, blank=True)
admin_c = models.ManyToManyField("Contact")
@@ -41,7 +42,7 @@ class ASNumber(MntdObject):
asblock = models.ForeignKey(ASBlock, models.CASCADE)
description = models.CharField(max_length=64, blank=True)
- mnt_lower = models.ManyToManyField(Maintainer)
+ mnt_lower = models.ManyToManyField(Maintainer, related_name='lower_asnumber_set')
#class Route(MntObject):
#
diff --git a/whoisdb/urls.py b/whoisdb/urls.py
index 8e2fb07..a0f1821 100644
--- a/whoisdb/urls.py
+++ b/whoisdb/urls.py
@@ -3,6 +3,6 @@ from django.conf.urls import url
from . import views as whoisdb_views
urlpatterns = [
- #url(r'^$', dncore_views.dashboard, name='dashboard'),
+ url(r'^$', whoisdb_views.dbDashboard, name='dashboard'),
]
diff --git a/whoisdb/validators.py b/whoisdb/validators.py
index 651f608..0a6fd24 100644
--- a/whoisdb/validators.py
+++ b/whoisdb/validators.py
@@ -3,6 +3,8 @@ from django.utils import six
from django.utils.deconstruct import deconstructible
from django.utils.translation import ugettext_lazy as _
+import re
+
@deconstructible
class HandleValidator(validators.RegexValidator):
regex = r'^[A-Z]+[0-9]+(-[A-Z]+)'
diff --git a/whoisdb/views.py b/whoisdb/views.py
index 91ea44a..c8fc5f3 100644
--- a/whoisdb/views.py
+++ b/whoisdb/views.py
@@ -1,3 +1,31 @@
from django.shortcuts import render
+from django.contrib.auth.decorators import login_required
+from django.http import HttpResponseRedirect
+from django.urls import reverse
+
+from .forms import MntForm, ContactForm
+
+@login_required
+def dbDashboard(request):
+ mnts = request.user.maintainer_set.all()
+
+ mntForm = contactForm = None
+ if request.method == "POST":
+ mntForm = MntForm(data=request.POST, prefix="mnt_")
+ contactForm = ContactForm(person=True, data=request.POST, prefix="contact")
+ if mntForm.is_valid() and contactForm.is_valid():
+ print("NOOT")
+
+ #return HttpResponseRedirect(reverse("whoisdb:dashboard"))
+
+
+ mntForm = MntForm(prefix="mnt", initial={'handle': 'AUTO', 'description': 'Main maintainer of %s' % request.user.username})
+ contactForm = ContactForm(person=True, initial={'handle': 'AUTO'}, prefix='contact_')
+ return render(request, "whoisdb/overview.html", {"mnts": mnts, "mntForm": mntForm, "contactForm": contactForm})
+
+def manageMnt(request, mnt=None):
+ if mnt:
+ # object or 404
+ pass
+ return render(request, "whoisdb/overview.html", {})
-# Create your views here.