Skip to content

Commit

Permalink
fix problems with hide-from-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
leifj committed Mar 19, 2016
1 parent 7bef8af commit a5bed7a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
11 changes: 8 additions & 3 deletions src/pyff/mdrepo.py
Expand Up @@ -6,6 +6,7 @@
import traceback

from pyff.stats import set_metadata_info, get_metadata_info
from pyff.store import entity_attribute_dict

try:
from cStringIO import StringIO
Expand All @@ -25,7 +26,7 @@
from lxml.etree import DocumentInvalid
import xmlsec
import ipaddr

from .constants import ATTRS
from . import merge_strategies
from .logs import log
from .utils import schema, filter_lang, root, duration2timedelta, \
Expand Down Expand Up @@ -204,9 +205,13 @@ def discojson(self, e, langs=None):
auth='saml',
entityID=entity_id)

if self.is_idp(e):
eattr = entity_attribute_dict(e)
if 'idp' in eattr[ATTRS['role']]:
d['type'] = 'idp'
elif self.is_sp(e):
d['hidden'] = 'true'
if 'http://pyff.io/category/discoverable' in eattr[ATTRS['entity-category']]:
d['hidden'] = 'false'
elif 'sp' in eattr[ATTRS['role']]:
d['type'] = 'sp'

icon_info = self.icon(e)
Expand Down
12 changes: 7 additions & 5 deletions src/pyff/site/static/js/pyff.js
Expand Up @@ -304,9 +304,11 @@ $(document).ready(function() {
var i = lst.length;
while (i--) {
with_entity_id(lst[i], function (elt) { /* success */
elt.sticky = false;
div.prepend(idp_template.render(elt));
seen[elt.entityID] = true
if (! elt.hidden) {
elt.sticky = false;
div.prepend(idp_template.render(elt));
seen[elt.entityID] = true
}
}, function (id) { /* fail */
lst.splice(i, 1);
$.jStorage.set('pyff.discovery.idps',lst);
Expand Down Expand Up @@ -348,8 +350,8 @@ $(document).ready(function() {
if (entity.icon) {
$(this).attr('src',entity.icon).attr('width',entity.icon_width).attr('height',entity.icon_height).addClass("img-responsive img-thumbnail")
} else {
console.log(this);
console.log($(this).closest('.hideout'))
// console.log(this);
// console.log($(this).closest('.hideout'))
$(this).hide();
$(this).closest(".hideout").hide();
}
Expand Down
5 changes: 2 additions & 3 deletions src/pyff/store.py
Expand Up @@ -39,8 +39,7 @@ def _domains(entity):

def with_entity_attributes(entity, cb):
for ea in entity.iter("{%s}EntityAttributes" % NS['mdattr']):
a = ea.find(".//{%s}Attribute" % NS['saml'])
if a is not None:
for a in ea.iter("{%s}Attribute" % NS['saml']):
an = a.get('Name', None)
if a is not None:
values = [v.text.strip() for v in a.iter("{%s}AttributeValue" % NS['saml'])]
Expand Down Expand Up @@ -241,7 +240,7 @@ def _lookup(self, key):
return self.entities.values()
if '+' in key:
key = key.strip('+')
# log.debug("lookup intersection of '%s'" % ' and '.join(key.split('+')))
#log.debug("lookup intersection of '%s'" % ' and '.join(key.split('+')))
hits = None
for f in key.split("+"):
f = f.strip()
Expand Down
2 changes: 1 addition & 1 deletion src/pyff/templates/ds.html
Expand Up @@ -83,7 +83,7 @@ <h3><span class="sp sp-name"></span></h3>
{% block content %}
<div id="content" class="idpchooser">
<div id="quickLinks"
data-target="/metadata/{http:%2F%2Fpyff.io/domain}{{entity['domains']}}+{http:%2F%2Fpyff.io/role}idp.json"></div>
data-target="/metadata/{http://pyff.io/domain}{{entity['domains']}}+{http://pyff.io/role}idp.json"></div>
<form role="search">
<div class="form-group">
<div id="thesearch"><input type="text"
Expand Down

0 comments on commit a5bed7a

Please sign in to comment.