]> git.lizzy.rs Git - cheatdb.git/blob - app/views/packages/todo.py
Add topics todo list based on forum parser
[cheatdb.git] / app / views / packages / todo.py
1 # Content DB
2 # Copyright (C) 2018  rubenwardy
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17
18 from flask import *
19 from flask_user import *
20 from flask.ext import menu
21 from app import app
22 from app.models import *
23
24 @app.route("/todo/")
25 @login_required
26 def todo_page():
27         canApproveNew = Permission.APPROVE_NEW.check(current_user)
28         canApproveRel = Permission.APPROVE_RELEASE.check(current_user)
29         canApproveScn = Permission.APPROVE_SCREENSHOT.check(current_user)
30
31         packages = None
32         if canApproveNew:
33                 packages = Package.query.filter_by(approved=False, soft_deleted=False).all()
34
35         releases = None
36         if canApproveRel:
37                 releases = PackageRelease.query.filter_by(approved=False).all()
38
39         screenshots = None
40         if canApproveScn:
41                 screenshots = PackageScreenshot.query.filter_by(approved=False).all()
42
43
44         topics_to_add = KrockForumTopic.query \
45                         .filter(~ db.exists().where(Package.forums==KrockForumTopic.topic_id)) \
46                         .count()
47
48         return render_template("todo/list.html", title="Reports and Work Queue",
49                 packages=packages, releases=releases, screenshots=screenshots,
50                 canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn,
51                 topics_to_add=topics_to_add)
52
53
54 @app.route("/todo/topics/")
55 @login_required
56 def todo_topics_page():
57         total = KrockForumTopic.query.count()
58
59         topics = KrockForumTopic.query \
60                         .filter(~ db.exists().where(Package.forums==KrockForumTopic.topic_id)) \
61                         .all()
62
63         return render_template("todo/topics.html", topics=topics, total=total)