Exemple #1
0
def save(req):
    if req.method != 'POST':
        return HttpResponseNotFound()

    if not is_login(req):
        return HttpResponseNotAllowed()
    techerId=None
    if 'tech' == req.session['utype']:
        techerId = req.session['id']
        techer=TechService().findById(techerId)
        service=CourseService()
        service.save(
            name=req.POST.get('name'), 
            purpose=req.POST.get('purpose'), 
            techerId=techerId,
            techerNumber=techer['number'],
            techerName=techer['name']
        )
        return HttpResponse(json.dumps({'code': 200}))
    else:
        return HttpResponseNotAllowed()