diff --git a/app/blueprints/api/endpoints.py b/app/blueprints/api/endpoints.py index 4836fe0f..083b2f7a 100644 --- a/app/blueprints/api/endpoints.py +++ b/app/blueprints/api/endpoints.py @@ -103,10 +103,11 @@ def resolve_package_deps(out, package, only_hard, depth=1): elif dep.meta_package: name = dep.meta_package.name - fulfilled_by = [ pkg.getId() for pkg in dep.meta_package.packages] + fulfilled_by = [ pkg.getId() for pkg in dep.meta_package.packages if pkg.state == PackageState.APPROVED] if depth == 1 and not dep.optional: - most_likely = next((pkg for pkg in dep.meta_package.packages if pkg.type == PackageType.MOD), None) + most_likely = next((pkg for pkg in dep.meta_package.packages \ + if pkg.type == PackageType.MOD and pkg.state == PackageState.APPROVED), None) if most_likely: resolve_package_deps(out, most_likely, only_hard, depth + 1) diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index db234f05..b24a3e01 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -21,7 +21,7 @@ from flask import render_template from flask_babel import lazy_gettext, gettext from flask_wtf import FlaskForm from flask_login import login_required -from sqlalchemy import or_, func +from sqlalchemy import or_, func, and_ from sqlalchemy.orm import joinedload, subqueryload from wtforms import * from wtforms_sqlalchemy.fields import QuerySelectField, QuerySelectMultipleField @@ -123,7 +123,7 @@ def view(package): if show_similar and package.type != PackageType.TXP: conflicting_modnames = db.session.query(MetaPackage.name) \ .filter(MetaPackage.id.in_([ mp.id for mp in package.provides ])) \ - .filter(MetaPackage.packages.any(Package.id != package.id)) \ + .filter(MetaPackage.packages.any(and_(Package.id != package.id, Package.state == PackageState.APPROVED))) \ .all() conflicting_modnames += db.session.query(ForumTopic.name) \ @@ -298,14 +298,14 @@ def create_edit(author=None, name=None): if form.validate_on_submit(): wasNew = False - if not package: + if package is None: package = Package.query.filter_by(name=form["name"].data, author_id=author.id).first() if package is not None: - if package.state == PackageState.READY_FOR_REVIEW: + if package.state == PackageState.DELETED: Package.query.filter_by(name=form["name"].data, author_id=author.id).delete() else: flash(gettext("Package already exists!"), "danger") - return redirect(url_for("packages.create_edit")) + return redirect(package.getURL("packages.view")) package = Package() package.author = author diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index 4872aac2..292b87cc 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -100,7 +100,7 @@ - {{ user.packages.count() }} + {{ user.packages.filter_by(state='APPROVED').count() }} {{ _("packages") }}