Improve outdated messages

This commit is contained in:
rubenwardy 2021-01-30 16:48:11 +00:00
parent 36dc51ef4a
commit 3b213889ca
3 changed files with 23 additions and 17 deletions

@ -973,3 +973,21 @@ class PackageUpdateConfig(db.Model):
def set_outdated(self):
self.outdated_at = datetime.datetime.utcnow()
def get_message(self):
if self.trigger == PackageUpdateTrigger.COMMIT:
msg = "New commit {} found on the Git repo.".format(self.last_commit[0:5])
else:
msg = "New tag {} found on the Git repo.".format(self.last_tag)
last_release = self.package.releases.first()
if last_release and last_release.commit_hash:
msg += " The last release was commit {}".format(last_release.commit_hash[0:5])
return msg
def get_create_release_url(self):
title = self.last_tag or self.outdated_at.strftime("%Y-%m-%d")
ref = self.last_tag or self.last_commit
return self.package.getCreateReleaseURL(title=title, ref=ref)

@ -22,12 +22,8 @@
{% set action = "Make release" if config.make_release else "Notification" %}
{{ _("On %(trigger)s, do %(action)s", trigger=config.trigger.value, action=action) }}
{% else %}
{% if config.trigger == config.trigger.TAG and config.last_tag %}
{{ _("New tag: %(tag)s", tag=config.last_tag) }}
{% else %}
{{ _("Git repo has commit %(ref)s", ref=config.last_commit[0:5]) }}
{% endif %}
<span class="text-muted ml-3">
{{ config.get_message() }}<br />
<span class="text-muted">
{{ config.outdated_at | datetime }}
</span>
{% endif %}
@ -35,10 +31,8 @@
<div class="col-sm-auto">
{% if not show_config %}
{% set release_title = config.last_tag or (config.outdated_at | isodate) %}
{% if package.checkPerm(current_player, "MAKE_RELEASE") %}
<a class="btn btn-sm btn-primary mr-2"
href="{{ package.getCreateReleaseURL(title=release_title, ref=config.last_tag or config.last_commit) }}">
<a class="btn btn-sm btn-primary mr-2" href="{{ config.get_create_release_url() }}">
<i class="fas fa-plus mr-1"></i>
{{ _("Release") }}
</a>

@ -181,20 +181,14 @@
<b>Package may be outdated</b>
</p>
<p class="mt-0 my-1">
{% if config.trigger == config.trigger.TAG and config.last_tag %}
{{ _("New tag: %(tag)s.", tag=config.last_tag) }}
{% else %}
{{ _("Git repo has commit %(ref)s.", ref=config.last_commit[0:5]) }}
{% endif %}
{{ config.get_message() }}
</p>
<p class="mt-0 my-1" style="font-size: 80%; opacity: 85%;">
<i class="fas fa-lock mr-1"></i>
{{ _("Only visible to the author and Editors.") }}
</p>
<div class="btn-group btn-group-sm my-0">
{% set release_title = config.last_tag or (config.outdated_at | isodate) %}
<a class="btn btn-warning"
href="{{ package.getCreateReleaseURL(title=release_title, ref=config.last_tag or config.last_commit) }}">
<a class="btn btn-warning" href="{{ config.get_create_release_url() }}">
<i class="fas fa-plus mr-1"></i>
{{ _("Release") }}
</a>