From 906ec3885a5cbb4a562c3c08364f6d58a63839b9 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 1 Sep 2022 22:45:53 +0100 Subject: [PATCH] Rename "Metapackage" to "Mod Name" --- app/blueprints/admin/actions.py | 8 +++---- .../{metapackages => modnames}/__init__.py | 21 +++++++++------- app/blueprints/packages/packages.py | 8 +++---- app/blueprints/todo/__init__.py | 8 +++---- app/flatpages/help/api.md | 2 +- app/logic/game_support.py | 16 ++++++------- app/tasks/importtasks.py | 2 +- app/templates/macros/forms.html | 2 +- .../{metapackages => modnames}/list.html | 8 +++---- .../{metapackages => modnames}/view.html | 8 +++---- app/templates/packages/similar.html | 4 ++-- app/templates/packages/view.html | 6 ++--- app/templates/todo/editor.html | 4 ++-- app/templates/todo/metapackages.html | 24 ------------------- app/templates/todo/modnames.html | 24 +++++++++++++++++++ 15 files changed, 75 insertions(+), 70 deletions(-) rename app/blueprints/{metapackages => modnames}/__init__.py (79%) rename app/templates/{metapackages => modnames}/list.html (79%) rename app/templates/{metapackages => modnames}/view.html (75%) delete mode 100644 app/templates/todo/metapackages.html create mode 100644 app/templates/todo/modnames.html diff --git a/app/blueprints/admin/actions.py b/app/blueprints/admin/actions.py index f2e5394c..8d460c47 100644 --- a/app/blueprints/admin/actions.py +++ b/app/blueprints/admin/actions.py @@ -25,7 +25,7 @@ from sqlalchemy import or_, and_ from app.logic.game_support import GameSupportResolver 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.forumtasks import importTopicList, checkAllForumAccounts 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")) -@action("Delete unused metapackages") -def del_meta_packages(): +@action("Delete unused mod names") +def del_mod_names(): query = MetaPackage.query.filter(~MetaPackage.dependencies.any(), ~MetaPackage.packages.any()) count = query.count() query.delete(synchronize_session=False) 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")) diff --git a/app/blueprints/metapackages/__init__.py b/app/blueprints/modnames/__init__.py similarity index 79% rename from app/blueprints/metapackages/__init__.py rename to app/blueprints/modnames/__init__.py index 3b624aba..caa4f097 100644 --- a/app/blueprints/metapackages/__init__.py +++ b/app/blueprints/modnames/__init__.py @@ -19,22 +19,27 @@ from flask import * from sqlalchemy import func from app.models import MetaPackage, Package, db, Dependency, PackageState, ForumTopic -bp = Blueprint("metapackages", __name__) +bp = Blueprint("modnames", __name__) -@bp.route("/metapackages/") +@bp.route("/metapackages/") +def mp_redirect(path): + return redirect(path.replace("/metapackages/", "/modnames/")) + + +@bp.route("/modnames/") 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) \ .order_by(db.asc(MetaPackage.name)) \ .group_by(MetaPackage.id).all() - return render_template("metapackages/list.html", mpackages=mpackages) + return render_template("modnames/list.html", modnames=modnames) -@bp.route("/metapackages//") +@bp.route("/modnames//") def view(name): - mpackage = MetaPackage.query.filter_by(name=name).first() - if mpackage is None: + modname = MetaPackage.query.filter_by(name=name).first() + if modname is None: abort(404) dependers = db.session.query(Package) \ @@ -59,6 +64,6 @@ def view(name): .order_by(db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \ .all() - return render_template("metapackages/view.html", mpackage=mpackage, + return render_template("modnames/view.html", modname=modname, dependers=dependers, optional_dependers=optional_dependers, similar_topics=similar_topics) diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index d7f1c5d7..948d0b5c 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -370,7 +370,7 @@ def create_edit(author=None, name=None): return render_template("packages/create_edit.html", package=package, form=form, author=author, enable_wizard=enableWizard, 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") @@ -613,10 +613,10 @@ def share(package): @is_package_page def similar(package): packages_modnames = {} - for metapackage in package.provides: - packages_modnames[metapackage] = Package.query.filter(Package.id != package.id, + for mname in package.provides: + packages_modnames[mname] = Package.query.filter(Package.id != package.id, 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)) \ .all() diff --git a/app/blueprints/todo/__init__.py b/app/blueprints/todo/__init__.py index 8e07bb35..cb3d5a92 100644 --- a/app/blueprints/todo/__init__.py +++ b/app/blueprints/todo/__init__.py @@ -143,15 +143,15 @@ def tags_user(): return redirect(url_for('todo.tags', author=current_user.username)) -@bp.route("/todo/metapackages/") +@bp.route("/todo/modnames/") @login_required -def metapackages(): - mpackages = MetaPackage.query \ +def modnames(): + mnames = MetaPackage.query \ .filter(~ MetaPackage.packages.any(state=PackageState.APPROVED)) \ .filter(MetaPackage.dependencies.any(Dependency.depender.has(state=PackageState.APPROVED), optional=False)) \ .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/") diff --git a/app/flatpages/help/api.md b/app/flatpages/help/api.md index bf388100..7b510d17 100644 --- a/app/flatpages/help/api.md +++ b/app/flatpages/help/api.md @@ -104,7 +104,7 @@ Tokens can be attained by visiting [Settings > API Tokens](/user/tokens/). * `name`: Package name. * `provides`: List of technical mod names inside the package. * `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`). * `optional_depends`: list of optional dependencies * Same as above. diff --git a/app/logic/game_support.py b/app/logic/game_support.py index b85661ec..35d9dde9 100644 --- a/app/logic/game_support.py +++ b/app/logic/game_support.py @@ -34,7 +34,7 @@ get_game_support(package): return support get_meta_package_support(meta): - for package implementing meta package: + for package implementing mod name: support = support OR get_game_support(package) return support @@ -58,9 +58,9 @@ mtg_mod_blacklist = { class GameSupportResolver: session: sqlalchemy.orm.Session checked_packages = set() - checked_metapackages = set() + checked_modnames = set() resolved_packages: Dict[int, set[int]] = {} - resolved_metapackages: Dict[int, set[int]] = {} + resolved_modnames: Dict[int, set[int]] = {} def __init__(self, session): self.session = session @@ -69,14 +69,14 @@ class GameSupportResolver: print(f"Resolving for {meta.name}", file=sys.stderr) key = meta.name - if key in self.resolved_metapackages: - return self.resolved_metapackages.get(key) + if key in self.resolved_modnames: + 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) return set() - self.checked_metapackages.add(key) + self.checked_modnames.add(key) retval = set() @@ -94,7 +94,7 @@ class GameSupportResolver: retval.update(ret) - self.resolved_metapackages[key] = retval + self.resolved_modnames[key] = retval return retval def resolve(self, package: Package, history: List[str]) -> set[int]: diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index cd9e66e1..c56ce35e 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -102,7 +102,7 @@ def postReleaseCheckUpdate(self, release: PackageRelease, path): package.provides.clear() package.provides.extend(getMetaPackages(tree.getModNames())) - # Delete all meta package dependencies + # Delete all mod name dependencies package.dependencies.filter(Dependency.meta_package != None).delete() # Get raw dependencies diff --git a/app/templates/macros/forms.html b/app/templates/macros/forms.html index 203e5082..3dd946cd 100644 --- a/app/templates/macros/forms.html +++ b/app/templates/macros/forms.html @@ -66,7 +66,7 @@ {% macro package_lists() -%}