コード例 #1
0
ファイル: views.py プロジェクト: haandol/assemblyapi
def api_get_assembly_member(request, version, format):
    if request.method == 'POST':
        return get_error_json(900) if format=='json' else get_error_xml(900)

    name = get_value(request, 'GET', 'name')
    area = get_value(request, 'GET', 'area')
    party = get_value(request, 'GET', 'party')

    members = Assemblyman.objects.all()
    if name:
        members = members.filter(name=name)
    if area:
        members = members.filter(area__contains=area)
    if party: 
        members = members.filter(party__name=party)

    return bind_members(members, format)
コード例 #2
0
ファイル: views.py プロジェクト: haandol/assemblyapi
def api_get_assembly_candidate(request, version, format):
    if request.method == 'POST':
        return get_error_json(900) if format=='json' else get_error_xml(900)

    name = get_value(request, 'GET', 'name')
    city = get_value(request, 'GET', 'city')
    area = get_value(request, 'GET', 'area')
    party = get_value(request, 'GET', 'party')

    candidates = Candidate.objects.all()
    if name:
        candidates = candidates.filter(name=name)
    if city:
        candidates = candidates.filter(city__contains=city)
    if area:
        candidates = candidates.filter(area__contains=area)
    if party: 
        candidates = candidates.filter(party=party)

    return bind_candidates(candidates, format)