mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Todo: Add game support status
This commit is contained in:
parent
d0f6be6826
commit
57b736b1df
@ -20,7 +20,7 @@ from flask_login import current_user, login_required
|
|||||||
from sqlalchemy import or_, and_
|
from sqlalchemy import or_, and_
|
||||||
|
|
||||||
from app.models import User, Package, PackageState, PackageScreenshot, PackageUpdateConfig, ForumTopic, db, \
|
from app.models import User, Package, PackageState, PackageScreenshot, PackageUpdateConfig, ForumTopic, db, \
|
||||||
PackageRelease, Permission, NotificationType, AuditSeverity, UserRank
|
PackageRelease, Permission, NotificationType, AuditSeverity, UserRank, PackageType
|
||||||
from app.tasks.importtasks import makeVCSRelease
|
from app.tasks.importtasks import makeVCSRelease
|
||||||
from app.utils import addNotification, addAuditLog
|
from app.utils import addNotification, addAuditLog
|
||||||
|
|
||||||
@ -51,6 +51,17 @@ def view_user(username=None):
|
|||||||
Package.state == PackageState.CHANGES_NEEDED)) \
|
Package.state == PackageState.CHANGES_NEEDED)) \
|
||||||
.order_by(db.asc(Package.created_at)).all()
|
.order_by(db.asc(Package.created_at)).all()
|
||||||
|
|
||||||
|
outdated_packages = user.maintained_packages \
|
||||||
|
.filter(Package.state != PackageState.DELETED,
|
||||||
|
Package.update_config.has(PackageUpdateConfig.outdated_at.isnot(None))) \
|
||||||
|
.order_by(db.asc(Package.title)).all()
|
||||||
|
|
||||||
|
missing_game_support = user.maintained_packages.filter(
|
||||||
|
Package.state != PackageState.DELETED,
|
||||||
|
Package.type.in_([PackageType.MOD, PackageType.TXP]),
|
||||||
|
~Package.supported_games.any()) \
|
||||||
|
.order_by(db.asc(Package.title)).all()
|
||||||
|
|
||||||
packages_with_no_screenshots = user.maintained_packages.filter(
|
packages_with_no_screenshots = user.maintained_packages.filter(
|
||||||
~Package.screenshots.any(), Package.state == PackageState.APPROVED).all()
|
~Package.screenshots.any(), Package.state == PackageState.APPROVED).all()
|
||||||
|
|
||||||
@ -60,11 +71,6 @@ def view_user(username=None):
|
|||||||
PackageScreenshot.height < PackageScreenshot.SOFT_MIN_SIZE[1]))) \
|
PackageScreenshot.height < PackageScreenshot.SOFT_MIN_SIZE[1]))) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
outdated_packages = user.maintained_packages \
|
|
||||||
.filter(Package.state != PackageState.DELETED,
|
|
||||||
Package.update_config.has(PackageUpdateConfig.outdated_at.isnot(None))) \
|
|
||||||
.order_by(db.asc(Package.title)).all()
|
|
||||||
|
|
||||||
topics_to_add = ForumTopic.query \
|
topics_to_add = ForumTopic.query \
|
||||||
.filter_by(author_id=user.id) \
|
.filter_by(author_id=user.id) \
|
||||||
.filter(~ db.exists().where(Package.forums == ForumTopic.topic_id)) \
|
.filter(~ db.exists().where(Package.forums == ForumTopic.topic_id)) \
|
||||||
@ -77,7 +83,7 @@ def view_user(username=None):
|
|||||||
|
|
||||||
return render_template("todo/user.html", current_tab="user", user=user,
|
return render_template("todo/user.html", current_tab="user", user=user,
|
||||||
unapproved_packages=unapproved_packages, outdated_packages=outdated_packages,
|
unapproved_packages=unapproved_packages, outdated_packages=outdated_packages,
|
||||||
needs_tags=needs_tags, topics_to_add=topics_to_add,
|
missing_game_support=missing_game_support, needs_tags=needs_tags, topics_to_add=topics_to_add,
|
||||||
packages_with_no_screenshots=packages_with_no_screenshots,
|
packages_with_no_screenshots=packages_with_no_screenshots,
|
||||||
packages_with_small_screenshots=packages_with_small_screenshots,
|
packages_with_small_screenshots=packages_with_small_screenshots,
|
||||||
screenshot_min_size=PackageScreenshot.HARD_MIN_SIZE, screenshot_rec_size=PackageScreenshot.SOFT_MIN_SIZE)
|
screenshot_min_size=PackageScreenshot.HARD_MIN_SIZE, screenshot_rec_size=PackageScreenshot.SOFT_MIN_SIZE)
|
||||||
@ -127,3 +133,22 @@ def apply_all_updates(username):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return redirect(url_for("todo.view_user", username=username))
|
return redirect(url_for("todo.view_user", username=username))
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/user/game_support/")
|
||||||
|
@bp.route("/users/<username>/game_support/")
|
||||||
|
@login_required
|
||||||
|
def all_game_support(username=None):
|
||||||
|
if username is None:
|
||||||
|
return redirect(url_for("todo.all_game_support", username=current_user.username))
|
||||||
|
|
||||||
|
user: User = User.query.filter_by(username=username).one_or_404()
|
||||||
|
if current_user != user and not current_user.rank.atLeast(UserRank.EDITOR):
|
||||||
|
abort(403)
|
||||||
|
|
||||||
|
packages = user.maintained_packages.filter(
|
||||||
|
Package.state != PackageState.DELETED,
|
||||||
|
Package.type.in_([PackageType.MOD, PackageType.TXP])) \
|
||||||
|
.order_by(db.asc(Package.title)).all()
|
||||||
|
|
||||||
|
return render_template("todo/game_support.html", user=user, packages=packages)
|
||||||
|
58
app/templates/todo/game_support.html
Normal file
58
app/templates/todo/game_support.html
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ _("Game Support for %(username)s", username=user.display_name) }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<a class="btn btn-secondary float-right" href="/help/game_support/">{{ _("Help") }}</a>
|
||||||
|
<h1 class="mb-5">{{ self.title() }}</h1>
|
||||||
|
<p>
|
||||||
|
{{ _("You should specify the games supported by your mods and texture packs.") }}
|
||||||
|
{{ _("Specifying game support makes it easier for players to find your content.") }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="list-group mt-3 mb-5">
|
||||||
|
{% for package in packages %}
|
||||||
|
<div class="list-group-item">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-2 text-muted">
|
||||||
|
<img
|
||||||
|
class="img-fluid"
|
||||||
|
style="max-height: 22px; max-width: 22px;"
|
||||||
|
src="{{ package.getThumbnailOrPlaceholder() }}" />
|
||||||
|
|
||||||
|
<span class="pl-2">
|
||||||
|
{{ package.title }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
{% set supported_games = package.getSortedSupportedGames() %}
|
||||||
|
{% if supported_games %}
|
||||||
|
{% for support in supported_games %}
|
||||||
|
<a class="badge badge-secondary"
|
||||||
|
href="{{ support.game.getURL('packages.view') }}">
|
||||||
|
{{ _("%(title)s by %(display_name)s",
|
||||||
|
title=support.game.title, display_name=support.game.author.display_name) }}
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">
|
||||||
|
<i>
|
||||||
|
{{ _("None listed, assumed to support all games") }}
|
||||||
|
</i>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<a class="btn btn-sm btn-primary" href="{{ package.getURL('packages.game_support') }}">Game Support</a>
|
||||||
|
<a class="btn btn-sm btn-secondary" href="{{ package.getURL('packages.view') }}">Package</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-muted">{{ _("Nothing to do :)") }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -63,6 +63,38 @@
|
|||||||
{% from "macros/todo.html" import render_outdated_packages %}
|
{% from "macros/todo.html" import render_outdated_packages %}
|
||||||
{{ render_outdated_packages(outdated_packages, current_user) }}
|
{{ render_outdated_packages(outdated_packages, current_user) }}
|
||||||
|
|
||||||
|
<div class="mb-4"></div>
|
||||||
|
|
||||||
|
<a class="btn btn-secondary float-right" href="/help/game_support/">
|
||||||
|
{{ _("Help") }}
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-secondary float-right mr-2" href="{{ url_for('todo.all_game_support', username=user.username) }}">
|
||||||
|
{{ _("See game support for your packages") }}
|
||||||
|
</a>
|
||||||
|
<h2>{{ _("Missing Game Support") }}</h2>
|
||||||
|
{% if missing_game_support %}
|
||||||
|
<p>
|
||||||
|
{{ _("You should specify the games supported by your mods and texture packs.") }}
|
||||||
|
{{ _("Specifying game support makes it easier for players to find your content.") }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
<div class="list-group mt-3 mb-5">
|
||||||
|
{% for package in missing_game_support %}
|
||||||
|
<a class="list-group-item list-group-item-action" href="{{ package.getURL('packages.game_support') }}">
|
||||||
|
<img
|
||||||
|
class="img-fluid"
|
||||||
|
style="max-height: 22px; max-width: 22px;"
|
||||||
|
src="{{ package.getThumbnailOrPlaceholder() }}" />
|
||||||
|
|
||||||
|
<span class="pl-2">
|
||||||
|
{{ package.title }}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-muted">{{ _("Nothing to do :)") }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="mt-5"></div>
|
<div class="mt-5"></div>
|
||||||
<h2 id="missing-screenshots">{{ _("Missing Screenshots") }}</h2>
|
<h2 id="missing-screenshots">{{ _("Missing Screenshots") }}</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user