Hide/show delegated objects

This commit is contained in:
Sebastian Lohff 2017-03-27 01:09:40 +02:00
parent ecec36aa3d
commit 8509821f28
3 changed files with 13 additions and 5 deletions

View File

@ -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))

View File

@ -12,6 +12,9 @@
{% if mnts %}
<p>
You can create new database objects <a href="{% url "whoisdb:createObjectOverview" %}">here</a>.
{% if hasDelegations %}
See <a href="?delegated=1">also delegated objects</a>.
{% endif %}
</p>
</p>

View File

@ -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.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):