mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-10 15:07:35 +01:00
Remove provides/dependencies from Package form
This commit is contained in:
parent
b8ee612b45
commit
68524adadf
@ -231,11 +231,10 @@ class PackageForm(FlaskForm):
|
||||
type = SelectField("Type", [InputRequired()], choices=PackageType.choices(), coerce=PackageType.coerce, default=PackageType.MOD)
|
||||
license = QuerySelectField("License", [DataRequired()], allow_blank=True, query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||
media_license = QuerySelectField("Media License", [DataRequired()], allow_blank=True, query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
|
||||
provides_str = StringField("Provides (mods included in package)", [Optional()])
|
||||
tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=makeLabel)
|
||||
content_warnings = QuerySelectMultipleField('Content Warnings', query_factory=lambda: ContentWarning.query.order_by(db.asc(ContentWarning.name)), get_pk=lambda a: a.id, get_label=makeLabel)
|
||||
harddep_str = StringField("Hard Dependencies", [Optional()])
|
||||
softdep_str = StringField("Soft Dependencies", [Optional()])
|
||||
# harddep_str = StringField("Hard Dependencies", [Optional()])
|
||||
# softdep_str = StringField("Soft Dependencies", [Optional()])
|
||||
repo = StringField("VCS Repository URL", [Optional(), URL()], filters = [lambda x: x or None])
|
||||
website = StringField("Website URL", [Optional(), URL()], filters = [lambda x: x or None])
|
||||
issueTracker = StringField("Issue Tracker URL", [Optional(), URL()], filters = [lambda x: x or None])
|
||||
@ -285,9 +284,8 @@ def create_edit(author=None, name=None):
|
||||
form.license.data = None
|
||||
form.media_license.data = None
|
||||
else:
|
||||
form.harddep_str.data = ",".join([str(x) for x in package.getSortedHardDependencies() ])
|
||||
form.softdep_str.data = ",".join([str(x) for x in package.getSortedOptionalDependencies() ])
|
||||
form.provides_str.data = MetaPackage.ListToSpec(package.provides)
|
||||
# form.harddep_str.data = ",".join([str(x) for x in package.getSortedHardDependencies() ])
|
||||
# form.softdep_str.data = ",".join([str(x) for x in package.getSortedOptionalDependencies() ])
|
||||
form.tags.data = list(package.tags)
|
||||
form.content_warnings.data = list(package.content_warnings)
|
||||
|
||||
@ -326,25 +324,19 @@ def create_edit(author=None, name=None):
|
||||
if package.type == PackageType.TXP:
|
||||
package.license = package.media_license
|
||||
|
||||
mpackage_cache = {}
|
||||
package.provides.clear()
|
||||
mpackages = MetaPackage.SpecToList(form.provides_str.data, mpackage_cache)
|
||||
for m in mpackages:
|
||||
package.provides.append(m)
|
||||
# Dependency.query.filter_by(depender=package).delete()
|
||||
# deps = Dependency.SpecToList(package, form.harddep_str.data, mpackage_cache)
|
||||
# for dep in deps:
|
||||
# dep.optional = False
|
||||
# db.session.add(dep)
|
||||
|
||||
Dependency.query.filter_by(depender=package).delete()
|
||||
deps = Dependency.SpecToList(package, form.harddep_str.data, mpackage_cache)
|
||||
for dep in deps:
|
||||
dep.optional = False
|
||||
db.session.add(dep)
|
||||
# deps = Dependency.SpecToList(package, form.softdep_str.data, mpackage_cache)
|
||||
# for dep in deps:
|
||||
# dep.optional = True
|
||||
# db.session.add(dep)
|
||||
|
||||
deps = Dependency.SpecToList(package, form.softdep_str.data, mpackage_cache)
|
||||
for dep in deps:
|
||||
dep.optional = True
|
||||
db.session.add(dep)
|
||||
|
||||
if wasNew and package.type == PackageType.MOD and not package.name in mpackage_cache:
|
||||
m = MetaPackage.GetOrCreate(package.name, mpackage_cache)
|
||||
if wasNew and package.type == PackageType.MOD:
|
||||
m = MetaPackage.GetOrCreate(package.name, {})
|
||||
package.provides.append(m)
|
||||
|
||||
package.tags.clear()
|
||||
|
@ -165,7 +165,6 @@ class User(db.Model, UserMixin):
|
||||
# Content
|
||||
notifications = db.relationship("Notification", primaryjoin="User.id==Notification.user_id")
|
||||
|
||||
# causednotifs = db.relationship("Notification", backref="causer", lazy="dynamic")
|
||||
packages = db.relationship("Package", backref=db.backref("author", lazy="joined"), lazy="dynamic")
|
||||
requests = db.relationship("EditRequest", backref="author", lazy="dynamic")
|
||||
threads = db.relationship("Thread", backref="author", lazy="dynamic")
|
||||
@ -743,7 +742,7 @@ class Package(db.Model):
|
||||
elif perm == Permission.MAKE_RELEASE or perm == Permission.ADD_SCREENSHOTS:
|
||||
return isMaintainer
|
||||
|
||||
elif perm == Permission.EDIT_PACKAGE or perm == Permission.REIMPORT_META or \
|
||||
elif perm == Permission.EDIT_PACKAGE or \
|
||||
perm == Permission.APPROVE_CHANGES or perm == Permission.APPROVE_RELEASE:
|
||||
return isMaintainer and user.rank.atLeast(UserRank.MEMBER if self.approved else UserRank.NEW_MEMBER)
|
||||
|
||||
@ -767,6 +766,9 @@ class Package(db.Model):
|
||||
elif perm == Permission.CHANGE_RELEASE_URL:
|
||||
return user.rank.atLeast(UserRank.MODERATOR)
|
||||
|
||||
elif perm == Permission.REIMPORT_META:
|
||||
return user.rank.atLeast(UserRank.ADMIN)
|
||||
|
||||
else:
|
||||
raise Exception("Permission {} is not related to packages".format(perm.name))
|
||||
|
||||
|
@ -30,14 +30,13 @@ $(function() {
|
||||
|
||||
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
|
||||
setField("#name", result.name);
|
||||
setField("#provides_str", result.provides);
|
||||
setField("#title", result.title);
|
||||
setField("#repo", result.repo || repoURL);
|
||||
setField("#issueTracker", result.issueTracker);
|
||||
setField("#desc", result.description);
|
||||
setField("#short_desc", result.short_description);
|
||||
setField("#harddep_str", result.depends);
|
||||
setField("#softdep_str", result.optional_depends);
|
||||
// setField("#harddep_str", result.depends);
|
||||
// setField("#softdep_str", result.optional_depends);
|
||||
setField("#short_desc", result.short_description);
|
||||
setField("#forums", result.forumId);
|
||||
if (result.type && result.type.length > 2) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
{% if enable_wizard %}
|
||||
<script src="/static/url.min.js"></script>
|
||||
<script src="/static/polltask.js"></script>
|
||||
<script src="/static/package_create.js?v=3"></script>
|
||||
<script src="/static/package_create.js?v=4"></script>
|
||||
{% endif %}
|
||||
<script src="/static/package_edit.js?v=3"></script>
|
||||
{% endblock %}
|
||||
@ -81,12 +81,17 @@
|
||||
<fieldset class="pkg_meta">
|
||||
<legend class="not_txp">{{ _("Dependencies") }}</legend>
|
||||
|
||||
{{ render_mpackage_field(form.provides_str, class_="not_txp", placeholder="Comma separated list") }}
|
||||
{{ render_deps_field(form.harddep_str, class_="not_txp not_game", placeholder="Comma separated list") }}
|
||||
{{ render_deps_field(form.softdep_str, class_="not_txp not_game", placeholder="Comma separated list") }}
|
||||
<p class="alert alert-secondary not_txp">
|
||||
<span class="fas fa-info pr-1"></span>
|
||||
|
||||
{{ _("Note: This information is now updated automatically when creating a release.") }}
|
||||
</p>
|
||||
|
||||
{# {{ render_deps_field(form.harddep_str, class_="not_txp not_game", placeholder="Comma separated list") }}
|
||||
{{ render_deps_field(form.softdep_str, class_="not_txp not_game", placeholder="Comma separated list") }} #}
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<fieldset class="mt-4">
|
||||
<legend class="pkg_meta">{{ _("Repository and Links") }}</legend>
|
||||
|
||||
<div class="pkg_wiz_1">
|
||||
|
Loading…
Reference in New Issue
Block a user