示例#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
def _create_admin_unit(form):
    admin_unit = AdministrativeUnit()
    admin_unit.name = form.cleaned_data['name']
    admin_unit.country = form.cleaned_data['country']
    admin_unit.region_type = form.cleaned_data['region_type']
    admin.region_statistics = form.cleaned_data['region_statistics']
    admin_unit.save()
def _create_admin_unit(form):
    admin_unit = AdministrativeUnit()
    admin_unit.name = form.cleaned_data['name']
    admin_unit.country = form.cleaned_data['country']
    admin_unit.region_type = form.cleaned_data['region_type']
    admin_unit.health = form.cleaned_data['health']
    admin_unit.economy = form.cleaned_data['economy']
    admin_unit.environment = form.cleaned_data['environment']
    admin_unit.governance = form.cleaned_data['governance']
    admin_unit.infrastructure = form.cleaned_data['infrastructure']
    admin_unit.social_sector = form.cleaned_data['social_sector']    
    admin_unit.agriculture = form.cleaned_data['agriculture']
    admin_unit.dev_partners = form.cleaned_data['dev_partners']
    admin_unit.recent_reports = form.cleaned_data['recent_reports']
    admin_unit.resources = form.cleaned_data['resources']
    admin_unit.save()
示例#4
0
        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
    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