Add work queue

This commit is contained in:
rubenwardy 2018-03-21 19:24:45 +00:00
parent aed805da6e
commit e5de870b47
4 changed files with 66 additions and 17 deletions

@ -36,6 +36,9 @@ class Permission(enum.Enum):
CHANGE_RELEASE_URL = "CHANGE_RELEASE_URL" CHANGE_RELEASE_URL = "CHANGE_RELEASE_URL"
def check(self, user): def check(self, user):
if not user.is_authenticated:
return False
if self == Permission.APPROVE_NEW: if self == Permission.APPROVE_NEW:
return user.rank.atLeast(UserRank.EDITOR) return user.rank.atLeast(UserRank.EDITOR)
else: else:

@ -14,6 +14,7 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="/">{{ config.USER_APP_NAME }}</a></li> <li><a href="/">{{ config.USER_APP_NAME }}</a></li>
{% for item in current_menu.children recursive %} {% for item in current_menu.children recursive %}
{% if item.visible %}
<li{% if item.children %} class="dropdown"{% endif %}> <li{% if item.children %} class="dropdown"{% endif %}>
<a href="{{ item.url }}" <a href="{{ item.url }}"
{% if item.children %} {% if item.children %}
@ -33,6 +34,7 @@
</ul> </ul>
{% endif %} {% endif %}
</li> </li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">

33
app/templates/todo.html Normal file

@ -0,0 +1,33 @@
{% extends "base.html" %}
{% block title %}
{{ title }}
{% endblock %}
{% block content %}
<h2>Packages Awaiting Approval</h2>
<ul>
{% for p in approve_new %}
<li><a href="{{ p.getDetailsURL() }}">
{{ p.title }} by {{ p.author.display_name }}
</a></li>
{% else %}
<li><i>No packages available</i></ul>
{% endfor %}
</ul>
<h2>Releases Awaiting Approval</h2>
<ul>
{% for r in releases %}
<li>
<a href="{{ r.getEditURL() }}">{{ r.title }}</a>
on
<a href="{{ r.package.getDetailsURL() }}">
{{ r.package.title }} by {{ r.package.author.display_name }}
</a>
</li>
{% else %}
<li><i>No packages available</i></ul>
{% endfor %}
</ul>
{% endblock %}

@ -30,6 +30,17 @@ def txp_page():
packages = Package.query.filter_by(type=PackageType.TXP, approved=True).all() packages = Package.query.filter_by(type=PackageType.TXP, approved=True).all()
return render_template('packages.html', title="Texture Packs", packages=packages) return render_template('packages.html', title="Texture Packs", packages=packages)
def canSeeWorkQueue():
return Permission.APPROVE_NEW.check(current_user)
@menu.register_menu(app, '.todo', "Work Queue", order=20, visible_when=lambda: canSeeWorkQueue)
@app.route("/todo/")
@login_required
def todo_page():
packages = Package.query.filter_by(approved=False).all()
releases = PackageRelease.query.filter_by(approved=False).all()
return render_template('todo.html', title="Reports and Work Queue", approve_new=packages, releases=releases)
def getPageByInfo(type, author, name): def getPageByInfo(type, author, name):
user = User.query.filter_by(username=author).first() user = User.query.filter_by(username=author).first()
@ -70,7 +81,7 @@ class PackageForm(FlaskForm):
forums = IntegerField("Forum Topic ID", [InputRequired(), NumberRange(0,999999)]) forums = IntegerField("Forum Topic ID", [InputRequired(), NumberRange(0,999999)])
submit = SubmitField('Save') submit = SubmitField('Save')
@menu.register_menu(app, '.new', 'Create', order=20) @menu.register_menu(app, '.new', 'Create', order=21, visible_when=lambda: current_user.is_authenticated)
@app.route("/new/", methods=['GET', 'POST']) @app.route("/new/", methods=['GET', 'POST'])
@app.route("/<type>s/<author>/<name>/edit/", methods=['GET', 'POST']) @app.route("/<type>s/<author>/<name>/edit/", methods=['GET', 'POST'])
@login_required @login_required