From 8509821f282afbfce5426671395c2bfc85214eed Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Mon, 27 Mar 2017 01:09:40 +0200 Subject: [PATCH] Hide/show delegated objects --- dncore/views.py | 5 +++-- templates/whoisdb/overview.html | 3 +++ whoisdb/views.py | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dncore/views.py b/dncore/views.py index 44f3df0..21a45aa 100644 --- a/dncore/views.py +++ b/dncore/views.py @@ -22,8 +22,9 @@ def profile(request): @login_required def dashboard(request): mnts = request.user.maintainer_set.all() - asns = ASNumber.objects.filter(Q(mnt_by__in=mnts) | Q(mnt_lower__in=mnts)) - inetnums = InetNum.objects.filter(Q(mnt_by__in=mnts) | Q(mnt_lower__in=mnts)) + ownMnts = request.user.maintainer_set.filter(rir=False, lir=False).all() + asns = ASNumber.objects.filter(Q(mnt_by__in=ownMnts) | Q(mnt_lower__in=ownMnts)) + inetnums = InetNum.objects.filter(Q(mnt_by__in=ownMnts) | Q(mnt_lower__in=ownMnts)) domains = Domain.objects.filter(mnt_by__in=mnts) rrequests = Request.objects.filter((Q(provider__in=mnts) | Q(applicant__in=mnts)) & Q(status=Request.STATE_OPEN)) diff --git a/templates/whoisdb/overview.html b/templates/whoisdb/overview.html index c2fc260..879687a 100644 --- a/templates/whoisdb/overview.html +++ b/templates/whoisdb/overview.html @@ -12,6 +12,9 @@ {% if mnts %}

You can create new database objects here. + {% if hasDelegations %} + See also delegated objects. + {% endif %}

diff --git a/whoisdb/views.py b/whoisdb/views.py index 27d1b5a..e078c0c 100644 --- a/whoisdb/views.py +++ b/whoisdb/views.py @@ -15,7 +15,7 @@ from .generic import DeleteCheckView, MntGenericMixin @login_required def createObjectOverview(request): - mnts = request.user.maintainer_set.all() + mnts = request.user.maintainer_set.filter().all() netblocks = InetNum.objects.filter(Q(mnt_by__in=mnts) | Q(mnt_lower__in=mnts)).distinct() asblocks = ASBlock.objects.filter(Q(mnt_by__in=mnts) | Q(mnt_lower__in=mnts)).distinct() @@ -24,7 +24,11 @@ def createObjectOverview(request): @login_required def dbDashboard(request): - mnts = request.user.maintainer_set.all() + mnts = request.user.maintainer_set.filter(rir=False, lir=False).all() + if request.GET.get("delegated", None): + mnts = request.user.maintainer_set.all() + hasDelegations = request.user.maintainer_set.filter(Q(rir=True) | Q(lir=True)).count() > 0 + contacts = Contact.objects.filter(mnt_by__in=mnts) netblocks = InetNum.objects.filter(Q(mnt_by__in=mnts) | Q(mnt_lower__in=mnts)).distinct() asblocks = ASBlock.objects.filter(Q(mnt_by__in=mnts) | Q(mnt_lower__in=mnts)).distinct() @@ -57,7 +61,7 @@ def dbDashboard(request): mntForm = MntInitialForm(user=request.user, prefix="mnt", initial={'handle': 'AUTO', 'description': 'Primary maintainer of %s' % request.user.username}) contactForm = ContactInitialForm(user=request.user, initial={'handle': 'AUTO', 'name': request.user.username.capitalize()}, prefix='contact') - return render(request, "whoisdb/overview.html", {"mnts": mnts, "contacts": contacts, "mntForm": mntForm, "contactForm": contactForm, "netblocks": netblocks, "asblocks": asblocks, "asnumbers": asnumbers}) + return render(request, "whoisdb/overview.html", {"mnts": mnts, "contacts": contacts, "mntForm": mntForm, "contactForm": contactForm, "netblocks": netblocks, "asblocks": asblocks, "asnumbers": asnumbers, 'hasDelegations': hasDelegations}) def showHandle(request, handle):