More links, anonymous search

This commit is contained in:
Sebastian Lohff 2017-03-27 13:36:03 +02:00
parent 231f8a7f30
commit f6440a57e3
3 changed files with 9 additions and 8 deletions

View File

@ -45,10 +45,11 @@
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<li{% if request.resolver_match.url_name == 'index' %} class="active"{%endif%}><a href="{% url "dashboard" %}">Dashboard</a></li> <li{% if request.resolver_match.url_name == 'dashboard' %} class="active"{%endif%}><a href="{% url "dashboard" %}">Dashboard</a></li>
{% else %} {% else %}
<li{% if request.resolver_match.url_name == 'index' %} class="active"{%endif%}><a href="{% url "index" %}">Home</a></li> <li{% if request.resolver_match.url_name == 'index' %} class="active"{%endif%}><a href="{% url "index" %}">Home</a></li>
{% endif %} {% endif %}
<li{% if "dncore" in request.resolver_match.app and request.resolver_match.url_name == 'search' %} class="active"{%endif%}><a href="{% url "whoisdb:search" %}">Search</a></li>
<li class="dropdown{% if request.resolver_match.url_name == 'whoisdb' %} active{%endif%}"> <li class="dropdown{% if request.resolver_match.url_name == 'whoisdb' %} active{%endif%}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Whois DB <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Whois DB <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">

View File

@ -108,12 +108,9 @@ def findInDatabase(rawValue):
whoisdb.models.ASNumber, whoisdb.models.ASNumber,
] ]
for handleObj in handleObjs: for handleObj in handleObjs:
results.extend(handleObj.objects.filter(handle=rawValue)) obj = handleObj.objects.filter(handle=rawValue)
if not obj and len(rawValue) >= 3:
obj = handleObj.objects.filter(handle__startswith=rawValue)
results.extend(obj)
return results return results
# try:
# - ipnetwork
# - ipaddress
# - asnumber (either asXXXXXX or just number XXXXXX)
# - handle name

View File

@ -116,6 +116,9 @@ class MntdObject(WhoisObject):
mnt_by = models.ManyToManyField(Maintainer) mnt_by = models.ManyToManyField(Maintainer)
def canEdit(self, user): def canEdit(self, user):
if not hasattr(user, "maintainer_set"):
return False
mnts = user.maintainer_set.all() mnts = user.maintainer_set.all()
objmnts = self.mnt_by.all() objmnts = self.mnt_by.all()
if hasattr(self, "mnt_lower"): if hasattr(self, "mnt_lower"):