# HG changeset patch # User cavaliet # Date 1355503710 -3600 # Node ID 581c7906ebb4040e88a8d6111da45a75d7896657 # Parent 9bd66b69effcadeb1fb421529b836814911c80aa enable remove unused annotations in mashupbytag diff -r 9bd66b69effc -r 581c7906ebb4 src/ldt/ldt/ldt_utils/views/json.py --- a/src/ldt/ldt/ldt_utils/views/json.py Thu Dec 13 17:42:29 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/views/json.py Fri Dec 14 17:48:30 2012 +0100 @@ -172,6 +172,18 @@ mashup_list["items"].append(res["element_id"]) mashup_dict["lists"].append(mashup_list) + # If asked, we remove the annotations not used in the mashup. + # It enabled a lighter response + remove_not_used_str = request.REQUEST.get("removenotused") + remove_not_used = False + if remove_not_used_str: + remove_not_used = {'true': True, 'false': False, "0": False, "1": True}.get(remove_not_used_str.lower()) + if remove_not_used: + for a in mashup_dict["annotations"]: + if a["id"] not in mashup_list["items"]: + mashup_dict["annotations"].remove(a) + + json_str = simplejson.dumps(mashup_dict, ensure_ascii=False, indent=indent) if escape_bool: json_str = escape(json_str)