Improve wizard behaviour

This commit is contained in:
rubenwardy 2021-01-29 22:54:14 +00:00
parent f49da74c3a
commit 3dde8c05ad
3 changed files with 10 additions and 6 deletions

@ -251,7 +251,7 @@ def delete_release(package, id):
class PackageUpdateConfigFrom(FlaskForm):
trigger = SelectField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
default=PackageUpdateTrigger.COMMIT)
default=PackageUpdateTrigger.TAG)
ref = StringField("Branch name", [Optional()], default=None)
action = SelectField("Action", [InputRequired()], choices=[("notification", "Notification"), ("make_release", "Create Release")], default="make_release")
submit = SubmitField("Save Settings")
@ -270,8 +270,12 @@ def update_config(package):
return redirect(package.getEditURL())
form = PackageUpdateConfigFrom(obj=package.update_config)
if request.method == "GET" and package.update_config:
if request.method == "GET":
if package.update_config:
form.action.data = "make_release" if package.update_config.make_release else "notification"
elif request.args.get("action") == "notification":
form.trigger.data = PackageUpdateTrigger.COMMIT
form.action.data = "notification"
if form.validate_on_submit():
if form.disable.data:

@ -513,9 +513,9 @@ class Package(db.Model):
return url_for("packages.bulk_change_release",
author=self.author.username, name=self.name)
def getUpdateConfigURL(self):
def getUpdateConfigURL(self, action=None):
return url_for("packages.update_config",
author=self.author.username, name=self.name)
author=self.author.username, name=self.name, action=action)
def getSetupReleasesURL(self):
return url_for("packages.setup_releases",

@ -24,7 +24,7 @@
<p class="mt-5">
<a class="btn btn-primary" href="{{ package.getUpdateConfigURL() }}">Automatically</a>
<a class="btn btn-secondary ml-2" href="{{ package.getUpdateConfigURL() }}">Manually, enable reminders</a>
<a class="btn btn-secondary ml-2" href="{{ package.getUpdateConfigURL(action="notification") }}">Manually, enable reminders</a>
<a class="btn btn-secondary ml-2" href="{{ package.getCreateReleaseURL() }}">Manually, no reminders</a>
<a class="btn btn-secondary ml-2" href="{{ package.getDetailsURL() }}">Later</a>
</p>