示例#1
0
 def get_result_json():
     """Basically fetch all indicators as per the map level info
     :return:
     """
     indicator_details = {}
     country = Location.country()
     if hasattr(settings, 'MAP_ADMIN_LEVEL'):
         location_type = country.get_descendants()[settings.MAP_ADMIN_LEVEL - 1]
     else:
         location_type = LocationType.largest_unit()
     if report_level is None:
         lreport_level = location_type.level
     else:
         lreport_level = report_level
     for indicator in indicators:
         indicator_df = indicator.get_data(country, report_level=lreport_level).fillna(0)
         indicator_df.index = indicator_df.index.str.upper()
         indicator_details[indicator.name] = indicator_df.transpose(
         ).to_dict()
     return json.dumps(indicator_details, cls=DjangoJSONEncoder)
示例#2
0
def home(request):
    map_filter = MapFilterForm(request.GET)
    in_kwargs = {'display_on_dashboard': True}
    if request.GET.get('survey'):
        in_kwargs['survey__id'] = request.GET['survey']
    display_indicators = Indicator.objects.filter(**in_kwargs).order_by('name')
    return render(request,
                  'home/index.html',
                  {'surveys': Survey.objects.all().order_by('name'),
                   'title': settings.PROJECT_TITLE,
                   'twitter_token': settings.TWITTER_TOKEN,
                   'twitter_url': settings.TWITTER_URL,
                   'map_filter': map_filter,
                   'shape_file_uri': settings.SHAPE_FILE_URI,
                   'loc_field': settings.SHAPE_FILE_LOC_FIELD,
                   'alt_loc_field': settings.SHAPE_FILE_LOC_ALT_FIELD,
                   'map_center': settings.MAP_CENTER,
                   'zoom_level': settings.MAP_ZOOM_LEVEL,
                   'display_indicators': display_indicators,
                   'indicator_reports_field': Indicator.REPORT_FIELD_NAME,
                   'country': Location.country()})
示例#3
0
def home(request):
    map_filter = MapFilterForm(request.GET)
    in_kwargs = {'display_on_dashboard': True}
    if request.GET.get('survey'):
        in_kwargs['survey__id'] = request.GET['survey']
    display_indicators = Indicator.objects.filter(**in_kwargs).order_by('name')
    return render(
        request, 'home/index.html', {
            'surveys': Survey.objects.all().order_by('name'),
            'title': settings.PROJECT_TITLE,
            'twitter_token': settings.TWITTER_TOKEN,
            'twitter_url': settings.TWITTER_URL,
            'map_filter': map_filter,
            'shape_file_uri': settings.SHAPE_FILE_URI,
            'loc_field': settings.SHAPE_FILE_LOC_FIELD,
            'alt_loc_field': settings.SHAPE_FILE_LOC_ALT_FIELD,
            'map_center': settings.MAP_CENTER,
            'zoom_level': settings.MAP_ZOOM_LEVEL,
            'display_indicators': display_indicators,
            'indicator_reports_field': Indicator.REPORT_FIELD_NAME,
            'country': Location.country()
        })