def post(self): data = request.get_json() todo = ToDo() todo.title = data.get('title') todo.notes = data.get('notes') todo.deadline = data.get('deadline') todo.tag = data.get('tag') todo.save() return 'Succeed to add task.', 201
def add_problem(request, patient_id): role = UserProfile.objects.get(user=request.user).role authenticated = True if (role == 'physician' or role == 'admin') else False if 'problem_name' in request.POST: problem = Problem(patient=User.objects.get(id=patient_id), problem_name=request.POST['problem_name'], concept_id=request.POST['concept_id'], authenticated=authenticated) problem.save() elif 'goal' in request.POST: goal = Goal(patient=User.objects.get(id=patient_id), goal=request.POST['goal']) goal.save() elif 'todo' in request.POST: print 'todo' print request.POST todo = ToDo(patient=User.objects.get(id=patient_id), todo=request.POST['todo']) todo.save() return HttpResponse('added')
def add_problem(request, patient_id): role = UserProfile.objects.get(user=request.user).role authenticated = True if (role == 'physician' or role == 'admin') else False if 'problem_name' in request.POST: problem = Problem(patient=User.objects.get(id=patient_id), problem_name=request.POST['problem_name'], concept_id=request.POST['concept_id'], authenticated=authenticated) problem.save() elif 'goal' in request.POST: goal = Goal(patient=User.objects.get(id=patient_id), goal=request.POST['goal']) goal.save() elif 'todo' in request.POST: # print 'todo' # print request.POST todo = ToDo(patient=User.objects.get(id=patient_id), todo=request.POST['todo']) todo.save() return HttpResponse('added')
def create_todo(req): if req.session.get('mail'): user = models.User.objects.filter(mail=req.session.get('mail')).first() if req.method == 'POST': tdf = ToDoForm(req.POST) if tdf.is_valid(): title = tdf.cleaned_data['title'] # 获取form表单中的值 content = tdf.cleaned_data['content'] date = tdf.cleaned_data['date'] todo = ToDo() todo.title = title todo.content = content todo.date = date todo.user = user todo.save() return HttpResponseRedirect('/todo_list/') else: return render(req, 'create_todo.html') else: return render_to_response('login.html', {})