def v_tasks_ajax(req): opts = { 'people': req.GET.get('people') or 'me', 'status': int(req.GET.get('status')) or 0 } user = req.user proj = req._target if 'me' == opts['people']: Q0 = Q(creator = user) elif 'others' == opts['people']: Q0 = ~Q(creator = user) else: Q0 = Q() if 2 == opts['status']: Q1 = Q() else: Q1 = Q(is_done = opts['status']) qs = proj.tasks.filter(Q0, Q1) data = [i.stdout() for i in qs.order_by('-created_time')] return render_api(data)
def v_tasks_ajax_create(req): print req.POST form = forms.TaskForm(user=req.user, data=req.POST.copy()) if not form.is_valid(): print form.errors raise ApiBaseError(400, 'Bad Data') task = form.save() return render_api(task.stdout())
def v_projs_ajax(req): # NOTE ?? if False: try: user_is_creator = int(req.GET.get('is_creator')) except: raise ApiBaseError(400, 'param error') user = req.user data = [i.stdout() for i in user.in_projs.all()] return render_api(data)
def v_tasks_ajax_undone(req): task = req._target if not task.is_done: raise ApiBaseError(400) task.undone() return render_api({})
def v_tasks_ajax_commenton(req): print req.POST _comment_.create_comment(req._target, req.user, req.POST['content']) return render_api({'msg': 'OK'})
def v_tasks_ajax_delete(req): task = req._target task.delete() return render_api({})
def v_tasks_ajax_update(req): task = req._target task.content = req.POST['content'] task.save() return render_api(task.stdout())
def v_tasks_ajax_show(req): task = req._target data = task.stdout() data['comments'] = _comment_.get_comments(task) return render_api(data)
def v_projs_ajax_show(req): return render_api(req._target.stdout())