def list(request): if request.method != CommonData.Method.GET.value: data = CommonData.response_data(RequetMethodError, "Method is invalid") return HttpResponse(json.dumps(data), content_type="application/json") limit = 10 page = 1 if 'limit' in request.GET.keys(): limit = int(request.GET['limit']) if 'current_page' in request.GET.keys(): page = int(request.GET['current_page']) offset = (page - 1) * limit project_list = ProjectDao.get_all_project_list(offset, limit) data = CommonData.response_data(Success, "Success") count = ProjectDao.get_all_projects_count() data["projects_data"] = { "projects": project_list, "current_page": page, "total": count, "limit": limit } return HttpResponse(json.dumps(data, default=datetime2string), content_type="application/json")
def list(request: HttpRequest): if request.method != CommonData.Method.GET.value: response = Response(RequestMethodError, 'Method is invalid', {}) return HttpResponse(response.toJson(), content_type='application/json') limit = 10 page = 1 if 'limit' in request.GET.keys(): limit = int(request.GET['limit']) if 'current_page' in request.GET.keys(): page = int(request.GET['current_page']) offset = (page - 1) * limit project_list = ProjectDao.get_project_list_with_user( request.user, offset, limit) count = ProjectDao.get_all_projects_count() response = Response( Success, 'Success', { 'projects': project_list, 'current_page': page, 'total': count, 'limit': limit }) return HttpResponse(response.toJson(), content_type='application/json')