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"
def check(self, user):
if not user.is_authenticated:
return False
if self == Permission.APPROVE_NEW:
return user.rank.atLeast(UserRank.EDITOR)
else:

@ -14,25 +14,27 @@
<ul class="nav navbar-nav">
<li><a href="/">{{ config.USER_APP_NAME }}</a></li>
{% for item in current_menu.children recursive %}
<li{% if item.children %} class="dropdown"{% endif %}>
<a href="{{ item.url }}"
{% if item.visible %}
<li{% if item.children %} class="dropdown"{% endif %}>
<a href="{{ item.url }}"
{% if item.children %}
class="dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false"
{% endif %}>
{{ item.text }}
{% if item.children %}
class="dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false"
{% endif %}>
{{ item.text }}
<span class="caret"></span>
{% endif %}
</a>
{% if item.children %}
<span class="caret"></span>
<ul class="dropdown-menu" role="menu">
{{ loop(item.children) }}
</ul>
{% endif %}
</a>
{% if item.children %}
<ul class="dropdown-menu" role="menu">
{{ loop(item.children) }}
</ul>
{% endif %}
</li>
</li>
{% endif %}
{% endfor %}
</ul>
<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()
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):
user = User.query.filter_by(username=author).first()
@ -70,7 +81,7 @@ class PackageForm(FlaskForm):
forums = IntegerField("Forum Topic ID", [InputRequired(), NumberRange(0,999999)])
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("/<type>s/<author>/<name>/edit/", methods=['GET', 'POST'])
@login_required