From 2c2a2036d95ec25ac3ee8937941b2c1a614974b4 Mon Sep 17 00:00:00 2001 From: Jens Timmerman Date: Wed, 11 May 2016 10:24:33 +0200 Subject: [PATCH] enable categories again in the view, but allow for disabling categories by setting them empty in the settings. Also fix a sorting issue where names sometimes had whitespace in front of their names --- setup.py | 2 +- wayf/templates/idp_dropdown.html | 2 +- wayf/utils.py | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 345bcbe..7d68844 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='django-wayf', - version='0.1', + version='0.2.0', packages=find_packages(), include_package_data=True, license='GPL v3', diff --git a/wayf/templates/idp_dropdown.html b/wayf/templates/idp_dropdown.html index c9f43d6..c1bc245 100644 --- a/wayf/templates/idp_dropdown.html +++ b/wayf/templates/idp_dropdown.html @@ -1,5 +1,5 @@ {% for category, insts in idplist %} - + {% for inst in insts %} {% ifequal inst.id selected.id %} diff --git a/wayf/utils.py b/wayf/utils.py index 76443ef..23ae859 100644 --- a/wayf/utils.py +++ b/wayf/utils.py @@ -206,6 +206,11 @@ def getIdpsByCategory(self, lang=None, exclude=None): idps = [] + # if no valid categories are found, return all idp's + if not validcats: + catidps = self.getEntities() + return [('institutions', catidps)] + for category in cats: catidps = sorted(self.getCategoryIdps(category)) idps.append(map(lambda x: { @@ -253,13 +258,13 @@ def __init__(self,el): # Get the institution's name try: for name in self.el.Organization.OrganizationDisplayName: - self.name[name.get('{http://www.w3.org/XML/1998/namespace}lang')] = name.text + self.name[name.get('{http://www.w3.org/XML/1998/namespace}lang')] = name.text.strip() except: self.name = {'en': "no name"} try: for url in self.el.Organization.OrganizationURL: - self.url[url.get('{http://www.w3.org/XML/1998/namespace}lang')] = url.text + self.url[url.get('{http://www.w3.org/XML/1998/namespace}lang')] = url.text.strip() except: pass @@ -271,12 +276,12 @@ def __init__(self,el): # require a set of nested checks, exception catching is more # clean. try: - self.contact['email'] = contact.EmailAddress.text + self.contact['email'] = contact.EmailAddress.text.strip() except: pass try: - self.contact['telephone'] = contact.TelephoneNumber.text + self.contact['telephone'] = contact.TelephoneNumber.text.strip() except: pass except: