def project_monitor(brigadeid=None): ''' Are the Brigade projects test passing or not ''' projects = [] projects_with_tests = [] limit = int(request.args.get('limit', 50)) if not brigadeid: projects = cfapi.get_projects(projects, cfapi.BASE_URL + "/projects", limit) else: projects = cfapi.get_projects( projects, cfapi.BASE_URL + "/organizations/" + brigadeid + "/projects", limit ) for project in projects: if project["commit_status"] in ["success", "failure"]: projects_with_tests.append(project) return render_template('monitor.html', projects=projects_with_tests, org_name=brigadeid)
def projects(brigadeid=None): ''' Display a list of projects ''' # is this an exisiting group if brigadeid: if not cfapi.is_existing_organization(brigadeid): return render_template('404.html'), 404 # Get the params projects = [] brigade = None search = request.args.get("q", None) page = request.args.get("page", None) status = request.args.get("status", None) organization_type = request.args.get("organization_type", None) # Set next if page: if brigadeid: next = "/brigade/" + brigadeid + "/projects?page=" + str( int(page) + 1) else: next = "/brigade/projects?page=" + str(int(page) + 1) else: if brigadeid: next = "/brigade/" + brigadeid + "/projects?page=2" else: next = "/brigade/projects?page=2" # build the url if brigadeid: url = cfapi.BASE_URL + "/organizations/" + brigadeid + "/projects" # set the brigade name if projects: brigade = projects[0]["organization"] else: brigade = {"name": brigadeid.replace("-", " ")} else: # build cfapi url url = cfapi.BASE_URL + "/projects" url += "?sort_by=last_updated" if search: url += "&q=" + search if page: url += "&page=" + page if status: url += "&status=" + status if organization_type: url += "&organization_type=" + organization_type projects = cfapi.get_projects(projects, url) return render_template("projects.html", projects=projects, brigade=brigade, next=next)
def project_monitor(brigadeid=None): ''' Are the Brigade projects test passing or not ''' projects = [] projects_with_tests = [] limit = int(request.args.get('limit', 50)) if not brigadeid: projects = cfapi.get_projects( projects, cfapi.BASE_URL + "/projects", limit) else: projects = cfapi.get_projects( projects, cfapi.BASE_URL + "/organizations/" + brigadeid + "/projects", limit ) for project in projects: if project["commit_status"] in ["success", "failure"]: projects_with_tests.append(project) return render_template('monitor.html', projects=projects_with_tests, org_name=brigadeid)
def projects(brigadeid=None): ''' Display a list of projects ''' # is this an exisiting group if brigadeid: brigade = cfapi.find_brigade(brigadeid) if not brigade: return render_template('404.html'), 404 elif brigade["id"] != brigadeid: return redirect( url_for("brigade.projects", brigadeid=brigade["id"])) # Get the params projects = [] brigade = None search = request.args.get("q", None) page = request.args.get("page", 1, int) status = request.args.get("status", None) organization_type = request.args.get("organization_type", None) # Set next next = url_for('.projects', brigadeid=brigadeid, page=page + 1) # build the url if brigadeid: url = cfapi.BASE_URL + "/organizations/" + brigadeid + "/projects" else: url = cfapi.BASE_URL + "/projects" query = {"sort_by": "last_updated"} if search: query.update({"q": search}) if page: query.update({"page": page}) if status: query.update({"status": status}) if organization_type: query.update({"organization_type": organization_type}) url += '?' + urllib.parse.urlencode(query) projects = cfapi.get_projects(projects, url) # set the brigade name if brigadeid: if len(projects): brigade = projects[0]["organization"] else: brigade = {"name": brigadeid.replace("-", " ")} return render_template("projects.html", projects=projects, brigade=brigade, next=next)
def projects(brigadeid=None): ''' Display a list of projects ''' # is this an exisiting group if brigadeid: if not cfapi.is_existing_organization(brigadeid): return render_template('404.html'), 404 # Get the params projects = [] brigade = None search = request.args.get("q", None) page = request.args.get("page", 1, int) status = request.args.get("status", None) organization_type = request.args.get("organization_type", None) # Set next next = url_for('.projects', brigadeid=brigadeid, page=page + 1) # build the url if brigadeid: url = cfapi.BASE_URL + "/organizations/" + brigadeid + "/projects" else: url = cfapi.BASE_URL + "/projects" query = {"sort_by": "last_updated"} if search: query.update({"q": search}) if page: query.update({"page": page}) if status: query.update({"status": status}) if organization_type: query.update({"organization_type": organization_type}) url += '?' + urllib.urlencode(query) projects = cfapi.get_projects(projects, url) # set the brigade name if brigadeid: if len(projects): brigade = projects[0]["organization"] else: brigade = {"name": brigadeid.replace("-", " ")} return render_template("projects.html", projects=projects, brigade=brigade, next=next)