diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index 9f35c4f9..37136fc9 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -458,6 +458,11 @@ def translation(package): @login_required @is_package_page def remove(package): + if not package.check_perm(current_user, Permission.EDIT_PACKAGE): + abort(403) + + states = [PackageDevState.AS_IS, PackageDevState.DEPRECATED, PackageDevState.LOOKING_FOR_MAINTAINER] + if request.method == "GET": # Find packages that will having missing hard deps after this action broken_meta = MetaPackage.query.filter(MetaPackage.packages.contains(package), @@ -467,9 +472,19 @@ def remove(package): Package.dependencies.any( and_(Dependency.meta_package_id.in_([x.id for x in broken_meta]), Dependency.optional == False))).all() - return render_template("packages/remove.html", package=package, hard_deps=hard_deps, + return render_template("packages/remove.html", + package=package, hard_deps=hard_deps, states=states, tabs=get_package_tabs(current_user, package), current_tab="remove") + for state in states: + if state.name in request.form: + flash(gettext("Set state to %(state)s", state=state.title), "success") + package.dev_state = state + msg = "Set dev state of {} to {}".format(package.title, state.title) + add_audit_log(AuditSeverity.NORMAL, current_user, msg, package.get_url("packages.view"), package) + db.session.commit() + return redirect(package.get_url("packages.view")) + reason = request.form.get("reason") or "?" if len(reason) > 500: abort(400) diff --git a/app/models/packages.py b/app/models/packages.py index 661be166..59990f4a 100644 --- a/app/models/packages.py +++ b/app/models/packages.py @@ -112,6 +112,10 @@ class PackageDevState(enum.Enum): def __str__(self): return self.name + @property + def title(self): + return self.value + def get_desc(self): if self == PackageDevState.WIP: return "Under active development, and may break worlds/things without warning" diff --git a/app/templates/packages/remove.html b/app/templates/packages/remove.html index 35640189..bd8f0a10 100644 --- a/app/templates/packages/remove.html +++ b/app/templates/packages/remove.html @@ -1,12 +1,37 @@ {% extends "packages/package_base.html" %} {% block title %} -Remove {{ package.title }} +{{ _("Remove %(title)s", title=package.title) }} {% endblock %} {% block content %} +

{{ self.title() }}

+
-

{{ _("Remove %(title)s", title=package.title) }}

+

{{ _("Change maintenance state") }}

+

+ {{ _("As an alternative to removing your package, you may wish to change the maintenance state.") }} +

+ + +

+ {% for state in states %} + + {% endfor %} +

+
+ +
+

{{ _("Remove") }}

{{ _("In order to avoid data loss, you cannot permanently delete packages. You can remove them from ContentDB, which will cause them to not be