def deregister(cls, email: str) -> bool: user = cls.find_by_email(email) user.remove_from_mongo() alerts = Alert.find_many_by("user_email", email) for alert in alerts: alert.remove_from_mongo() return True
def delete_report(report_id): report = Report.get_by_id(report_id) try: alerts = Alert.find_many_by("report_id", report_id) for alert in alerts: alert.remove_from_mongo() flash( f"Alert for {alert.report.state_name} with threshold of {alert.case_limit} cases removed.", "danger") except TypeError: print(f"No alerts associated with {report.state_name}.") report.remove_from_mongo() flash(f"Report for {report.state_name} removed from database.", "danger") return redirect(url_for('.index'))
def index(): reports = Report.all() subscribers = [] for report in reports: report.load_data() alerts = Alert.find_many_by("report_id", report._id) subscribers.append(len(alerts)) sind = sorted(range(len(subscribers)), key=lambda k: -subscribers[k]) reports = [reports[i] for i in sind] subscribers = [subscribers[i] for i in sind] for report in reports: report.load_data() return render_template('reports_index.html', reports=reports, subscribers=subscribers)
def index(): alerts = Alert.find_many_by('user_email', session['email']) return render_template('alerts_index.html', alerts=alerts)
def index(): alerts = Alert.find_many_by('user_email', session['email']) for alert in alerts: alert.report.load_data() return render_template('alerts_index.html', alerts=alerts)