from flask import render_template

import quoted_forsooth.plugins.report_plugin as report_plugin
from quoted_forsooth.db import session_scope, get_tag, Game, Completion, Quotation, Tag

class ReportNeedsEndingScreencap(report_plugin.ReportPlugin):
    url_name = 'needs_ending_screencap'

    def view(self):
        with session_scope() as session:
            ss = session.query(Game).filter(
                Game.completions.any(Completion.status_id == 2),
                ~Game.quotations.any(Quotation.tags.any(Tag.id == get_tag('endless game').id)),
                ~Game.quotations.any(Quotation.tags.any(Tag.id == get_tag('you win').id)))
            return render_template('source/index.html', sources=ss)
