'Resolved in' actually sends the relevant version 'under water'

if you have an old screen open which says 'resolved in v1.0' that's what
should happen when you click, even when v2.0 has been seen in the meanwhile
This commit is contained in:
Klaas van Schelven
2024-02-21 18:55:52 +01:00
parent a63157db5e
commit f0e93b4d5d
4 changed files with 18 additions and 8 deletions

View File

@@ -71,10 +71,11 @@ class Issue(models.Model):
def get_events_at(self):
return json.loads(self.events_at)
def add_fixed_at(self, release):
def add_fixed_at(self, release_version):
# release_version: str
fixed_at = self.get_fixed_at()
if release.version not in fixed_at:
fixed_at.append(release.version)
if release_version not in fixed_at:
fixed_at.append(release_version)
self.fixed_at = json.dumps(fixed_at)
def occurs_in_last_release(self):
@@ -105,8 +106,16 @@ class IssueStateManager(object):
@staticmethod
def resolve_by_latest(issue):
# NOTE: currently unused; we may soon reintroduce it though so I left it in.
issue.is_resolved = True
issue.add_fixed_at(issue.project.get_latest_release())
issue.add_fixed_at(issue.project.get_latest_release().version)
IssueStateManager.unmute(issue, implicitly_called=True) # as in IssueStateManager.resolve()
@staticmethod
def resolve_by_release(issue, release_version):
# release_version: str
issue.is_resolved = True
issue.add_fixed_at(release_version)
IssueStateManager.unmute(issue, implicitly_called=True) # as in IssueStateManager.resolve()
@staticmethod

View File

@@ -20,7 +20,7 @@
{% if not issue.occurs_in_last_release %}
{# As an alternative to 'resolved in get_latest' I briefly considered 'resolved in first-after-last-seen'. I settled on "who cares, it's in the margin anyway" #}
{# and if you, as a user, really insist on getting this 100% right you can always be explicit by setting up your CLI integrations #}
<button class="font-bold text-slate-500 border-slate-300 pl-4 pr-4 pb-2 pt-2 ml-1 border-2 hover:bg-cyan-400 active:ring rounded-md" name="action" value="resolved_latest">Resolved in {{ issue.project.get_latest_release.get_short_version }}</button>
<button class="font-bold text-slate-500 border-slate-300 pl-4 pr-4 pb-2 pt-2 ml-1 border-2 hover:bg-cyan-400 active:ring rounded-md" name="action" value="resolved_release:{{ issue.project.get_latest_release.version }}">Resolved in {{ issue.project.get_latest_release.get_short_version }}</button>
{% endif %}
{# 'by next' is even if 'by current' is also shown: just because you haven't seen 'by current' doesn't mean it's actually already solved #}
<button class="font-bold text-slate-800 border-slate-500 pl-4 pr-4 pb-2 pt-2 ml-1 border-2 bg-cyan-200 hover:bg-cyan-400 active:ring rounded-md" name="action" value="resolved_next">Resolved in next release</button>

View File

@@ -32,8 +32,9 @@ def issue_event_detail(request, issue_pk, event_pk):
if request.method == "POST":
if request.POST["action"] == "resolved":
IssueStateManager.resolve(issue)
elif request.POST["action"] == "resolved_latest":
IssueStateManager.resolve_by_latest(issue)
elif request.POST["action"].startswith("resolved_release:"):
release_version = request.POST["action"].split(":", 1)[1]
IssueStateManager.resolve_by_release(issue, release_version)
elif request.POST["action"] == "resolved_next":
IssueStateManager.resolve_by_next(issue)
elif request.POST["action"] == "reopen":

View File

@@ -95,7 +95,7 @@ def create_release_if_needed(project, version):
if release == project.get_latest_release():
for bnr_issue in Issue.objects.filter(project=project, is_resolved_by_next_release=True):
bnr_issue.add_fixed_at(release)
bnr_issue.add_fixed_at(release.version)
bnr_issue.is_resolved_by_next_release = False
bnr_issue.save()