Set default git reference in create release form to None

This commit is contained in:
rubenwardy 2020-12-04 01:43:20 +00:00
parent 78630b3071
commit 2b06bca015
3 changed files with 40 additions and 15 deletions

View File

@ -45,7 +45,7 @@ def get_mt_releases(is_max):
class CreatePackageReleaseForm(FlaskForm): class CreatePackageReleaseForm(FlaskForm):
title = StringField("Title", [InputRequired(), Length(1, 30)]) title = StringField("Title", [InputRequired(), Length(1, 30)])
uploadOpt = RadioField ("Method", choices=[("upload", "File Upload")], default="upload") uploadOpt = RadioField ("Method", choices=[("upload", "File Upload")], default="upload")
vcsLabel = StringField("VCS Commit Hash, Branch, or Tag", default="master") vcsLabel = StringField("Git reference (ie: commit hash, branch, or tag)", default=None)
fileUpload = FileField("File Upload") fileUpload = FileField("File Upload")
min_rel = QuerySelectField("Minimum Minetest Version", [InputRequired()], min_rel = QuerySelectField("Minimum Minetest Version", [InputRequired()],
query_factory=lambda: get_mt_releases(False), get_pk=lambda a: a.id, get_label=lambda a: a.name) query_factory=lambda: get_mt_releases(False), get_pk=lambda a: a.id, get_label=lambda a: a.name)
@ -74,7 +74,7 @@ def create_release(package):
# Initial form class from post data and default data # Initial form class from post data and default data
form = CreatePackageReleaseForm() form = CreatePackageReleaseForm()
if package.repo is not None: if package.repo is not None:
form["uploadOpt"].choices = [("vcs", "From Git Commit or Branch"), ("upload", "File Upload")] form["uploadOpt"].choices = [("vcs", "Import from Git"), ("upload", "Upload .zip file")]
if request.method != "POST": if request.method != "POST":
form["uploadOpt"].data = "vcs" form["uploadOpt"].data = "vcs"

View File

@ -41,6 +41,8 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<h3 class="mt-5">Supported Minetest versions</h3>
<div class="row"> <div class="row">
{{ render_field(form.min_rel, class_="col-sm-6") }} {{ render_field(form.min_rel, class_="col-sm-6") }}
{{ render_field(form.max_rel, class_="col-sm-6") }} {{ render_field(form.max_rel, class_="col-sm-6") }}
@ -51,14 +53,19 @@
</p> </p>
<p> <p>
Note: Min and max versions will be used to hide the package on Set the minimum and maximum Minetest versions supported.
platforms not within the range. This release will be hidden to clients outside of that range.<br />
You cannot select the oldest version for min or the newest version
for max as this does not make sense - you can't predict the future.<br />
Leave both as None if in doubt. Leave both as None if in doubt.
You can <a href="/help/package_config/">set this automatically</a> in the .conf of your package.
</p>
<p>
You cannot select the oldest version for min or the newest version
for max as this does not make sense - you can't predict the future.
</p> </p>
{{ render_submit_field(form.submit) }} <p class="mt-5">
{{ render_submit_field(form.submit) }}
</p>
</form> </form>
<h2 class="mt-5">{{ _("Delete Release") }}</h2> <h2 class="mt-5">{{ _("Delete Release") }}</h2>

View File

@ -11,11 +11,11 @@
<a class="float-right btn btn-sm btn-info mr-2" href="{{ url_for('github.setup_webhook', pid=package.id) }}">{{ _("Setup webhook") }}</a> <a class="float-right btn btn-sm btn-info mr-2" href="{{ url_for('github.setup_webhook', pid=package.id) }}">{{ _("Setup webhook") }}</a>
<i class="fas fa-info mr-2"></i> <i class="fas fa-info mr-2"></i>
{{ _("Set up a webhook on GitHub to create releases automatically.") }} {{ _("Create releases automatically when you push commits or tags to GitHub, using a webhook or the API.") }}
{% elif package.repo %} {% elif package.repo %}
<i class="fas fa-info mr-2"></i> <i class="fas fa-info mr-2"></i>
{{ _("You can create releases automatically when you push commits or tags to your repository.") }} {{ _("You can create releases automatically when you push commits or tags to your repository, using a webhook or the API.") }}
{% else %} {% else %}
<i class="fas fa-info mr-2"></i> <i class="fas fa-info mr-2"></i>
@ -27,16 +27,28 @@
<form method="POST" action="" enctype="multipart/form-data"> <form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
<h3>1. Name release</h3>
{{ render_field(form.title, placeholder="Human readable. Eg: 1.0.0 or 2018-05-28") }} {{ render_field(form.title, placeholder="Human readable. Eg: 1.0.0 or 2018-05-28") }}
<h3 class="mt-5">2. Set the content</h3>
<p class="mb-0">Method</p> <p class="mb-0">Method</p>
{{ render_radio_field(form.uploadOpt) }} {{ render_radio_field(form.uploadOpt) }}
{% if package.repo %} {% if package.repo %}
{{ render_field(form.vcsLabel, class_="mt-3") }} {{ render_field(form.vcsLabel, placeholder="Leave blank to use default branch", class_="mt-3") }}
{% endif %} {% endif %}
{{ render_field(form.fileUpload, fieldclass="form-control-file", class_="mt-3", accept=".zip") }} {{ render_field(form.fileUpload, fieldclass="form-control-file", class_="mt-3", accept=".zip") }}
<p>
Take a look at the <a href="/help/package_config/">Package Configuration and Releases Guide</a> for
tips on customising releases.
</p>
<h3 class="mt-5">3. Supported Minetest versions</h3>
<div class="row"> <div class="row">
{{ render_field(form.min_rel, class_="col-sm-6") }} {{ render_field(form.min_rel, class_="col-sm-6") }}
{{ render_field(form.max_rel, class_="col-sm-6") }} {{ render_field(form.max_rel, class_="col-sm-6") }}
@ -47,15 +59,21 @@
</p> </p>
<p> <p>
Note: Min and max versions will be used to hide the package on Set the minimum and maximum Minetest versions supported.
platforms not within the range. This release will be hidden to clients outside of that range.<br />
You cannot select the oldest version for min or the newest version
for max as this does not make sense - you can't predict the future.<br />
Leave both as None if in doubt. Leave both as None if in doubt.
You can <a href="/help/package_config/">set this automatically</a> in the .conf of your package.
</p>
<p>
You cannot select the oldest version for min or the newest version
for max as this does not make sense - you can't predict the future.
</p> </p>
{{ render_submit_field(form.submit) }} <p class="mt-5">
{{ render_submit_field(form.submit) }}
</p>
</form> </form>
{% endblock %} {% endblock %}
{% block scriptextra %} {% block scriptextra %}