mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Rename "Metapackage" to "Mod Name"
This commit is contained in:
parent
f649fa57e6
commit
906ec3885a
@ -25,7 +25,7 @@ from sqlalchemy import or_, and_
|
|||||||
|
|
||||||
from app.logic.game_support import GameSupportResolver
|
from app.logic.game_support import GameSupportResolver
|
||||||
from app.models import PackageRelease, db, Package, PackageState, PackageScreenshot, MetaPackage, User, \
|
from app.models import PackageRelease, db, Package, PackageState, PackageScreenshot, MetaPackage, User, \
|
||||||
NotificationType, PackageUpdateConfig, License, UserRank, PackageType, PackageGameSupport, ThreadReply
|
NotificationType, PackageUpdateConfig, License, UserRank, PackageType, ThreadReply
|
||||||
from app.tasks.emails import send_pending_digests
|
from app.tasks.emails import send_pending_digests
|
||||||
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
||||||
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, check_for_updates, updateAllGameSupport
|
from app.tasks.importtasks import importRepoScreenshot, checkZipRelease, check_for_updates, updateAllGameSupport
|
||||||
@ -147,14 +147,14 @@ def clean_uploads():
|
|||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
|
|
||||||
|
|
||||||
@action("Delete unused metapackages")
|
@action("Delete unused mod names")
|
||||||
def del_meta_packages():
|
def del_mod_names():
|
||||||
query = MetaPackage.query.filter(~MetaPackage.dependencies.any(), ~MetaPackage.packages.any())
|
query = MetaPackage.query.filter(~MetaPackage.dependencies.any(), ~MetaPackage.packages.any())
|
||||||
count = query.count()
|
count = query.count()
|
||||||
query.delete(synchronize_session=False)
|
query.delete(synchronize_session=False)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
flash("Deleted " + str(count) + " unused meta packages", "success")
|
flash("Deleted " + str(count) + " unused mod names", "success")
|
||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,22 +19,27 @@ from flask import *
|
|||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from app.models import MetaPackage, Package, db, Dependency, PackageState, ForumTopic
|
from app.models import MetaPackage, Package, db, Dependency, PackageState, ForumTopic
|
||||||
|
|
||||||
bp = Blueprint("metapackages", __name__)
|
bp = Blueprint("modnames", __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/metapackages/")
|
@bp.route("/metapackages/<path:path>")
|
||||||
|
def mp_redirect(path):
|
||||||
|
return redirect(path.replace("/metapackages/", "/modnames/"))
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/modnames/")
|
||||||
def list_all():
|
def list_all():
|
||||||
mpackages = db.session.query(MetaPackage, func.count(Package.id)) \
|
modnames = db.session.query(MetaPackage, func.count(Package.id)) \
|
||||||
.select_from(MetaPackage).outerjoin(MetaPackage.packages) \
|
.select_from(MetaPackage).outerjoin(MetaPackage.packages) \
|
||||||
.order_by(db.asc(MetaPackage.name)) \
|
.order_by(db.asc(MetaPackage.name)) \
|
||||||
.group_by(MetaPackage.id).all()
|
.group_by(MetaPackage.id).all()
|
||||||
return render_template("metapackages/list.html", mpackages=mpackages)
|
return render_template("modnames/list.html", modnames=modnames)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/metapackages/<name>/")
|
@bp.route("/modnames/<name>/")
|
||||||
def view(name):
|
def view(name):
|
||||||
mpackage = MetaPackage.query.filter_by(name=name).first()
|
modname = MetaPackage.query.filter_by(name=name).first()
|
||||||
if mpackage is None:
|
if modname is None:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
dependers = db.session.query(Package) \
|
dependers = db.session.query(Package) \
|
||||||
@ -59,6 +64,6 @@ def view(name):
|
|||||||
.order_by(db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \
|
.order_by(db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
return render_template("metapackages/view.html", mpackage=mpackage,
|
return render_template("modnames/view.html", modname=modname,
|
||||||
dependers=dependers, optional_dependers=optional_dependers,
|
dependers=dependers, optional_dependers=optional_dependers,
|
||||||
similar_topics=similar_topics)
|
similar_topics=similar_topics)
|
@ -370,7 +370,7 @@ def create_edit(author=None, name=None):
|
|||||||
return render_template("packages/create_edit.html", package=package,
|
return render_template("packages/create_edit.html", package=package,
|
||||||
form=form, author=author, enable_wizard=enableWizard,
|
form=form, author=author, enable_wizard=enableWizard,
|
||||||
packages=package_query.all(),
|
packages=package_query.all(),
|
||||||
mpackages=MetaPackage.query.order_by(db.asc(MetaPackage.name)).all(),
|
modnames=MetaPackage.query.order_by(db.asc(MetaPackage.name)).all(),
|
||||||
tabs=get_package_tabs(current_user, package), current_tab="edit")
|
tabs=get_package_tabs(current_user, package), current_tab="edit")
|
||||||
|
|
||||||
|
|
||||||
@ -613,10 +613,10 @@ def share(package):
|
|||||||
@is_package_page
|
@is_package_page
|
||||||
def similar(package):
|
def similar(package):
|
||||||
packages_modnames = {}
|
packages_modnames = {}
|
||||||
for metapackage in package.provides:
|
for mname in package.provides:
|
||||||
packages_modnames[metapackage] = Package.query.filter(Package.id != package.id,
|
packages_modnames[mname] = Package.query.filter(Package.id != package.id,
|
||||||
Package.state != PackageState.DELETED) \
|
Package.state != PackageState.DELETED) \
|
||||||
.filter(Package.provides.any(PackageProvides.c.metapackage_id == metapackage.id)) \
|
.filter(Package.provides.any(PackageProvides.c.metapackage_id == mname.id)) \
|
||||||
.order_by(db.desc(Package.score)) \
|
.order_by(db.desc(Package.score)) \
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
|
@ -143,15 +143,15 @@ def tags_user():
|
|||||||
return redirect(url_for('todo.tags', author=current_user.username))
|
return redirect(url_for('todo.tags', author=current_user.username))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/todo/metapackages/")
|
@bp.route("/todo/modnames/")
|
||||||
@login_required
|
@login_required
|
||||||
def metapackages():
|
def modnames():
|
||||||
mpackages = MetaPackage.query \
|
mnames = MetaPackage.query \
|
||||||
.filter(~ MetaPackage.packages.any(state=PackageState.APPROVED)) \
|
.filter(~ MetaPackage.packages.any(state=PackageState.APPROVED)) \
|
||||||
.filter(MetaPackage.dependencies.any(Dependency.depender.has(state=PackageState.APPROVED), optional=False)) \
|
.filter(MetaPackage.dependencies.any(Dependency.depender.has(state=PackageState.APPROVED), optional=False)) \
|
||||||
.order_by(db.asc(MetaPackage.name)).all()
|
.order_by(db.asc(MetaPackage.name)).all()
|
||||||
|
|
||||||
return render_template("todo/metapackages.html", mpackages=mpackages)
|
return render_template("todo/modnames.html", modnames=mnames)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/user/todo/")
|
@bp.route("/user/todo/")
|
||||||
|
@ -104,7 +104,7 @@ Tokens can be attained by visiting [Settings > API Tokens](/user/tokens/).
|
|||||||
* `name`: Package name.
|
* `name`: Package name.
|
||||||
* `provides`: List of technical mod names inside the package.
|
* `provides`: List of technical mod names inside the package.
|
||||||
* `depends`: List of hard dependencies.
|
* `depends`: List of hard dependencies.
|
||||||
* Each dep will either be a metapackage dependency (`name`), or a
|
* Each dep will either be a modname dependency (`name`), or a
|
||||||
package dependency (`author/name`).
|
package dependency (`author/name`).
|
||||||
* `optional_depends`: list of optional dependencies
|
* `optional_depends`: list of optional dependencies
|
||||||
* Same as above.
|
* Same as above.
|
||||||
|
@ -34,7 +34,7 @@ get_game_support(package):
|
|||||||
return support
|
return support
|
||||||
|
|
||||||
get_meta_package_support(meta):
|
get_meta_package_support(meta):
|
||||||
for package implementing meta package:
|
for package implementing mod name:
|
||||||
support = support OR get_game_support(package)
|
support = support OR get_game_support(package)
|
||||||
|
|
||||||
return support
|
return support
|
||||||
@ -58,9 +58,9 @@ mtg_mod_blacklist = {
|
|||||||
class GameSupportResolver:
|
class GameSupportResolver:
|
||||||
session: sqlalchemy.orm.Session
|
session: sqlalchemy.orm.Session
|
||||||
checked_packages = set()
|
checked_packages = set()
|
||||||
checked_metapackages = set()
|
checked_modnames = set()
|
||||||
resolved_packages: Dict[int, set[int]] = {}
|
resolved_packages: Dict[int, set[int]] = {}
|
||||||
resolved_metapackages: Dict[int, set[int]] = {}
|
resolved_modnames: Dict[int, set[int]] = {}
|
||||||
|
|
||||||
def __init__(self, session):
|
def __init__(self, session):
|
||||||
self.session = session
|
self.session = session
|
||||||
@ -69,14 +69,14 @@ class GameSupportResolver:
|
|||||||
print(f"Resolving for {meta.name}", file=sys.stderr)
|
print(f"Resolving for {meta.name}", file=sys.stderr)
|
||||||
|
|
||||||
key = meta.name
|
key = meta.name
|
||||||
if key in self.resolved_metapackages:
|
if key in self.resolved_modnames:
|
||||||
return self.resolved_metapackages.get(key)
|
return self.resolved_modnames.get(key)
|
||||||
|
|
||||||
if key in self.checked_metapackages:
|
if key in self.checked_modnames:
|
||||||
print(f"Error, cycle found: {','.join(history)}", file=sys.stderr)
|
print(f"Error, cycle found: {','.join(history)}", file=sys.stderr)
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
self.checked_metapackages.add(key)
|
self.checked_modnames.add(key)
|
||||||
|
|
||||||
retval = set()
|
retval = set()
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ class GameSupportResolver:
|
|||||||
|
|
||||||
retval.update(ret)
|
retval.update(ret)
|
||||||
|
|
||||||
self.resolved_metapackages[key] = retval
|
self.resolved_modnames[key] = retval
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def resolve(self, package: Package, history: List[str]) -> set[int]:
|
def resolve(self, package: Package, history: List[str]) -> set[int]:
|
||||||
|
@ -102,7 +102,7 @@ def postReleaseCheckUpdate(self, release: PackageRelease, path):
|
|||||||
package.provides.clear()
|
package.provides.clear()
|
||||||
package.provides.extend(getMetaPackages(tree.getModNames()))
|
package.provides.extend(getMetaPackages(tree.getModNames()))
|
||||||
|
|
||||||
# Delete all meta package dependencies
|
# Delete all mod name dependencies
|
||||||
package.dependencies.filter(Dependency.meta_package != None).delete()
|
package.dependencies.filter(Dependency.meta_package != None).delete()
|
||||||
|
|
||||||
# Get raw dependencies
|
# Get raw dependencies
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
{% macro package_lists() -%}
|
{% macro package_lists() -%}
|
||||||
<script>
|
<script>
|
||||||
meta_packages = [
|
meta_packages = [
|
||||||
{% for m in mpackages %}
|
{% for m in modnames %}
|
||||||
{# This is safe as name can only contain `[a-z0-9_]` #}
|
{# This is safe as name can only contain `[a-z0-9_]` #}
|
||||||
{
|
{
|
||||||
id: "{{ m.name }}",
|
id: "{{ m.name }}",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ _("Meta Packages") }}
|
{{ _("Mod Names") }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -18,11 +18,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for pair in mpackages %}
|
{% for pair in modnames %}
|
||||||
{% set meta = pair[0] %}
|
{% set meta = pair[0] %}
|
||||||
{% set count = pair[1] %}
|
{% set count = pair[1] %}
|
||||||
<a class="list-group-item list-group-item-action"
|
<a class="list-group-item list-group-item-action"
|
||||||
href="{{ url_for('metapackages.view', name=meta.name) }}">
|
href="{{ url_for('modnames.view', name=meta.name) }}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
{{ meta.name }}
|
{{ meta.name }}
|
||||||
@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><i>{{ _("No meta packages found.") }}</i></li>
|
<li><i>{{ _("No mod names found.") }}</i></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,21 +1,21 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ mpackage.name }} - {{ _("Meta Packages") }}
|
{{ modname.name }} - {{ _("Mod Names") }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ _("Meta Package \"%(name)s\"", name=mpackage.name) }}</h1>
|
<h1>{{ _("Mod Name \"%(name)s\"", name=modname.name) }}</h1>
|
||||||
|
|
||||||
<h2>{{ _("Provided By") }}</h2>
|
<h2>{{ _("Provided By") }}</h2>
|
||||||
|
|
||||||
<h3>{{ _("Mods") }}</h3>
|
<h3>{{ _("Mods") }}</h3>
|
||||||
{{ render_pkggrid(mpackage.packages.filter_by(type="MOD", state="APPROVED").all()) }}
|
{{ render_pkggrid(modname.packages.filter_by(type="MOD", state="APPROVED").all()) }}
|
||||||
|
|
||||||
<h3>{{ _("Games") }}</h3>
|
<h3>{{ _("Games") }}</h3>
|
||||||
{{ render_pkggrid(mpackage.packages.filter_by(type="GAME", state="APPROVED").all()) }}
|
{{ render_pkggrid(modname.packages.filter_by(type="GAME", state="APPROVED").all()) }}
|
||||||
|
|
||||||
{% if similar_topics %}
|
{% if similar_topics %}
|
||||||
<h3>{{ _("Forum Topics") }}</h3>
|
<h3>{{ _("Forum Topics") }}</h3>
|
@ -13,8 +13,8 @@
|
|||||||
<p class="text-muted">
|
<p class="text-muted">
|
||||||
{{ _("This package contains modnames that are present in the following packages:") }}
|
{{ _("This package contains modnames that are present in the following packages:") }}
|
||||||
</p>
|
</p>
|
||||||
{% for metapackage, packages in packages_modnames.items() %}
|
{% for modname, packages in packages_modnames.items() %}
|
||||||
<h4>{{ metapackage.name }}</h4>
|
<h4>{{ modname.name }}</h4>
|
||||||
<ul>
|
<ul>
|
||||||
{% for pkg in packages %}
|
{% for pkg in packages %}
|
||||||
<li>
|
<li>
|
||||||
|
@ -398,7 +398,7 @@
|
|||||||
</a>
|
</a>
|
||||||
{% elif dep.meta_package %}
|
{% elif dep.meta_package %}
|
||||||
<a class="badge badge-primary"
|
<a class="badge badge-primary"
|
||||||
href="{{ url_for('metapackages.view', name=dep.meta_package.name) }}">
|
href="{{ url_for('modnames.view', name=dep.meta_package.name) }}">
|
||||||
{{ dep.meta_package.name }}
|
{{ dep.meta_package.name }}
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -421,7 +421,7 @@
|
|||||||
title=dep.package.title, display_name=dep.package.author.display_name) }}
|
title=dep.package.title, display_name=dep.package.author.display_name) }}
|
||||||
{% elif dep.meta_package %}
|
{% elif dep.meta_package %}
|
||||||
<a class="badge badge-secondary"
|
<a class="badge badge-secondary"
|
||||||
href="{{ url_for('metapackages.view', name=dep.meta_package.name) }}">
|
href="{{ url_for('modnames.view', name=dep.meta_package.name) }}">
|
||||||
{{ dep.meta_package.name }}
|
{{ dep.meta_package.name }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ "Expected package or meta_package in dep!" | throw }}
|
{{ "Expected package or meta_package in dep!" | throw }}
|
||||||
@ -507,7 +507,7 @@
|
|||||||
<dt>{{ _("Provides") }}</dt>
|
<dt>{{ _("Provides") }}</dt>
|
||||||
<dd>{% for meta in package.provides %}
|
<dd>{% for meta in package.provides %}
|
||||||
<a class="badge badge-secondary"
|
<a class="badge badge-secondary"
|
||||||
href="{{ url_for('metapackages.view', name=meta.name) }}">{{ meta.name }}</a>
|
href="{{ url_for('modnames.view', name=meta.name) }}">{{ meta.name }}</a>
|
||||||
{% endfor %}</dd>
|
{% endfor %}</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
|
@ -148,10 +148,10 @@
|
|||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ _("Meta packages that have hard dependers, but no packages providing them.") }}
|
{{ _("Mod names that have hard dependers, but no packages providing them.") }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<a class="btn btn-primary" href="{{ url_for('todo.metapackages') }}">
|
<a class="btn btn-primary" href="{{ url_for('todo.modnames') }}">
|
||||||
{{ _("View") }}
|
{{ _("View") }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block title %}
|
|
||||||
Unfulfilled Meta Packages
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h1>Unfulfilled Meta Packages</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Meta packages that have hard dependers, but are not fulfilled.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="list-group">
|
|
||||||
{% for meta in mpackages %}
|
|
||||||
<a class="list-group-item list-group-item-action"
|
|
||||||
href="{{ url_for('metapackages.view', name=meta.name) }}">
|
|
||||||
{{ meta.name }}
|
|
||||||
</a>
|
|
||||||
{% else %}
|
|
||||||
<li><i>No meta packages found.</i></li>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
24
app/templates/todo/modnames.html
Normal file
24
app/templates/todo/modnames.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Unfulfilled Mod Names
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Unfulfilled Mod Names</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Mod names that have hard dependers, but are not fulfilled.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="list-group">
|
||||||
|
{% for meta in modnames %}
|
||||||
|
<a class="list-group-item list-group-item-action"
|
||||||
|
href="{{ url_for('modnames.view', name=meta.name) }}">
|
||||||
|
{{ meta.name }}
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<li><i>No mod names found.</i></li>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user