from django.shortcuts import render
from django.http import JsonResponse, HttpResponse

import urllib.request
import urllib.parse
import json


# Create your views here.
def index(request):
    return HttpResponse('Success!')


def course_all(request):
    req = urllib.request.Request('http://models-api:8000/api/course/all/')
    resp_json = urllib.request.urlopen(req).read().decode('utf-8')
    resp = json.loads(resp_json)
    return JsonResponse(resp)


def course_detail(request, sisid):
    req = urllib.request.Request('http://models-api:8000/api/course/' + sisid + '/')
    resp_json = urllib.request.urlopen(req).read().decode('utf-8')
    resp = json.loads(resp_json)
    return JsonResponse(resp)

@@ -425,36 +425,692 @@
 on)%0A
+%0A
     
-return JsonResponse(resp
+new_data = %7B%7D%0A    new_data%5B'status_code'%5D = resp%5B'status_code'%5D%0A%0A    course_data = %5B%5D%0A    for course_dict in resp%5B'all_courses'%5D:%0A        new_dict = %5B%5D%0A        new_dict%5B'href'%5D = course_dict%5B'id'%5D + '/'%0A        new_dict%5B'course_name'%5D = course_dict%5B'mnemonic'%5D + %22 %22 + course_dict%5B'number'%5D%0A        if course_dict%5B'section'%5D != '':%0A            new_dict%5B'course_name'%5D += %22 - %22 + course_dict%5B'section'%5D%0A        if course_dict%5B'title'%5D != '':%0A            new_dict%5B'course_name'%5D += %22: %22 + course_dict%5B'title'%5D%0A        new_dict%5B'instructor'%5D = course_dict%5B'instructor'%5D%0A        course_data.append(new_dict)%0A    new_data%5B'all_courses'%5D = course_data%0A%0A    return JsonResponse(new_data
 )%0A%0A%0A
@@ -1288,32 +1288,32 @@
 decode('utf-8')%0A
-
     resp = json.
@@ -1329,16 +1329,98 @@
 p_json)%0A
+%0A    for key in resp.keys:%0A        if resp%5Bkey%5D == '':%0A            resp.pop(key)%0A%0A
     retu

optimize data in exp level