Exemplo n.º 1
0
def all(req):
    if not is_login(req):
        return HttpResponseNotAllowed()
    service=ResourceService()
    data={'code': 200}
    data['data'] = list(service.list())
    return HttpResponse(json.dumps(data))
Exemplo n.º 2
0
def delete(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    id = req.POST.get('id')
    service=ResourceService()
    service.delete(id)
    return HttpResponse(json.dumps({'code': 200}))
Exemplo n.º 3
0
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    service=ResourceService()
    service.save(
        content=req.POST.get('content'), 
        url=req.POST.get('url'), 
        courseId=req.POST.get('courseId'),
        courseName=req.POST.get('courseName')
    )
    return HttpResponse(json.dumps({'code': 200}))