From cb878d3ed8a5828e6dec42b0ead8adeeda539485 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Wed, 15 Feb 2017 02:35:46 +0100 Subject: [PATCH] zwischencommit --- dncore/urls.py | 1 + dncore/views.py | 2 +- dnmgmt/urls.py | 4 +- templates/base.html | 17 +++++--- templates/dncore/dashboard.html | 15 +++++++ templates/registration/login.html | 4 +- templates/registration/register.html | 2 +- whoisdb/models.py | 63 +++++++++++++++++++++++++++- whoisdb/validators.py | 13 ++++++ 9 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 templates/dncore/dashboard.html create mode 100644 whoisdb/validators.py diff --git a/dncore/urls.py b/dncore/urls.py index aab6521..e4dbd30 100644 --- a/dncore/urls.py +++ b/dncore/urls.py @@ -7,6 +7,7 @@ urlpatterns = [ url(r'^$', dncore_views.dashboard, name='dashboard'), url(r'^login/$', auth_views.login, name='login'), + url(r'^login/$', auth_views.login, name='register'), url(r'^logout/$', auth_views.logout, {'next_page': '/'}, name='logout'), url(r'^profile/$', dncore_views.profile, name='profile'), ] diff --git a/dncore/views.py b/dncore/views.py index 90ff661..5053ab1 100644 --- a/dncore/views.py +++ b/dncore/views.py @@ -7,7 +7,7 @@ def profile(request): @login_required def dashboard(request): - pass + return render(request, "dncore/dashboard.html", {}) def index(request): return render(request, "index.html", {}) diff --git a/dnmgmt/urls.py b/dnmgmt/urls.py index 94c98dd..dac152e 100644 --- a/dnmgmt/urls.py +++ b/dnmgmt/urls.py @@ -22,8 +22,8 @@ import whoisdb.urls urlpatterns = [ - url(r'^$', dncore.views.index), - url(r'^dashboard/$', dncore.views.dashboard), + url(r'^$', dncore.views.index, name='index'), + url(r'^dashboard/$', dncore.views.dashboard, name='dashboard'), url(r'^admin/', admin.site.urls), url(r'^user/', include(dncore.urls, namespace='user')), diff --git a/templates/base.html b/templates/base.html index 9ff0196..d86a4ad 100644 --- a/templates/base.html +++ b/templates/base.html @@ -35,29 +35,34 @@ - Darknet Mgmt + Darknet Mgmt diff --git a/templates/dncore/dashboard.html b/templates/dncore/dashboard.html new file mode 100644 index 0000000..24acbdd --- /dev/null +++ b/templates/dncore/dashboard.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block content %} +
+
+
+
Welcome!
+
+ Here you can manage your darknet resources! +
+
+
+
+{% endblock %} + diff --git a/templates/registration/login.html b/templates/registration/login.html index dae0786..47c3ec1 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -10,9 +10,9 @@
Login

- Don't have an account? Register here! + Don't have an account? Register here!

-
+ {% csrf_token %} {{ form|crispy }} diff --git a/templates/registration/register.html b/templates/registration/register.html index 6fedb8a..0540f46 100644 --- a/templates/registration/register.html +++ b/templates/registration/register.html @@ -12,7 +12,7 @@ Please register with your (uppercase) Callsign as Usernames. For DN-Calls, -[0-9] is allowed.

- + {% csrf_token %} {{ form|crispy }} diff --git a/whoisdb/models.py b/whoisdb/models.py index 259d73c..f3c7265 100644 --- a/whoisdb/models.py +++ b/whoisdb/models.py @@ -1,6 +1,67 @@ from django.db import models from dncore.models import User +from .validators import HandleValidator -class Maintainer(models.Model): +class ExtraFields(models.Model): + name = models.CharField(max_length=64) + value = models.CharField(max_length=128) + + order = models.PositiveSmallIntegerField() + +class WhoisObject(models.Model): + handle_suffix = None + whois_fields = None + whois_extra_field_names = None + + 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) + + class Meta: + abstract = True + +class Maintainer(WhoisObject): auth = models.ManyToManyField(User) + + admin_c = models.ManyToManyField("Contact") + +class MntdObject(WhoisObject): + mnt_by = models.ManyToManyField(Maintainer) + + class Meta: + abstract = True + + +class Contact(MntdObject): + TYPE = (('person', 'person'), ('role', 'role')) + + name = models.CharField(max_length=128) + +class MntdCObject(MntdObject) + admin_c = models.ManyToManyField("Contact") + + class Meta: + abstract = True + +class MntdObject(WhoisObject): + admin_c = models.ManyToManyField(Contact) + mnt_by = models + + class Meta: + abstract = True + + + + +class ASNumber(WhoisObject): + number = models.PositiveIntegerField(unique=True, db_index=True) + + +class InetNum(WhoisObject): + PROTO = (('ipv4', 'ipv4'), ('ipv6', 'ipv6')) + protocol = models.CharField(max_length=4, choices=PROTO) + netmask = models.PositiveIntegerField() + +#class ASBlock(WhoisObject): +# pass diff --git a/whoisdb/validators.py b/whoisdb/validators.py new file mode 100644 index 0000000..651f608 --- /dev/null +++ b/whoisdb/validators.py @@ -0,0 +1,13 @@ +from django.core import validators +from django.utils import six +from django.utils.deconstruct import deconstructible +from django.utils.translation import ugettext_lazy as _ + +@deconstructible +class HandleValidator(validators.RegexValidator): + regex = r'^[A-Z]+[0-9]+(-[A-Z]+)' + message = _( + 'Enter a valid handle (all uppercase)' + ) + flags = re.ASCII if six.PY3 else 0 +