From fa85504d7185d90f8995e128650f5785a34979e0 Mon Sep 17 00:00:00 2001 From: Matt Griswold Date: Mon, 1 Apr 2019 15:01:57 -0500 Subject: [PATCH] PR qu20020 branding fixes (#467) * Qu20020 - Assorted Fixes - PeeringDB version is missing on the error page footer #432 - Inconsistent page widths #446 - Facility countries show up in different languages #448 - sponsor level in search results #449 * fix tests --- config/facsimile/peeringdb.yaml | 5 + peeringdb_server/data_views.py | 22 +- peeringdb_server/search.py | 24 +- peeringdb_server/static/peeringdb.js | 44 +++- peeringdb_server/static/site.css | 20 +- peeringdb_server/static/sponsors-style.css | 2 +- peeringdb_server/templates/site/about.html | 2 +- .../templates/site/advanced-search.html | 65 ++--- peeringdb_server/templates/site/aup.html | 2 +- .../templates/site/profile-affiliate.html | 66 ++++++ .../templates/site/profile-change-email.html | 32 +++ .../site/profile-change-password.html | 33 +++ .../templates/site/profile-confirm-email.html | 31 +++ .../templates/site/profile-pick-language.html | 22 ++ .../templates/site/search_result.html | 22 +- peeringdb_server/templates/site/verify.html | 222 ++---------------- .../site/view_organization_side.html | 36 +-- peeringdb_server/urls.py | 1 + peeringdb_server/views.py | 15 +- tests/test_search.py | 46 +++- tests/test_sponsors.py | 85 +++++++ 21 files changed, 524 insertions(+), 273 deletions(-) create mode 100644 peeringdb_server/templates/site/profile-affiliate.html create mode 100644 peeringdb_server/templates/site/profile-change-email.html create mode 100644 peeringdb_server/templates/site/profile-change-password.html create mode 100644 peeringdb_server/templates/site/profile-confirm-email.html create mode 100644 peeringdb_server/templates/site/profile-pick-language.html create mode 100644 tests/test_sponsors.py diff --git a/config/facsimile/peeringdb.yaml b/config/facsimile/peeringdb.yaml index 64d9e5df..cd1a998b 100644 --- a/config/facsimile/peeringdb.yaml +++ b/config/facsimile/peeringdb.yaml @@ -177,6 +177,11 @@ install: - $SRC_DIR$/peeringdb_server/templates/site/error_404.html - $SRC_DIR$/peeringdb_server/templates/site/error_403.html - $SRC_DIR$/peeringdb_server/templates/site/maintenance.html + - $SRC_DIR$/peeringdb_server/templates/site/profile-change-password.html + - $SRC_DIR$/peeringdb_server/templates/site/profile-change-email.html + - $SRC_DIR$/peeringdb_server/templates/site/profile-affiliate.html + - $SRC_DIR$/peeringdb_server/templates/site/profile-confirm-email.html + - $SRC_DIR$/peeringdb_server/templates/site/profile-pick-language.html - $SRC_DIR$/peeringdb_server/templates/site/view_network_side.html - $SRC_DIR$/peeringdb_server/templates/site/view_network_bottom.html - $SRC_DIR$/peeringdb_server/templates/site/view_exchange_side.html diff --git a/peeringdb_server/data_views.py b/peeringdb_server/data_views.py index cd866946..4f2cf6de 100644 --- a/peeringdb_server/data_views.py +++ b/peeringdb_server/data_views.py @@ -4,16 +4,19 @@ This holds JSON views for various data sets, Mostly these are needed for filling form-selects for editable mode """ +import datetime + from django.contrib.auth.decorators import login_required from django.http import JsonResponse import django_countries import models import django_peeringdb.const as const -from peeringdb_server.models import Organization, Network - from django.utils import translation from django.utils.translation import ugettext_lazy as _ +from peeringdb_server.models import ( + Organization, Network, Sponsorship) + #def _(x): # return x @@ -76,6 +79,21 @@ def countries(request): } for code, name in list(django_countries.countries)] }) +def sponsorships(request): + """ + Returns all sponsorships + """ + + now = datetime.datetime.now().replace(tzinfo=models.UTC()) + qset = Sponsorship.objects.filter(start_date__lte=now, + end_date__gte=now) + + return JsonResponse({ + "sponsors": dict([(sponsor.org_id, { + "id": sponsor.org_id, + "name": sponsor.label.lower() + }) for sponsor in qset]) + }) @login_required def facilities(request): diff --git a/peeringdb_server/search.py b/peeringdb_server/search.py index df820ea7..00c192d1 100644 --- a/peeringdb_server/search.py +++ b/peeringdb_server/search.py @@ -154,16 +154,28 @@ def search(term): for tag, index in search_index.items(): for id, data in index.items(): if data.name.lower().find(term) > -1: - result[tag].append({"id": id, "name": data.search_result_name}) + result[tag].append({ + "id": id, + "name": data.search_result_name, + "org_id": data.org_id + }) continue if hasattr(data, 'name_long') and data.name_long.lower().find(term) > -1: - result[tag].append({"id": id, "name": data.search_result_name}) + result[tag].append({ + "id": id, + "name": data.search_result_name, + "org_id" : data.org_id + }) continue if hasattr(data, 'aka') and data.aka.lower().find(term) > -1: - result[tag].append({"id": id, "name": data.search_result_name}) + result[tag].append({ + "id": id, + "name": data.search_result_name, + "org_id": data.org_id + }) continue if typed_q: @@ -171,7 +183,8 @@ def search(term): if str(data.id).startswith(typed_q[tag]): result[tag].append({ "id": id, - "name": data.search_result_name + "name": data.search_result_name, + "org_id": data.org_id }) continue @@ -184,7 +197,8 @@ def search(term): if asn and str(data.asn).startswith(asn): result[tag].append({ "id": id, - "name": data.search_result_name + "name": data.search_result_name, + "org_id": data.org_id }) for k, items in result.items(): diff --git a/peeringdb_server/static/peeringdb.js b/peeringdb_server/static/peeringdb.js index c7653744..a4b0bbb5 100644 --- a/peeringdb_server/static/peeringdb.js +++ b/peeringdb_server/static/peeringdb.js @@ -315,12 +315,16 @@ PeeringDB.InlineSearch = { if(typeof data == 'string') data = JSON.parse(data) - PeeringDB.InlineSearch.apply_result(data) - PeeringDB.InlineSearch.busy = false - if(val=PeeringDB.InlineSearch.queuedSearch) { - PeeringDB.InlineSearch.queuedSearch = null; - PeeringDB.InlineSearch.search(val); - } + + + twentyc.data.load("sponsors", {callback:function() { + PeeringDB.InlineSearch.apply_result(data) + PeeringDB.InlineSearch.busy = false + if(val=PeeringDB.InlineSearch.queuedSearch) { + PeeringDB.InlineSearch.queuedSearch = null; + PeeringDB.InlineSearch.search(val); + } + }.bind(this)}); } ) @@ -349,6 +353,15 @@ PeeringDB.InlineSearch = { rowNode = $(document.createElement("div")) rowNode.addClass("result_row") rowNode.append($('').attr("href", "/"+type+"/"+row.id).text(row.name)); + + var sponsor = (twentyc.data.get("sponsors")[row.org_id] || {}).name; + if(sponsor) { + rowNode.append($(''). + attr("href", "/sponsors"). + addClass("sponsor "+sponsor). + text(sponsor+" sponsor")); + } + this.resultNodes[type].lst.append(rowNode) } } @@ -654,6 +667,15 @@ twentyc.editable.target.register( } row = twentyc.editable.templates.copy("advanced-search-"+reftag+"-item") + + if(d.sponsorship) { + $(''). + attr("href", "/sponsors"). + addClass("sponsor "+d.sponsorship). + text(d.sponsorship.toLowerCase()+" sponsor"). + insertAfter(row.find('.name')); + } + row.find("[data-edit-name]").each(function(idx) { var fld = $(this); var value = d[fld.data("edit-name")] @@ -686,6 +708,15 @@ twentyc.editable.target.register( data.ix_count = data.netixlan_set.length; data.fac_count = data.netfac_set.length; data.info_traffic_raw = twentyc.data.get("traffic_speed_by_label")[data.info_traffic] || 0; + data.sponsorship = (twentyc.data.get("sponsors")[data.org_id] || {}).name; + }, + + finalize_data_ix : function(data) { + data.sponsorship = (twentyc.data.get("sponsors")[data.org_id] || {}).name; + }, + + finalize_data_fac : function(data) { + data.sponsorship = (twentyc.data.get("sponsors")[data.org_id] || {}).name; } }, "base" @@ -1318,6 +1349,7 @@ twentyc.data.loaders.assign("locales", "data"); twentyc.data.loaders.assign("countries", "data"); twentyc.data.loaders.assign("countries_b", "data"); twentyc.data.loaders.assign("facilities", "data"); +twentyc.data.loaders.assign("sponsors", "data"); twentyc.data.loaders.assign("enum/regions", "data"); twentyc.data.loaders.assign("enum/org_groups", "data"); twentyc.data.loaders.assign("enum/media", "data"); diff --git a/peeringdb_server/static/site.css b/peeringdb_server/static/site.css index 681ed485..d6f19f85 100644 --- a/peeringdb_server/static/site.css +++ b/peeringdb_server/static/site.css @@ -14,6 +14,7 @@ html, body { body { background-color: #4b6063; + overflow-y: scroll; } input[type="text"]:focus, @@ -1012,7 +1013,7 @@ div.oauth img { div.tab-content > div.active { background-color: #f1f1f1; - padding: 15px; + padding: 15px 0px; margin-left: 1px; } @@ -1156,6 +1157,13 @@ div.sponsor.diamond h3 { border-bottom: 2px solid #1c3f28; } +a.sponsor { + text-transform: capitalize; + display: inline-block; + margin-top: 2px; +} + +a.sponsor, div.view_title div.sponsor::after { border-radius: 5px; font-size: 11px; @@ -1170,6 +1178,11 @@ div.view_title div.sponsor::after { cursor: pointer; } +a.sponsor { + text-decoration: none; +} + +a.sponsor.diamond, div.view_title div.sponsor.diamond::after { background-color: #00aca1; border-color: #00aca1; @@ -1177,18 +1190,23 @@ div.view_title div.sponsor.diamond::after { content: 'Diamond Sponsor'; } +a.sponsor.platinum, div.view_title div.sponsor.platinum::after { background-color: #899a9d; border-color: #899a9d; color: #ffffff; content: 'Platinum Sponsor'; } + +a.sponsor.gold, div.view_title div.sponsor.gold::after { background-color: #e3a631; border-color: #e3a631; color: #ffffff; content: 'Gold Sponsor'; } + +a.sponsor.silver, div.view_title div.sponsor.silver::after { border-color: #626a75; background-color: #626a75; diff --git a/peeringdb_server/static/sponsors-style.css b/peeringdb_server/static/sponsors-style.css index 66831588..7d697366 100644 --- a/peeringdb_server/static/sponsors-style.css +++ b/peeringdb_server/static/sponsors-style.css @@ -5,7 +5,7 @@ article, aside, details, figcaption, figure, footer, header, main, nav, section, audio, canvas, video { display:inline-block } html { font-size:20px } -.sponsorspage { margin:auto ; max-width:1170px ; padding:0 15px } +.sponsorspage { margin:auto ; max-width:1170px ; padding:0px } /* SPONSOR LEVELS */ /* designed for 1201+ */ diff --git a/peeringdb_server/templates/site/about.html b/peeringdb_server/templates/site/about.html index b08b606f..f60882ff 100644 --- a/peeringdb_server/templates/site/about.html +++ b/peeringdb_server/templates/site/about.html @@ -1,7 +1,7 @@ {% load i18n %}
-
+

{% trans "Our Culture" %}

{% blocktrans %}PeeringDB, as the name suggests, was set up to facilitate peering between networks and peering coordinators. In recent years, the vision of PeeringDB has developed to keep up with the speed and diverse manner in which the Internet is growing. The database is no longer just for peering and peering related information. It now includes all types of interconnection data for networks, clouds, services, and enterprise, as well as interconnection facilities that are developing at the edge of the Internet.{% endblocktrans %}

diff --git a/peeringdb_server/templates/site/advanced-search.html b/peeringdb_server/templates/site/advanced-search.html index 77c39259..77e94bd2 100644 --- a/peeringdb_server/templates/site/advanced-search.html +++ b/peeringdb_server/templates/site/advanced-search.html @@ -28,36 +28,45 @@
diff --git a/peeringdb_server/templates/site/aup.html b/peeringdb_server/templates/site/aup.html index 3d500cbd..2e42e532 100644 --- a/peeringdb_server/templates/site/aup.html +++ b/peeringdb_server/templates/site/aup.html @@ -1,6 +1,6 @@
-
+

PeeringDB Acceptable Use Policy

The PeeringDB Acceptable Use Policy explicitly states the parameters that copyright extends to:

diff --git a/peeringdb_server/templates/site/profile-affiliate.html b/peeringdb_server/templates/site/profile-affiliate.html new file mode 100644 index 00000000..528b7f37 --- /dev/null +++ b/peeringdb_server/templates/site/profile-affiliate.html @@ -0,0 +1,66 @@ +{% load i18n %} +
+ + diff --git a/peeringdb_server/templates/site/profile-change-email.html b/peeringdb_server/templates/site/profile-change-email.html new file mode 100644 index 00000000..44c68131 --- /dev/null +++ b/peeringdb_server/templates/site/profile-change-email.html @@ -0,0 +1,32 @@ +{% load i18n %} +
+ +

{% trans "Change email address" %}

+ +
+ {% blocktrans trimmed %} + For speedy validation, it is required that you use a work e-mail address. If you + plan to register your ASN with PeeringDB, it is recommended that you use an email-address + that exists in the ASN's public contact details. + {% endblocktrans %} +
+ + + + + + {% trans "Change Email" %} +
+ diff --git a/peeringdb_server/templates/site/profile-change-password.html b/peeringdb_server/templates/site/profile-change-password.html new file mode 100644 index 00000000..9b3e8578 --- /dev/null +++ b/peeringdb_server/templates/site/profile-change-password.html @@ -0,0 +1,33 @@ +{% load i18n %} +
+ +

{% trans "Change password" %}

+ + + + + + + + + + {% trans "Change Password" %} +
+ diff --git a/peeringdb_server/templates/site/profile-confirm-email.html b/peeringdb_server/templates/site/profile-confirm-email.html new file mode 100644 index 00000000..f4da3028 --- /dev/null +++ b/peeringdb_server/templates/site/profile-confirm-email.html @@ -0,0 +1,31 @@ +{% load i18n %} +
+ {% if request.user.email_confirmed %} +

+ {% trans "You have confirmed your email address!" %} +

+ {% endif %} + {% if not request.user.email %} +

{% trans "Attention!" %}

+

+ {% trans "Please specify an email address for your account, we won't be able to proceed with verification until you do." %} +

+ {% elif not request.user.email_confirmed %} +

{% trans "Email Confirmation" %}

+

+ {% trans "Before getting access to any other features, you need to confirm your email address." %} +

{% trans "We have sent you a message containing the confirmation link." %}
+
+
+ {% csrf_token %} + +
+
+

+ {% elif not request.user.is_verified %} +

+ {% trans "You won't have full access until we or the organization you are affiliated with have reviewed your account. Thank you for your patience." %} +

+ {% endif %} +
+ diff --git a/peeringdb_server/templates/site/profile-pick-language.html b/peeringdb_server/templates/site/profile-pick-language.html new file mode 100644 index 00000000..b0f33737 --- /dev/null +++ b/peeringdb_server/templates/site/profile-pick-language.html @@ -0,0 +1,22 @@ +{% load i18n %} +
+ +

{% trans "Select language" %}

+ + + {% get_current_language as LANGUAGE_CODE %} + + +
+ {% trans "Set language preference" %} +
diff --git a/peeringdb_server/templates/site/search_result.html b/peeringdb_server/templates/site/search_result.html index 9aaa3b60..93160e0f 100644 --- a/peeringdb_server/templates/site/search_result.html +++ b/peeringdb_server/templates/site/search_result.html @@ -11,14 +11,24 @@
{% trans "Exchanges" %} ({{ count_ixp }})
{% for row in search_ixp %} - +
+ {{row.name}} + {% if row.sponsorship %} + + {% endif %} +
{% endfor %}
{% trans "Networks" %} ({{ count_net }})
{% for row in search_net%} - +
+ {{row.name}} + {% if row.sponsorship %} + + {% endif %} +
{% endfor %} @@ -26,7 +36,12 @@
{% trans "Facilities" %} ({{ count_fac }})
{% for row in search_fac %} - +
+ {{row.name}} + {% if row.sponsorship %} + + {% endif %} +
{% endfor %} @@ -60,4 +75,5 @@
+ {% include 'site/footer.html' %} diff --git a/peeringdb_server/templates/site/verify.html b/peeringdb_server/templates/site/verify.html index 10cf9e05..6274fb3e 100644 --- a/peeringdb_server/templates/site/verify.html +++ b/peeringdb_server/templates/site/verify.html @@ -5,221 +5,35 @@
-
-
- -
- -

{% trans "Select language" %}

- - - {% get_current_language as LANGUAGE_CODE %} - - -
- {% trans "Set language preference" %} -
-
- -
-
-
+
+
+ + {% include "site/profile-confirm-email.html" %} {% if request.user.email_confirmed %} -

- {% trans "You have confirmed your email address!" %} -

- {% endif %} - {% if not request.user.email %} -

{% trans "Attention!" %}

-

- {% trans "Please specify an email address for your account, we won't be able to proceed with verification until you do." %} -

- {% elif not request.user.email_confirmed %} -

{% trans "Email Confirmation" %}

-

- {% trans "Before getting access to any other features, you need to confirm your email address." %} -

{% trans "We have sent you a message containing the confirmation link." %}
-
-
- {% csrf_token %} - -
-
-

- {% elif not request.user.is_verified %} -

- {% trans "You won't have full access until we or the organization you are affiliated with have reviewed your account. Thank you for your patience." %} -

- {% endif %} -
-
-
+ + {% include "site/profile-affiliate.html" %} - {% if request.user.email_confirmed %} -
-
- -
-

{% trans "Affiliate with organization" %}

- - {% if affiliation_request %} -
- {% if affiliation_request.status == "pending" %} - {% blocktrans with ar_name=affiliation_request.name trimmed %} Your affiliation with {{ ar_name }} is pending approval. {% endblocktrans %} - {% elif affiliation_request.status == "denied" %} - {% blocktrans with ar_name=affiliation_request.name trimmed %} Your affiliation with {{ ar_name }} was denied {% endblocktrans %} - {% elif affiliation_request.status == "approved" %} - {% blocktrans with ar_name=affiliation_request.name trimmed %} Your affiliation with {{ ar_name }} was approved {% endblocktrans %} - {% endif %} -
- {% endif %} - - -
-

- {% trans "To affiliate with an existing organization, please enter the ASN or organization name below." %} -

- -

- {% trans "To register a new network organization, please enter the ASN and organization name below." %} -

- -

- {% trans "To register a new facility or exchange organization, please enter the organization name below (ASN is optional)." %} -

-
- - - - - - {% trans "Affiliate" %} - -
- {% trans "In case the RiR entry cannot be retrieved for your ASN, please contact" %} - support@peeringdb.com {% trans "for assistance" %}. -
- -
-

{% trans "Existing affiliations" %}

- - {% for org in affiliations %} -
{% trans "Your affiliation with" %} {{ org.name }} {% trans "has been approved" %}.
- {% endfor %} -
- - -
- -
-
- - {% endif %} +
- {% if not request.user.has_oauth %} -
-
- -
+ + {% include "site/profile-pick-language.html" %} -

{% trans "Change email address" %}

+ {% if not request.user.has_oauth %} + + {% include "site/profile-change-email.html" %} + + {% include "site/profile-change-password.html" %} + {% endif %} -
- {% blocktrans trimmed %} - For speedy validation, it is required that you use a work e-mail address. If you - plan to register your ASN with PeeringDB, it is recommended that you use an email-address - that exists in the ASN's public contact details. - {% endblocktrans %} -
- - - - - - {% trans "Change Email" %}
-
-
-
-
- -
- -

{% trans "Change password" %}

- - - - - - - - - - {% trans "Change Password" %} -
-
- {% endif %}
diff --git a/peeringdb_server/templates/site/view_organization_side.html b/peeringdb_server/templates/site/view_organization_side.html index 00ad8925..c5d331d9 100644 --- a/peeringdb_server/templates/site/view_organization_side.html +++ b/peeringdb_server/templates/site/view_organization_side.html @@ -4,11 +4,11 @@ {% if data.facilities or permissions.can_create_fac %} -
@@ -30,7 +30,7 @@
-
@@ -55,10 +55,10 @@ {{ n.status }}
{% endif %} - +
-
{{ n.country|long_country_name }}
+
{{ n.country.name }}
{{ n.city }}
@@ -72,15 +72,15 @@ {% if data.networks or permissions.can_create_net %} -
- +
Networks
@@ -98,7 +98,7 @@
-
@@ -123,7 +123,7 @@ {{ n.status }}
{% endif %} - +
{{ n.asn }}
@@ -139,15 +139,15 @@ {% if data.exchanges or permissions.can_create_ix %} -
- +
{% trans "Exchanges" %}
@@ -166,7 +166,7 @@
-
@@ -193,7 +193,7 @@ {% endif %}
-
{{ n.country|long_country_name }}
+
{{ n.country.name }}
{{ n.city }}
diff --git a/peeringdb_server/urls.py b/peeringdb_server/urls.py index f1fc99c8..c48fcb18 100644 --- a/peeringdb_server/urls.py +++ b/peeringdb_server/urls.py @@ -113,6 +113,7 @@ urlpatterns = [ url(r'^org_admin/manage_user/delete$', peeringdb_server.org_admin_views.manage_user_delete), url(r'^data/countries$', peeringdb_server.data_views.countries), + url(r'^data/sponsors$', peeringdb_server.data_views.sponsorships), url(r'^data/countries_b$', peeringdb_server.data_views.countries_w_blank), url(r'^data/facilities$', peeringdb_server.data_views.facilities), url(r'^data/enum/(?P[\w_]+)$', peeringdb_server.data_views.enum), diff --git a/peeringdb_server/views.py b/peeringdb_server/views.py index 53da2f35..78c069b7 100644 --- a/peeringdb_server/views.py +++ b/peeringdb_server/views.py @@ -133,12 +133,12 @@ def get_client_ip(request): def view_http_error_404(request): template = loader.get_template('site/error_404.html') - return HttpResponseNotFound(template.render({}, request)) + return HttpResponseNotFound(template.render(make_env(), request)) def view_http_error_403(request): template = loader.get_template('site/error_403.html') - return HttpResponseForbidden(template.render({}, request)) + return HttpResponseForbidden(template.render(make_env(), request)) def view_http_error_csrf(request, reason): @@ -1558,6 +1558,17 @@ def request_search(request): result = search(q) + now = datetime.datetime.now().replace(tzinfo=UTC()) + + sponsors = dict([(s.org_id, s.label) + for s in + Sponsorship.objects.filter(start_date__lte=now, + end_date__gte=now)]) + + for tag, rows in result.items(): + for item in rows: + item["sponsorship"] = sponsors.get(item["org_id"]) + template = loader.get_template('site/search_result.html') env = make_env( **{ diff --git a/tests/test_search.py b/tests/test_search.py index c5972e4b..5685cd0c 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -2,13 +2,16 @@ Unit-tests for quick search functionality - note that advanced search is not tested here as that is using the PDB API entirely. """ +import re +import datetime import pytest -from django.test import TestCase +from django.test import TestCase, RequestFactory import peeringdb_server.search as search import peeringdb_server.models as models +import peeringdb_server.views as views class SearchTests(TestCase): @@ -24,6 +27,8 @@ class SearchTests(TestCase): search.SEARCH_CACHE["search_index"] = {} cls.instances = {} + cls.instances_sponsored = {} + # create an instance of each searchable model, so we have something # to search for cls.org = models.Organization.objects.create(name="Test org") @@ -36,6 +41,26 @@ class SearchTests(TestCase): status="ok", org=cls.org, name="Test %s" % model.handleref.tag, **kwargs) + # we also need to test that sponsor ship status comes through + # accordingly + cls.org_w_sponsorship = models.Organization.objects.create(name="Sponsor org", status="ok") + cls.sponsorship = models.Sponsorship.objects.create( + org=cls.org_w_sponsorship, + start_date=datetime.datetime.now() - datetime.timedelta(days=1), + end_date=datetime.datetime.now() + datetime.timedelta(days=1), + level=1); + + for model in search.searchable_models: + if model.handleref.tag == "net": + kwargs = {"asn": 2} + else: + kwargs = {} + cls.instances_sponsored[model.handleref.tag] = model.objects.create( + status="ok", org=cls.org_w_sponsorship, + name="Sponsor %s" % model.handleref.tag, + **kwargs) + + def test_search(self): """ search for entities containing 'Test' - this should return all @@ -47,14 +72,32 @@ class SearchTests(TestCase): assert k in rv assert len(rv[k]) == 1 assert rv[k][0]["name"] == inst.search_result_name + assert rv[k][0]["org_id"] == inst.org_id rv = search.search("as1") assert len(rv["net"]) == 1 assert rv["net"][0]["name"] == self.instances["net"].search_result_name + assert rv["net"][0]["org_id"] == self.instances["net"].org_id rv = search.search("asn1") assert len(rv["net"]) == 1 assert rv["net"][0]["name"] == self.instances["net"].search_result_name + assert rv["net"][0]["org_id"] == self.instances["net"].org_id + + def test_sponsor_badges(self): + """ + Test that the sponsor badges show up in search result + """ + + factory = RequestFactory() + request = factory.get("/search",{"q":"Sponsor"}) + response = views.request_search(request) + m = re.findall(re.escape( + '