mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -315,12 +315,16 @@ PeeringDB.InlineSearch = {
|
||||
|
||||
if(typeof data == 'string')
|
||||
data = JSON.parse(data)
|
||||
|
||||
|
||||
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($('<a>').attr("href", "/"+type+"/"+row.id).text(row.name));
|
||||
|
||||
var sponsor = (twentyc.data.get("sponsors")[row.org_id] || {}).name;
|
||||
if(sponsor) {
|
||||
rowNode.append($('<a>').
|
||||
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) {
|
||||
$('<a>').
|
||||
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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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+ */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% load i18n %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-3"></div>
|
||||
<div class="panel center col-xs-12 col-md-6">
|
||||
<div class="panel center col-xs-12">
|
||||
<h3>{% trans "Our Culture" %}</h3>
|
||||
|
||||
<p>{% 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 %}</p>
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
<script language="javascript" type="text/javascript">
|
||||
twentyc.editable.target.get("advanced_search").prototype.limit = {{ row_limit }};
|
||||
$(window).bind("load", function() {
|
||||
twentyc.data.load("enum/traffic");
|
||||
|
||||
var run_search = function() {
|
||||
|
||||
var reftag = $.urlParam("reftag")
|
||||
if(reftag == "net" || reftag == "ix" || reftag == "fac") {
|
||||
var searchForm = $('[data-edit-target="advanced_search:'+reftag+'"]')
|
||||
@@ -58,6 +60,13 @@
|
||||
target.search();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
twentyc.data.load("enum/traffic", {callback:function() {
|
||||
twentyc.data.load("sponsors", {callback:run_search});
|
||||
}});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-3"></div>
|
||||
<div class="panel center col-xs-12 col-md-6">
|
||||
<div class="panel center col-xs-12">
|
||||
<h3>PeeringDB Acceptable Use Policy</h3>
|
||||
|
||||
<p>The PeeringDB Acceptable Use Policy explicitly states the parameters that copyright extends to:</p>
|
||||
|
||||
66
peeringdb_server/templates/site/profile-affiliate.html
Normal file
66
peeringdb_server/templates/site/profile-affiliate.html
Normal file
@@ -0,0 +1,66 @@
|
||||
{% load i18n %}
|
||||
<div class="editable always panel"
|
||||
data-edit-target="/affiliate-to-org"
|
||||
id="form-affiliate-account">
|
||||
<h3>{% trans "Affiliate with organization" %}</h3>
|
||||
|
||||
{% if affiliation_request %}
|
||||
<div class="editable popin info">
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="editable popin help marg-top-15">
|
||||
<p>
|
||||
{% trans "To affiliate with an existing organization, please enter the ASN or organization name below." %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% trans "To register a new network organization, please enter the ASN and organization name below." %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% trans "To register a new facility or exchange organization, please enter the organization name below (ASN is optional)." %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<input type="text"
|
||||
class="editable string form-control"
|
||||
placeholder="{% trans "ASN" %}"
|
||||
data-edit-name="asn"
|
||||
data-edit-type="string" />
|
||||
|
||||
<input type="text"
|
||||
class="editable string form-control"
|
||||
placeholder="{% trans "Organization" %}"
|
||||
data-edit-name="org"
|
||||
data-edit-autocomplete="org"
|
||||
data-edit-autocomplete-allow-nonexistent="yes"
|
||||
data-edit-type="autocomplete" />
|
||||
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Affiliate" %}</a>
|
||||
|
||||
<div class="editable popin help marg-top-15">
|
||||
{% trans "In case the RiR entry cannot be retrieved for your ASN, please contact" %}
|
||||
<a href="mailto:support@peeringdb.com">support@peeringdb.com</a> {% trans "for assistance" %}.
|
||||
</div>
|
||||
|
||||
<div class="marg-top">
|
||||
<h3 class="marg-top">{% trans "Existing affiliations" %}</h3>
|
||||
|
||||
{% for org in affiliations %}
|
||||
<div class="editable popin help">{% trans "Your affiliation with" %} <a href="/org/{{ org.id }}">{{ org.name }}</a> {% trans "has been approved" %}.</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
32
peeringdb_server/templates/site/profile-change-email.html
Normal file
32
peeringdb_server/templates/site/profile-change-email.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% load i18n %}
|
||||
<div class="editable always panel"
|
||||
data-edit-target="/verify"
|
||||
id="form-update-account">
|
||||
|
||||
<h3>{% trans "Change email address" %}</h3>
|
||||
|
||||
<div class="editable popin help marg-top-15">
|
||||
{% 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 %}
|
||||
</div>
|
||||
|
||||
<input type="text"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Email" %}"
|
||||
data-edit-name="email"
|
||||
data-edit-type="email"
|
||||
data-edit-required="yes" />
|
||||
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Password" %}"
|
||||
data-edit-name="password"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Change Email" %}</a>
|
||||
</div>
|
||||
|
||||
33
peeringdb_server/templates/site/profile-change-password.html
Normal file
33
peeringdb_server/templates/site/profile-change-password.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{% load i18n %}
|
||||
<div class="editable always panel"
|
||||
data-edit-target="/change-password"
|
||||
id="form-change-password">
|
||||
|
||||
<h3>{% trans "Change password" %}</h3>
|
||||
<div class="editable popin info" id="password-change-success" style="display:none;">{% trans "Password changed" %}!</div>
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Current Password" %}"
|
||||
data-edit-name="password_c"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Password" %}"
|
||||
data-edit-name="password"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Password Verification" %}"
|
||||
data-edit-name="password_v"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Change Password" %}</a>
|
||||
</div>
|
||||
|
||||
31
peeringdb_server/templates/site/profile-confirm-email.html
Normal file
31
peeringdb_server/templates/site/profile-confirm-email.html
Normal file
@@ -0,0 +1,31 @@
|
||||
{% load i18n %}
|
||||
<div class="editable always panel">
|
||||
{% if request.user.email_confirmed %}
|
||||
<p>
|
||||
<b>{% trans "You have confirmed your email address!" %}</b>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if not request.user.email %}
|
||||
<h3>{% trans "Attention!" %}</h3>
|
||||
<p>
|
||||
{% trans "Please specify an email address for your account, we won't be able to proceed with verification until you do." %}
|
||||
</p>
|
||||
{% elif not request.user.email_confirmed %}
|
||||
<h3>{% trans "Email Confirmation" %}</h3>
|
||||
<p>
|
||||
<span class="attention">{% trans "Before getting access to any other features, you need to confirm your email address." %}</span>
|
||||
<div class="marg-top">{% trans "We have sent you a message containing the confirmation link." %} </div>
|
||||
<div class="center marg-top">
|
||||
<form action="/resend_email_confirmation" method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="submit" value="Resend Confirmation Email" class="btn btn-default" />
|
||||
</form>
|
||||
</div>
|
||||
</p>
|
||||
{% elif not request.user.is_verified %}
|
||||
<p>
|
||||
{% 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." %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
22
peeringdb_server/templates/site/profile-pick-language.html
Normal file
22
peeringdb_server/templates/site/profile-pick-language.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{% load i18n %}
|
||||
<div class="editable always auto-toggled panel"
|
||||
data-edit-target="/set-user-locale"
|
||||
data-edit-always-submit="yes"
|
||||
data-edit-enter-action="submit"
|
||||
id="form-language-preference">
|
||||
|
||||
<h3>{% trans "Select language" %}</h3>
|
||||
<div class="editable popin info" id="language-change-success" style="display:none;">{% trans "Language preference saved" %}!</div>
|
||||
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-12"
|
||||
data-edit-type="select"
|
||||
data-edit-data="locales"
|
||||
data-edit-required="no"
|
||||
data-edit-name="locale"
|
||||
data-edit-value="{{ LANGUAGE_CODE }}"
|
||||
data-edit-reset-value=""></div>
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Set language preference" %}</a>
|
||||
</div>
|
||||
@@ -11,14 +11,24 @@
|
||||
<div class="col-md-4 col-sm-12 col-xs-12">
|
||||
<div class="view_title">{% trans "Exchanges" %} ({{ count_ixp }})</div>
|
||||
{% for row in search_ixp %}
|
||||
<div class="result_row"><a href="/{{'InternetExchange'|ref_tag}}/{{row.id}}">{{row.name}}</a></div>
|
||||
<div class="result_row">
|
||||
<a href="/{{'InternetExchange'|ref_tag}}/{{row.id}}">{{row.name}}</a>
|
||||
{% if row.sponsorship %}
|
||||
<a href="/sponsors" class="sponsor {{ row.sponsorship|lower }}">{{ row.sponsorship }} sponsor</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-12 col-xs-12">
|
||||
<div class="view_title">{% trans "Networks" %} ({{ count_net }})</div>
|
||||
{% for row in search_net%}
|
||||
<div class="result_row"><a href="/{{'Network'|ref_tag}}/{{row.id}}">{{row.name}}</a></div>
|
||||
<div class="result_row">
|
||||
<a href="/{{'Network'|ref_tag}}/{{row.id}}">{{row.name}}</a>
|
||||
{% if row.sponsorship %}
|
||||
<a href="/sponsors" class="sponsor {{ row.sponsorship|lower }}">{{ row.sponsorship }} sponsor</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -26,7 +36,12 @@
|
||||
<div class="col-md-4 col-sm-12 col-xs-12">
|
||||
<div class="view_title">{% trans "Facilities" %} ({{ count_fac }})</div>
|
||||
{% for row in search_fac %}
|
||||
<div class="result_row"><a href="/{{'Facility'|ref_tag}}/{{row.id}}">{{row.name}}</a></div>
|
||||
<div class="result_row">
|
||||
<a href="/{{'Facility'|ref_tag}}/{{row.id}}">{{row.name}}</a>
|
||||
{% if row.sponsorship %}
|
||||
<a href="/sponsors" class="sponsor {{ row.sponsorship|lower }}">{{ row.sponsorship }} sponsor</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -60,4 +75,5 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% include 'site/footer.html' %}
|
||||
|
||||
@@ -5,221 +5,35 @@
|
||||
<div class="view_info">
|
||||
<div class="container">
|
||||
|
||||
<div class="row marg-top-15">
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
|
||||
<div class="editable always auto-toggled col-md-4 col-sm-6 col-xs-12 panel"
|
||||
data-edit-target="/set-user-locale"
|
||||
data-edit-always-submit="yes"
|
||||
data-edit-enter-action="submit"
|
||||
id="form-language-preference">
|
||||
|
||||
<h3>{% trans "Select language" %}</h3>
|
||||
<div class="editable popin info" id="language-change-success" style="display:none;">{% trans "Language preference saved" %}!</div>
|
||||
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-12"
|
||||
data-edit-type="select"
|
||||
data-edit-data="locales"
|
||||
data-edit-required="no"
|
||||
data-edit-name="locale"
|
||||
data-edit-value="{{ LANGUAGE_CODE }}"
|
||||
data-edit-reset-value=""></div>
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Set language preference" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row marg-top-15">
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
<div class="editable always col-md-4 col-sm-6 col-xs-12 panel">
|
||||
<div class="row marg-top-15 marg-bot-15">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<!-- CONFIRM EMAIL -->
|
||||
{% include "site/profile-confirm-email.html" %}
|
||||
{% if request.user.email_confirmed %}
|
||||
<p>
|
||||
<b>{% trans "You have confirmed your email address!" %}</b>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if not request.user.email %}
|
||||
<h3>{% trans "Attention!" %}</h3>
|
||||
<p>
|
||||
{% trans "Please specify an email address for your account, we won't be able to proceed with verification until you do." %}
|
||||
</p>
|
||||
{% elif not request.user.email_confirmed %}
|
||||
<h3>{% trans "Email Confirmation" %}</h3>
|
||||
<p>
|
||||
<span class="attention">{% trans "Before getting access to any other features, you need to confirm your email address." %}</span>
|
||||
<div class="marg-top">{% trans "We have sent you a message containing the confirmation link." %} </div>
|
||||
<div class="center marg-top">
|
||||
<form action="/resend_email_confirmation" method="POST">
|
||||
{% csrf_token %}
|
||||
<input type="submit" value="Resend Confirmation Email" class="btn btn-default" />
|
||||
</form>
|
||||
</div>
|
||||
</p>
|
||||
{% elif not request.user.is_verified %}
|
||||
<p>
|
||||
{% 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." %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
</div>
|
||||
<!-- AFFILIATE -->
|
||||
{% include "site/profile-affiliate.html" %}
|
||||
|
||||
{% if request.user.email_confirmed %}
|
||||
<div class="row marg-top-15">
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
|
||||
<div class="editable always col-md-4 col-sm-6 col-xs-12 panel"
|
||||
data-edit-target="/affiliate-to-org"
|
||||
id="form-affiliate-account">
|
||||
<h3>{% trans "Affiliate with organization" %}</h3>
|
||||
|
||||
{% if affiliation_request %}
|
||||
<div class="editable popin info">
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="editable popin help marg-top-15">
|
||||
<p>
|
||||
{% trans "To affiliate with an existing organization, please enter the ASN or organization name below." %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% trans "To register a new network organization, please enter the ASN and organization name below." %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% trans "To register a new facility or exchange organization, please enter the organization name below (ASN is optional)." %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<input type="text"
|
||||
class="editable string form-control"
|
||||
placeholder="{% trans "ASN" %}"
|
||||
data-edit-name="asn"
|
||||
data-edit-type="string" />
|
||||
|
||||
<input type="text"
|
||||
class="editable string form-control"
|
||||
placeholder="{% trans "Organization" %}"
|
||||
data-edit-name="org"
|
||||
data-edit-autocomplete="org"
|
||||
data-edit-autocomplete-allow-nonexistent="yes"
|
||||
data-edit-type="autocomplete" />
|
||||
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Affiliate" %}</a>
|
||||
|
||||
<div class="editable popin help marg-top-15">
|
||||
{% trans "In case the RiR entry cannot be retrieved for your ASN, please contact" %}
|
||||
<a href="mailto:support@peeringdb.com">support@peeringdb.com</a> {% trans "for assistance" %}.
|
||||
</div>
|
||||
|
||||
<div class="marg-top">
|
||||
<h3 class="marg-top">{% trans "Existing affiliations" %}</h3>
|
||||
|
||||
{% for org in affiliations %}
|
||||
<div class="editable popin help">{% trans "Your affiliation with" %} <a href="/org/{{ org.id }}">{{ org.name }}</a> {% trans "has been approved" %}.</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
<div class="col-md-4 col-sm-3 col-xs-12 panel">
|
||||
<!-- OAUTH APPS -->
|
||||
<div class="marg-top marg-bot">
|
||||
<a href="/oauth2/applications">{% trans "Manage OAuth Applications" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
|
||||
<!-- PICK LANGUAGE -->
|
||||
{% include "site/profile-pick-language.html" %}
|
||||
|
||||
{% if not request.user.has_oauth %}
|
||||
<div class="row marg-top-15">
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
|
||||
<div class="editable always col-md-4 col-sm-6 col-xs-12 panel"
|
||||
data-edit-target="/verify"
|
||||
id="form-update-account">
|
||||
|
||||
<h3>{% trans "Change email address" %}</h3>
|
||||
|
||||
<div class="editable popin help marg-top-15">
|
||||
{% 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 %}
|
||||
</div>
|
||||
|
||||
<input type="text"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Email" %}"
|
||||
data-edit-name="email"
|
||||
data-edit-type="email"
|
||||
data-edit-required="yes" />
|
||||
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Password" %}"
|
||||
data-edit-name="password"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Change Email" %}</a>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
</div>
|
||||
<div class="row marg-top-15">
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
|
||||
<div class="editable always col-md-4 col-sm-6 col-xs-12 panel"
|
||||
data-edit-target="/change-password"
|
||||
id="form-change-password">
|
||||
|
||||
<h3>{% trans "Change password" %}</h3>
|
||||
<div class="editable popin info" id="password-change-success" style="display:none;">{% trans "Password changed" %}!</div>
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Current Password" %}"
|
||||
data-edit-name="password_c"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Password" %}"
|
||||
data-edit-name="password"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
|
||||
<input type="password"
|
||||
class="editable string form-control marg-bot-15"
|
||||
placeholder="{% trans "Password Verification" %}"
|
||||
data-edit-name="password_v"
|
||||
data-edit-type="password"
|
||||
data-edit-required="yes" />
|
||||
|
||||
<a class="btn btn-default" data-edit-action="submit">{% trans "Change Password" %}</a>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-3 col-xs-12"></div>
|
||||
</div>
|
||||
|
||||
<!-- CHANGE EMAIL -->
|
||||
{% include "site/profile-change-email.html" %}
|
||||
<!-- CHANGE PASSWORD -->
|
||||
{% include "site/profile-change-password.html" %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<div class="country" data-sort-value="{{ n.country|long_country_name }}" data-filter-value="{{ n.country|long_country_name }}">{{ n.country|long_country_name }}</div>
|
||||
<div class="country" data-sort-value="{{ n.country.name }}" data-filter-value="{{ n.country.name }}">{{ n.country.name }}</div>
|
||||
<div class="city" data-sort-value="{{ n.city }}" data-filter-value="{{ n.city }}">{{ n.city }}</div>
|
||||
</div>
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-xs-6 col-sm-6 col-md-6">
|
||||
<div class="country" data-sort-value="{{ n.country|long_country_name }}" data-filter-value="{{ n.country|long_country_name }}">{{ n.country|long_country_name }}</div>
|
||||
<div class="country" data-sort-value="{{ n.country.name }}" data-filter-value="{{ n.country.name }}">{{ n.country.name }}</div>
|
||||
<div class="city" data-sort-value="{{ n.city }}" data-filter-value="{{ n.city }}">{{ n.city }}</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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<name>[\w_]+)$', peeringdb_server.data_views.enum),
|
||||
|
||||
@@ -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(
|
||||
**{
|
||||
|
||||
@@ -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(
|
||||
'<a href="/sponsors" class="sponsor silver">'),
|
||||
response.content)
|
||||
|
||||
assert len(m) == 3
|
||||
|
||||
|
||||
def test_search_case(self):
|
||||
"""
|
||||
@@ -67,6 +110,7 @@ class SearchTests(TestCase):
|
||||
assert len(rv[k]) == 1
|
||||
assert rv[k][0]["name"] == inst.search_result_name
|
||||
|
||||
|
||||
def test_index_updates(self):
|
||||
"""
|
||||
test that indexes get updated correctly when objects are created
|
||||
|
||||
85
tests/test_sponsors.py
Normal file
85
tests/test_sponsors.py
Normal file
@@ -0,0 +1,85 @@
|
||||
import pytest
|
||||
import json
|
||||
import uuid
|
||||
import re
|
||||
|
||||
from django.test import Client, TestCase, RequestFactory
|
||||
from django.contrib.auth.models import Group, AnonymousUser
|
||||
from django.contrib.auth import get_user
|
||||
import django_namespace_perms as nsp
|
||||
|
||||
import peeringdb_server.views as views
|
||||
import peeringdb_server.models as models
|
||||
|
||||
|
||||
class ViewTestCase(TestCase):
|
||||
|
||||
entities = ["ix", "net", "fac"]
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
# create user and guest group
|
||||
|
||||
guest_group = Group.objects.create(name="guest")
|
||||
user_group = Group.objects.create(name="user")
|
||||
|
||||
cls.guest_user = models.User.objects.create_user(
|
||||
"guest", "guest@localhost", "guest")
|
||||
cls.guest_user.set_password("guest")
|
||||
guest_group.user_set.add(cls.guest_user)
|
||||
|
||||
# create organizations
|
||||
cls.organizations = dict((k,
|
||||
models.Organization.objects.create(
|
||||
name="Sponsor Org %s" % k, status="ok"))
|
||||
for k in ["a", "b", "c", "d"])
|
||||
|
||||
# create sponsorships
|
||||
cls.sponsorships = {
|
||||
"a": models.Sponsorship.objects.create(
|
||||
org=cls.organizations.get("a"), logo="fake.png",
|
||||
url="org-a.com", level=1),
|
||||
"b": models.Sponsorship.objects.create(
|
||||
org=cls.organizations.get("b"), logo="fake.png", level=1),
|
||||
"c": models.Sponsorship.objects.create(
|
||||
org=cls.organizations.get("c"), logo="fake.png", level=2),
|
||||
"d": models.Sponsorship.objects.create(
|
||||
org=cls.organizations.get("d"), level=1)
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
self.factory = RequestFactory()
|
||||
|
||||
def test_data_view(self):
|
||||
c = Client()
|
||||
resp = c.get("/data/sponsors", follow=True)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
expected = {u'sponsors': {u'1': {u'id': 1, u'name': u'silver'}, u'3': {u'id': 3, u'name': u'gold'}, u'2': {u'id': 2, u'name': u'silver'}, u'4': {u'id': 4, u'name': u'silver'}}}
|
||||
self.assertEqual(resp.json(), expected)
|
||||
|
||||
def test_view(self):
|
||||
c = Client()
|
||||
resp = c.get("/sponsors", follow=True)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
#make sure org a,b and c exist in the sponsors page
|
||||
self.assertGreater(resp.content.find(self.organizations["a"].name), -1)
|
||||
self.assertGreater(resp.content.find(self.organizations["b"].name), -1)
|
||||
self.assertGreater(resp.content.find(self.organizations["c"].name), -1)
|
||||
|
||||
#make sure org d does not exist in the sponsors page
|
||||
self.assertEqual(resp.content.find(self.organizations["d"].name), -1)
|
||||
|
||||
#makre sure order is randomized with each view
|
||||
i = 0
|
||||
rgx = re.compile("fake.png\" alt=\"([^\"]+)\"")
|
||||
a = re.findall(rgx, resp.content)
|
||||
while i < 100:
|
||||
resp = c.get("/sponsors", follow=True)
|
||||
b = re.findall(rgx, resp.content)
|
||||
self.assertEqual(len(a), len(b))
|
||||
if b != a:
|
||||
break
|
||||
i += 1
|
||||
self.assertLess(i, 99)
|
||||
Reference in New Issue
Block a user