2020-09-20 11:14:54 +00:00
|
|
|
from django.shortcuts import render
|
|
|
|
from dashboard.models import Area_code_2020
|
|
|
|
from django.http import JsonResponse
|
|
|
|
|
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
|
from polls.decorators import polls_login_required
|
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
@polls_login_required
|
|
|
|
def compartments(request):
|
2020-09-23 09:47:05 +00:00
|
|
|
parent_code = request.GET.get('code', '620000000000')
|
2020-09-20 11:14:54 +00:00
|
|
|
compartments = Area_code_2020.objects.filter(pcode=parent_code)
|
|
|
|
results = []
|
|
|
|
for o in compartments:
|
|
|
|
result = dict()
|
|
|
|
result['code'] = o.code
|
|
|
|
result['name'] = o.name
|
|
|
|
result['level'] = o.level
|
|
|
|
result['pcode'] = o.pcode
|
|
|
|
results.append(result)
|
|
|
|
return JsonResponse({'status': 'success', 'message': results}, safe=False)
|