Commit 9943ab2c authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

Present series state to the user

Include information that series is not complete (i.e. we have received
less patches than expected, basing on the [xx/yy] tag) and that series
looks "strange" (i.e. ordering may is off or we have got too many
patches).

Changes in logic:
If we get more patches than expected, *do not* reset status to
incomplete series, we've got the event for queued already anyway.
Just consider it "strange".

Also, let's include information which revision we are rerunning on the
rerun button.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent a7535e38
Pipeline #10348 canceled with stage
......@@ -630,10 +630,37 @@ class SeriesRevision(models.Model):
order=order)
sp.save()
revision_complete = self.patches.count() == self.n_patches
if revision_complete:
if self.patches_count == self.n_patches:
series_revision_complete.send(sender=self.__class__, revision=self)
@property
def patches_count(self):
return self.patches.count()
@property
def is_complete(self):
return self.patches_count >= self.n_patches
@property
def is_strange(self):
if self.patches_count > self.n_patches:
return True
names = [patch.name for patch in self.ordered_patches()]
# one patch "series", not much to break
if len(names) == 1:
return False
for index, name in enumerate(names):
match = re.search(r"\[(\d+)/(\d+)\]", name)
if not match: # we have a patch without proper numbering
return True
if (index + 1) != int(match.group(1)): # numbering is off
return True
return False
def duplicate_meta(self):
new = SeriesRevision.objects.get(pk=self.pk)
new.pk = None
......@@ -899,8 +926,7 @@ def _revision_update_state(revision):
} for s in summary]
# revision not yet complete
revision_complete = revision.patches.count() == revision.n_patches
if not revision_complete:
if not revision.is_complete:
revision.state = RevisionState.INCOMPLETE
# initial state
......
......@@ -50,7 +50,7 @@ $(document).ready(function() {
{% block body %}
<h1>{{ series.name }}</h1>
=
<div class="core-info">
<span>Submitted by {{ series.submitter|personify:project }} on {{ series.submitted }}</span>
</div>
......@@ -97,10 +97,17 @@ $(document).ready(function() {
<div id="retest-latest-container" class="btn-group" style="float: right;"
data-disabled-title="You have to be logged in and be the submitter or the project maintainer.">
{% if series.last_revision %}
<button class="btn btn-info" id="retest-latest"
data-series="{{ series.id }}" data-revision="{{ series.last_revision.version }}">
test latest revision again
test revision {{ series.last_revision.version }} again
</button>
{% else %}
<button class="btn btn-danger disabled" id="retest-latest"
data-series="{{ series.id }}" data-revision="{{ series.last_revision.version }}">
no complete revisions to test!
</button>
{% endif %}
</div>
<ul class="nav nav-pills small-pills" data-tabs="tabs" role="tablist">
......@@ -120,6 +127,16 @@ $(document).ready(function() {
<div class="alert alert-info">
<strong>THIS SERIES REVISION IS A RERUN.</strong> Please don't overuse the "test again" button.
</div>
{% endif %}
{% if not revision.is_complete %}
<div class="alert alert-danger">
<strong>SERIES REVISION IS NOT COMPLETE.</strong> We've got {{ revision.patches_count }} out of {{ revision.n_patches }} expected patches.
</div>
{% elif revision.is_strange %}
<div class="alert alert-warning">
<strong>SERIES REVISION LOOKS STRANGE.</strong> Please double-check patch list and the ordering before proceeding.
</div>
{% endif %}
<h3>Patches <a href="{% url 'seriesrevision-mbox' series.pk revision.version %}" >download mbox</a></h3>
......
......@@ -110,6 +110,61 @@ class GeneratedSeriesTest(SeriesTest):
return (series, mails)
class RevisionStatus(GeneratedSeriesTest):
@property
def series(self):
return Series.objects.all()[0]
@property
def last_revision(self):
return list(self.series.revisions())[-1]
def setUp(self):
(self.test_series, self.mails) = self._create_series(3)
def testFreshSeriesWithoutAllMailsShouldNotBeComple(self):
self.test_series.insert(self.mails[:-2])
self.assertFalse(self.last_revision.is_complete)
self.assertFalse(self.last_revision.is_strange)
def testSeriesWithAllMailsShouldBeComplete(self):
self.test_series.insert(self.mails)
self.assertTrue(self.last_revision.is_complete)
self.assertFalse(self.last_revision.is_strange)
def testSeriesWithExtraEmailShouldBeCompleteAndStrange(self):
extra = self.test_series.create_patch(self.test_series.n_patches + 1,
in_reply_to=self.mails[0])
self.test_series.insert(self.mails)
self.test_series.insert([extra])
self.assertTrue(self.last_revision.is_complete)
self.assertTrue(self.last_revision.is_strange)
def testSeriesWithExtraEmailShouldNotCreateNewCompletionEvent(self):
extra = self.test_series.create_patch(self.test_series.n_patches + 1,
in_reply_to=self.mails[0])
self.test_series.insert(self.mails)
event_count = EventLog.objects.all().count()
self.test_series.insert([extra])
self.assertEquals(EventLog.objects.all().count(), event_count)
def testSeriesWithWrongOrderingShouldBeCompleteAndStrange(self):
# replace patch 1/3 with a patch that is numbered 2/3
extra = self.test_series.create_patch(2, self.mails[1])
self.test_series.insert(self.mails)
self.test_series.insert([extra])
self.assertTrue(self.last_revision.is_complete)
self.assertTrue(self.last_revision.is_strange)
class BasicGeneratedSeriesTests(GeneratedSeriesTest):
def testInsertion(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment