mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add set up releases wizard
This commit is contained in:
parent
14a67b99ba
commit
c8406b45d4
@ -319,17 +319,6 @@ def create_edit(author=None, name=None):
|
||||
if package.type == PackageType.TXP:
|
||||
package.license = package.media_license
|
||||
|
||||
# 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)
|
||||
|
||||
if wasNew and package.type == PackageType.MOD:
|
||||
m = MetaPackage.GetOrCreate(package.name, {})
|
||||
package.provides.append(m)
|
||||
@ -344,13 +333,14 @@ def create_edit(author=None, name=None):
|
||||
|
||||
db.session.commit() # save
|
||||
|
||||
next_url = package.getDetailsURL()
|
||||
if wasNew and package.repo is not None:
|
||||
task = importRepoScreenshot.delay(package.id)
|
||||
next_url = url_for("tasks.check", id=task.id, r=next_url)
|
||||
importRepoScreenshot.delay(package.id)
|
||||
|
||||
next_url = package.getDetailsURL()
|
||||
if wasNew and ("WTFPL" in package.license.name or "WTFPL" in package.media_license.name):
|
||||
next_url = url_for("flatpage", path="help/wtfpl", r=next_url)
|
||||
elif wasNew:
|
||||
next_url = package.getSetupReleasesURL()
|
||||
|
||||
return redirect(next_url)
|
||||
|
||||
|
@ -252,29 +252,60 @@ def delete_release(package, id):
|
||||
class PackageUpdateConfigFrom(FlaskForm):
|
||||
trigger = SelectField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
|
||||
default=PackageUpdateTrigger.COMMIT)
|
||||
make_release = BooleanField("Create Release")
|
||||
submit = SubmitField("Save")
|
||||
action = SelectField("Action", [InputRequired()], choices=[("notification", "Notification"), ("make_release", "Create Release")], default="make_release")
|
||||
submit = SubmitField("Save Settings")
|
||||
disable = SubmitField("Disable")
|
||||
|
||||
|
||||
@bp.route("/packages/<author>/<name>/update-config/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
@is_package_page
|
||||
def update_config(package):
|
||||
package.update_config = package.update_config or PackageUpdateConfig()
|
||||
|
||||
if not package.checkPerm(current_user, Permission.MAKE_RELEASE):
|
||||
return redirect(package.getDetailsURL())
|
||||
abort(403)
|
||||
|
||||
if not package.repo:
|
||||
flash("Please add a Git repository URL in order to set up automatic releases", "danger")
|
||||
return redirect(package.getEditURL())
|
||||
|
||||
form = PackageUpdateConfigFrom(obj=package.update_config)
|
||||
if request.method == "GET" and package.update_config:
|
||||
form.action.data = "make_release" if package.update_config.make_release else "notification"
|
||||
|
||||
if form.validate_on_submit():
|
||||
flash("Changed update configuration", "success")
|
||||
form.populate_obj(package.update_config)
|
||||
if form.disable.data:
|
||||
flash("Deleted update configuration", "success")
|
||||
if package.update_config:
|
||||
db.session.delete(package.update_config)
|
||||
else:
|
||||
if package.update_config is None:
|
||||
package.update_config = PackageUpdateConfig()
|
||||
db.session.add(package.update_config)
|
||||
|
||||
form.populate_obj(package.update_config)
|
||||
package.update_config.make_release = form.action.data == "make_release"
|
||||
|
||||
check_for_updates.delay()
|
||||
|
||||
db.session.commit()
|
||||
|
||||
if not form.disable.data and package.releases.count() == 0:
|
||||
flash("Now, please create an initial release", "success")
|
||||
return redirect(package.getCreateReleaseURL())
|
||||
|
||||
return redirect(package.getDetailsURL())
|
||||
|
||||
return render_template("packages/update_config.html", package=package, form=form)
|
||||
|
||||
|
||||
@bp.route("/packages/<author>/<name>/setup-releases/")
|
||||
@login_required
|
||||
@is_package_page
|
||||
def setup_releases(package):
|
||||
if not package.checkPerm(current_user, Permission.MAKE_RELEASE):
|
||||
abort(403)
|
||||
|
||||
if package.update_config:
|
||||
return redirect(package.getUpdateConfigURL())
|
||||
|
||||
return render_template("packages/release_wizard.html", package=package)
|
||||
|
@ -514,6 +514,10 @@ class Package(db.Model):
|
||||
return url_for("packages.update_config",
|
||||
author=self.author.username, name=self.name)
|
||||
|
||||
def getSetupReleasesURL(self):
|
||||
return url_for("packages.setup_releases",
|
||||
author=self.author.username, name=self.name)
|
||||
|
||||
def getDownloadURL(self):
|
||||
return url_for("packages.download",
|
||||
author=self.author.username, name=self.name)
|
||||
|
@ -177,10 +177,9 @@
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro render_submit_field(field, label=None, tabindex=None) -%}
|
||||
{% macro render_submit_field(field, label=None, tabindex=None, class_=None) -%}
|
||||
{% if not label %}{% set label=field.label.text %}{% endif %}
|
||||
{#<button type="submit" class="form-control btn btn-default btn-primary">{{label}}</button>#}
|
||||
<input type="submit" value="{{label}}" class="btn btn-primary"
|
||||
{% if tabindex %}tabindex="{{ tabindex }}"{% endif %}
|
||||
>
|
||||
<input type="submit" name="{{ field.name }}" value="{{ label }}" class="{{ class_ or 'btn btn-primary' }}"
|
||||
{% if tabindex %}tabindex="{{ tabindex }}"{% endif %}>
|
||||
{%- endmacro %}
|
||||
|
@ -16,17 +16,15 @@
|
||||
{% set level = "warning" %}
|
||||
{% if package.releases.count() == 0 %}
|
||||
{% set message %}
|
||||
<h4 class="alert-heading">Release Required</h4>
|
||||
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
|
||||
<p>You need to create a release before this package can be approved.</p>
|
||||
<p>
|
||||
A release is a single downloadable version of your {{ package.type.value | lower }}.
|
||||
You need to create releases even if you use a rolling release development cycle,
|
||||
as Minetest needs them to check for updates.
|
||||
</p>
|
||||
<a class="btn" href="{{ package.getCreateReleaseURL() }}">Create Release</a>
|
||||
{% if package.update_config %}
|
||||
<a class="btn btn-sm btn-warning float-right" href="{{ package.getCreateReleaseURL() }}">Create first release</a>
|
||||
{% else %}
|
||||
A release is required before this package can be approved.
|
||||
<a class="btn btn-sm btn-warning float-right" href="{{ package.getSetupReleasesURL() }}">Set up releases</a>
|
||||
{% endif %}
|
||||
{{ _("You need to create a release before this package can be approved.") }}
|
||||
{% else %}
|
||||
{{ _("A release is required before this package can be approved.") }}
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
|
||||
|
@ -1,27 +1,27 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
Create a release | {{ package.title }}
|
||||
{{ _("Create a release") }} - {{ package.title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ _("Create a release") }}</h1>
|
||||
|
||||
{% if not (package.repo and package.update_config) %}
|
||||
<p class="alert alert-info mb-4">
|
||||
<a class="float-right btn btn-sm btn-info" href="{{ url_for('flatpage', path='help/release_webhooks') }}">{{ _("Learn more") }}</a>
|
||||
{% if package.checkPerm(current_user, "APPROVE_RELEASE") and package.getIsOnGitHub() %}
|
||||
<a class="float-right btn btn-sm btn-info mr-2" href="{{ url_for('github.setup_webhook', pid=package.id) }}">{{ _("Setup webhook") }}</a>
|
||||
{% if package.repo %}
|
||||
<a class="float-right btn btn-sm btn-info" href="{{ package.getSetupReleasesURL() }}">{{ _("Set up") }}</a>
|
||||
<i class="fas fa-info mr-2"></i>
|
||||
|
||||
{{ _("Create releases automatically when you push commits or tags to GitHub, using a webhook or the API.") }}
|
||||
{% elif package.repo %}
|
||||
<i class="fas fa-info mr-2"></i>
|
||||
|
||||
{{ _("You can create releases automatically when you push commits or tags to your repository, using a webhook or the API.") }}
|
||||
{{ _("You can create releases automatically when you push commits or tags to your repository.") }}
|
||||
{% else %}
|
||||
<a class="float-right btn btn-sm btn-info" href="{{ package.getEditURL() }}">{{ _("Add Git repo") }}</a>
|
||||
<i class="fas fa-info mr-2"></i>
|
||||
|
||||
{{ _("Using git will allow you to create releases automatically when you push code or tags.") }}
|
||||
{{ _("Using Git would allow you to create releases automatically when you push code or tags.") }}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% from "macros/forms.html" import render_field, render_submit_field, render_radio_field %}
|
||||
<form method="POST" action="" enctype="multipart/form-data">
|
||||
|
46
app/templates/packages/release_wizard.html
Normal file
46
app/templates/packages/release_wizard.html
Normal file
@ -0,0 +1,46 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
{{ _("How do you want to create releases?") }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ self.title() }}</h1>
|
||||
|
||||
<p>
|
||||
{{ _("A release is a single downloadable version of your %(title)s.", title=package.type.value.lower()) }}
|
||||
{{ _("You need to create releases even if you use a rolling release development cycle, as Minetest needs them to check for updates.") }}
|
||||
</p>
|
||||
|
||||
{% if package.repo %}
|
||||
<p>
|
||||
{{ _("When you push a commit or tag to your Git repository, ContentDB can create a new release automatically.") }}
|
||||
{{ _("ContentDB will check your Git repository at 2am UTC every day, but you can use webhooks or the API for faster updates.") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ _("This can be changed later.") }}
|
||||
</p>
|
||||
|
||||
<p class="mt-5">
|
||||
<a class="btn btn-primary" href="{{ package.getUpdateConfigURL() }}">Set up automatic releases</a>
|
||||
<a class="btn btn-secondary ml-2" href="{{ package.getCreateReleaseURL() }}">Create releases manually</a>
|
||||
<a class="btn btn-secondary ml-2" href="{{ package.getDetailsURL() }}">Later</a>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
{{ _("Using Git would allow you to create releases automatically when you push code or tags.") }}
|
||||
{{ _("Unfortunately, you will otherwise need to create a release manually.") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ _("This can be changed later.") }}
|
||||
</p>
|
||||
|
||||
<p class="mt-5">
|
||||
<a class="btn btn-primary" href="{{ package.getEditURL() }}">Add Git repo</a>
|
||||
<a class="btn btn-secondary ml-2" href="{{ package.getCreateReleaseURL() }}">Create releases manually</a>
|
||||
<a class="btn btn-secondary ml-2" href="{{ package.getDetailsURL() }}">Later</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@ -1,29 +1,41 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}
|
||||
Configure Update Detection | {{ package.title }}
|
||||
{{ _("Configure Automatic Releases") }} - {{ package.title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ _("Configure Update Detection") }}</h1>
|
||||
<h1>{{ _("Configure Automatic Releases") }}</h1>
|
||||
|
||||
<p>
|
||||
{{ _("When you push a change to your Git repository, ContentDB can create a new release automatically.") }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{{ _("ContentDB will poll your Git repository at 2am UTC every day.") }}
|
||||
{{ _("You should consider using webhooks or the API for faster rollouts.") }}
|
||||
</p>
|
||||
|
||||
{% if package.checkPerm(current_user, "APPROVE_RELEASE") and package.getIsOnGitHub() %}
|
||||
<p class="alert alert-info mb-4">
|
||||
<a class="float-right btn btn-sm btn-info" href="{{ url_for('flatpage', path='help/release_webhooks') }}">{{ _("Learn more") }}</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>
|
||||
|
||||
{{ _("Create releases faster by using a webhook.") }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
|
||||
<form method="POST" action="">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<h3>Triggers</h3>
|
||||
{{ render_field(form.trigger) }}
|
||||
|
||||
<h3 class="mt-5">Actions</h3>
|
||||
{{ render_checkbox_field(form.make_release) }}
|
||||
{{ render_field(form.trigger, class_="mt-5") }}
|
||||
{{ render_field(form.action) }}
|
||||
|
||||
<p class="mt-5">
|
||||
{{ render_submit_field(form.submit) }}
|
||||
{{ render_submit_field(form.disable, class_="btn btn-secondary ml-2") }}
|
||||
</p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user