Prevent renaming published packages

This commit is contained in:
rubenwardy 2023-10-15 22:13:35 +01:00
parent 4fc54f12bc
commit fc559814d4
2 changed files with 3 additions and 3 deletions

@ -682,9 +682,9 @@ class Package(db.Model):
elif perm == Permission.APPROVE_RELEASE: elif perm == Permission.APPROVE_RELEASE:
return (is_maintainer or is_approver) and user.rank.at_least(UserRank.MEMBER if self.approved else UserRank.NEW_MEMBER) return (is_maintainer or is_approver) and user.rank.at_least(UserRank.MEMBER if self.approved else UserRank.NEW_MEMBER)
# Anyone can change the package name when not approved, but only editors when approved # Anyone can change the package name when not approved
elif perm == Permission.CHANGE_NAME: elif perm == Permission.CHANGE_NAME:
return not self.approved or user.rank.at_least(UserRank.EDITOR) return not self.approved
# Editors can change authors and approve new packages # Editors can change authors and approve new packages
elif perm == Permission.APPROVE_NEW or perm == Permission.CHANGE_AUTHOR: elif perm == Permission.APPROVE_NEW or perm == Permission.CHANGE_AUTHOR:

@ -69,7 +69,7 @@
{{ render_field(form.title, class_="pkg_meta col-sm-5") }} {{ render_field(form.title, class_="pkg_meta col-sm-5") }}
{% if package and package.approved and not package.check_perm(current_user, "CHANGE_NAME") %} {% if package and package.approved and not package.check_perm(current_user, "CHANGE_NAME") %}
{{ render_field(form.name, class_="pkg_meta col-sm-4", {{ render_field(form.name, class_="pkg_meta col-sm-4",
readonly=True, hint=_("Please open a thread to request a name change")) }} readonly=True, hint=_("You need to unpublish the package to change the name.")) }}
{% else %} {% else %}
{{ render_field(form.name, class_="pkg_meta col-sm-4", pattern="[a-z0-9_]+", title=_("Lower case letters (a-z), digits (0-9), and underscores (_) only")) }} {{ render_field(form.name, class_="pkg_meta col-sm-4", pattern="[a-z0-9_]+", title=_("Lower case letters (a-z), digits (0-9), and underscores (_) only")) }}
{% endif %} {% endif %}