예제 #1
0
def _get_admin_model(admin_manager, details):
    try:
        country_regex = re.compile('^HASC')
        country_match = filter(country_regex.search, details.keys())
        country_match.sort()
        country_code = details[country_match[-1]].split(".")[0]
        unit_regex = re.compile('^NAME')
        admin_units = filter(unit_regex.search, details.keys())
        admin_units.sort()
        adminModel = admin_manager.get(name=details[admin_units[-1]],country=country_code)
        adminModel.found = True
        adminModel.unit_in_focus = "Region Details for %s in %s" %(details[admin_units[-1]], details['NAME_0'])
    except AdministrativeUnit.DoesNotExist, ex:
        logging.exception("Unable to find admin unit %s" % str(ex))
        adminModel = AdministrativeUnit()
        adminModel.unit_in_focus = "Region Details for %s in %s" %(details[admin_units[-1]], details['NAME_0'])
        adminModel.found = False
예제 #2
0
        country_code = details[country_match[-1]].split(".")[0]
        unit_regex = re.compile('^NAME')
        admin_units = filter(unit_regex.search, details.keys())
        admin_units.sort()
        adminModel = admin_manager.get(name=details[admin_units[-1]],country=country_code)
        adminModel.found = True
        adminModel.unit_in_focus = "Region Details for %s in %s" %(details[admin_units[-1]], details['NAME_0'])
    except AdministrativeUnit.DoesNotExist, ex:
        logging.exception("Unable to find admin unit %s" % str(ex))
        adminModel = AdministrativeUnit()
        adminModel.unit_in_focus = "Region Details for %s in %s" %(details[admin_units[-1]], details['NAME_0'])
        adminModel.found = False
    except Exception, ex:
        logging.exception("Exception thrown in admin unit search %s" % str(ex))
        adminModel = AdministrativeUnit()
        adminModel.unit_in_focus = ""
        adminModel.found = False
    
    return adminModel
 
def _filter_projects_for_request(request):
   if request.GET.get('tag', ''):
       projects = _get_projects_with_tag(left, bottom, right, top, sector_ids, implementor_ids, request.GET.get('tag'))
   elif request.GET.get('search_term', ''):
       projects = _get_projects_with_tag(left, bottom, right, top, sector_ids, implementor_ids, request.GET.get('search_term'))
   else:
       projects = _get_projects(left, bottom, right, top, sector_ids, implementor_ids)
   return projects


def convert_to_json(projects):