mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Add basic search to package list
This commit is contained in:
parent
8a8b0e505b
commit
4e870bd641
@ -5,6 +5,11 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<form method="get" action="">
|
||||||
|
<input type="text" name="q" value="{{ query or ''}}" />
|
||||||
|
<input type="submit" value="Search" />
|
||||||
|
</form>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for p in packages %}
|
{% for p in packages %}
|
||||||
<li><a href="{{ p.getDetailsURL() }}">
|
<li><a href="{{ p.getDetailsURL() }}">
|
||||||
|
@ -12,23 +12,29 @@ from wtforms.validators import *
|
|||||||
# TODO: the following could be made into one route, except I'm not sure how
|
# TODO: the following could be made into one route, except I'm not sure how
|
||||||
# to do the menu
|
# to do the menu
|
||||||
|
|
||||||
|
def doPackageList(type):
|
||||||
|
packagesQ = Package.query.filter_by(type=type, approved=True)
|
||||||
|
|
||||||
|
query = request.args.get("q")
|
||||||
|
if query is not None:
|
||||||
|
packagesQ = packagesQ.filter(Package.title.contains(query))
|
||||||
|
|
||||||
|
return render_template('packages.html', title=type.value + "s", packages=packagesQ.all(), query=query)
|
||||||
|
|
||||||
@app.route('/mods/')
|
@app.route('/mods/')
|
||||||
@menu.register_menu(app, '.mods', 'Mods', order=10)
|
@menu.register_menu(app, '.mods', 'Mods', order=10)
|
||||||
def mods_page():
|
def mods_page():
|
||||||
packages = Package.query.filter_by(type=PackageType.MOD, approved=True).all()
|
return doPackageList(PackageType.MOD)
|
||||||
return render_template('packages.html', title="Mods", packages=packages)
|
|
||||||
|
|
||||||
@app.route('/games/')
|
@app.route('/games/')
|
||||||
@menu.register_menu(app, '.games', 'Games', order=11)
|
@menu.register_menu(app, '.games', 'Games', order=11)
|
||||||
def games_page():
|
def games_page():
|
||||||
packages = Package.query.filter_by(type=PackageType.GAME, approved=True).all()
|
return doPackageList(PackageType.GAME)
|
||||||
return render_template('packages.html', title="Games", packages=packages)
|
|
||||||
|
|
||||||
@app.route('/texturepacks/')
|
@app.route('/texturepacks/')
|
||||||
@menu.register_menu(app, '.txp', 'Texture Packs', order=12)
|
@menu.register_menu(app, '.txp', 'Texture Packs', order=12)
|
||||||
def txp_page():
|
def txp_page():
|
||||||
packages = Package.query.filter_by(type=PackageType.TXP, approved=True).all()
|
return doPackageList(PackageType.TXP)
|
||||||
return render_template('packages.html', title="Texture Packs", packages=packages)
|
|
||||||
|
|
||||||
def canSeeWorkQueue():
|
def canSeeWorkQueue():
|
||||||
return Permission.APPROVE_NEW.check(current_user) or \
|
return Permission.APPROVE_NEW.check(current_user) or \
|
||||||
|
Loading…
Reference in New Issue
Block a user