コード例 #1
0
ファイル: api.py プロジェクト: yeleman/dmd
def get_entity_children(request, parent_uuid=None):
    """ generic view to build json results of entities children list """

    return HttpResponse(json.dumps(
        [Entity.get_or_none(e.uuid).to_dict()
         for e in Entity.get_or_none(parent_uuid).get_children()]),
        content_type='application/json')
コード例 #2
0
def get_entity_children(request, parent_uuid=None):
    """ generic view to build json results of entities children list """

    return HttpResponse(json.dumps([
        Entity.get_or_none(e.uuid).to_dict()
        for e in Entity.get_or_none(parent_uuid).get_children()
    ]),
                        content_type='application/json')
コード例 #3
0
ファイル: api.py プロジェクト: yeleman/dmd
def children_geojson(request, parent_uuid):
    parent = Entity.get_or_none(parent_uuid)

    if parent is None:
        data = None
    else:
        data = parent.children_geojson

    return JsonResponse(data, safe=False)
コード例 #4
0
ファイル: api.py プロジェクト: yeleman/dmd
def single_geojson(request, entity_uuid):
    entity = Entity.get_or_none(entity_uuid)

    if entity is None:
        data = None
    else:
        data = entity.geojson

    return JsonResponse(data, safe=False)
コード例 #5
0
ファイル: api.py プロジェクト: yeleman/dmd
def get_entity_detail(request, entity_uuid=None):
    entity = Entity.get_or_none(entity_uuid)

    if entity is None:
        data = None
    else:
        data = entity.to_dict()

    return JsonResponse(data, safe=False)
コード例 #6
0
def children_geojson(request, parent_uuid):
    parent = Entity.get_or_none(parent_uuid)

    if parent is None:
        data = None
    else:
        data = parent.children_geojson

    return JsonResponse(data, safe=False)
コード例 #7
0
def single_geojson(request, entity_uuid):
    entity = Entity.get_or_none(entity_uuid)

    if entity is None:
        data = None
    else:
        data = entity.geojson

    return JsonResponse(data, safe=False)
コード例 #8
0
def get_entity_detail(request, entity_uuid=None):
    entity = Entity.get_or_none(entity_uuid)

    if entity is None:
        data = None
    else:
        data = entity.to_dict()

    return JsonResponse(data, safe=False)
コード例 #9
0
ファイル: api.py プロジェクト: yeleman/dmd
def json_data_record_for(request, period_str, entity_uuid, indicator_slug):

    entity = Entity.get_or_none(entity_uuid)
    if entity is None:
        raise Http404(_("Unknown entity UUID `{u}`").format(u=entity_uuid))

    period = process_period_filter(request, period_str, 'period').get('period')
    if period is None:
        raise Http404(_("Unknown period `{p}`").format(p=period_str))

    indicator = Indicator.get_or_none(indicator_slug)
    if indicator is None:
        raise Http404(_("Unknown indicator `{s}`").format(s=indicator_slug))

    return JsonResponse(DataRecord.get_for(period, entity, indicator),
                        safe=False)
コード例 #10
0
def json_data_record_for(request, period_str, entity_uuid, indicator_slug):

    entity = Entity.get_or_none(entity_uuid)
    if entity is None:
        raise Http404(_("Unknown entity UUID `{u}`").format(u=entity_uuid))

    period = process_period_filter(request, period_str, 'period').get('period')
    if period is None:
        raise Http404(_("Unknown period `{p}`").format(p=period_str))

    indicator = Indicator.get_or_none(indicator_slug)
    if indicator is None:
        raise Http404(_("Unknown indicator `{s}`").format(s=indicator_slug))

    return JsonResponse(DataRecord.get_for(period, entity, indicator),
                        safe=False)
コード例 #11
0
ファイル: upload.py プロジェクト: yeleman/dmd
def upload_guide_download(request, uuid, *args, **kwargs):

    dps = Entity.get_or_none(uuid)
    if dps is None:
        return Http404(_("No Entity to match `{uuid}`").format(uuid=uuid))

    file_name = dataentry_fname_for(dps)
    file_content = generate_dataentry_for(dps).getvalue()

    response = HttpResponse(file_content,
                            content_type='application/'
                                         'vnd.openxmlformats-officedocument'
                                         '.spreadsheetml.sheet')
    response['Content-Disposition'] = 'attachment; filename="%s"' % file_name
    response['Content-Length'] = len(file_content)

    return response
コード例 #12
0
def upload_guide_download(request, uuid, *args, **kwargs):

    dps = Entity.get_or_none(uuid)
    if dps is None:
        return Http404(_("No Entity to match `{uuid}`").format(uuid=uuid))

    file_name = dataentry_fname_for(dps)
    file_content = generate_dataentry_for(dps).getvalue()

    response = HttpResponse(file_content,
                            content_type='application/'
                            'vnd.openxmlformats-officedocument'
                            '.spreadsheetml.sheet')
    response['Content-Disposition'] = 'attachment; filename="%s"' % file_name
    response['Content-Length'] = len(file_content)

    return response
コード例 #13
0
def process_entity_filter(request, entity_uuid=None):

    root = Entity.objects.get(level=0)
    entity = Entity.get_or_none(entity_uuid) if entity_uuid else root

    if entity is None:
        raise Http404(request,
                      _("Unable to match entity `{uuid}`")
                      .format(uuid=entity_uuid))

    return {
        'blank_uuid': "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        'root': root,
        'entity': entity,
        'lineage_data': lineage_data_for(entity),
        'lineage': Entity.lineage,
        'children': root.get_children(),
    }