def change_task_field(request, task_id, field_name): """Change a task field to the POSTed value.""" task = get_object_or_404(Task, pk=task_id) value, is_valid = _validate_field_value(field_name, request.POST.get(field_name)) if not is_valid: return json_r({}, HttpResponseBadRequest) setattr(task, field_name, value) task.save() return json_r({field_name: getattr(task, field_name)})
def all(request): counts = [[2, 0, 4, 12], [1, 11]] folders = _get_folders(request) pager = ['', ''] tasks = _get_tasks(request) friends = user_views.get_friends(request) return json_r({'counts': counts, 'groups': folders, 'pager': pager, 'tasks': tasks, 'friends': friends})
def all(request): counts = [[2, 0, 4, 12], [1, 11]] folders = _get_folders(request) pager = ['', ''] tasks = _get_tasks(request) friends = user_views.get_friends(request) return json_r({ 'counts': counts, 'groups': folders, 'pager': pager, 'tasks': tasks, 'friends': friends })
def new_task(request): # TODO: use forms return json_r({'TODO': True})
def folders(request): results = _get_folders(request) return json_r({'results': results})
def friends(request): return json_r(get_friends(request))
def available(request): form = UserForm(request.POST) available = 0 if form.is_valid(): available = 1 return json_r({'available': available})