def project_task_list(request, project_id): """ Gets tasks for a project """ project = Project.objects.get(id=project_id) task_types = TaskType.objects.filter(projects=project) return HttpResponse(dumps(task_types,indent=2, ensure_ascii=False),mimetype='application/json')
def client_project_list(request, client_id): """ Gets projects associated with a client """ client = Client.objects.get(id=client_id) projects = Project.objects.filter(client=client.harvest_id) return HttpResponse(dumps(projects,indent=2, ensure_ascii=False),mimetype='application/json')
def projects_by_client(request): """ Gets all projects, grouped by client """ response = [] #case insensitive ordering of objects for client in Client.objects.all().extra( select={'lower_name': 'lower(name)'}).order_by('lower_name'): projects = Project.objects.filter(client=client.harvest_id) response.append({ 'name':client.name,'harvestId':client.harvest_id, 'projects':projects }) return HttpResponse(dumps(response,indent=2, ensure_ascii=False),mimetype='application/json')
def client_list(request): """ Gets all clients """ return HttpResponse(dumps(Client.objects.all().order_by('name'),indent=2, ensure_ascii=False),mimetype='application/json')