def home(): if session: username = session['username'] uid = session['id'] # print(uid) projects = ProjectsModel.fetch_records(uid) users = UserModel.fetch_records() status = [x.status for x in projects] print(status) pie_chart = pygal.Pie() pie_chart.title = 'Incomplete projects vs Complete projects' pie_chart.add('ProjectModel', status.count('Complete')) pie_chart.add('ProjectModel', status.count('Incomplete')) graph = pie_chart.render_data_uri() return render_template('index.html', proj=len(projects), user=len(users), graph=graph) else: flash("Unauthorised Access", "danger") return redirect(url_for('login'))
def get(self): try: users = UserModel.fetch_records() return users_schema.dump(users) except KeyError as e: api.abort(500, e.__doc__, status="Could not perform this action", statusCode="500") except KeyError as e: api.abort(400, e.__doc__, status="Could not perform this action", statusCode="400")
def users(): # Fetch all records in users users = UserModel.fetch_records() return render_template('users.html', users=users)