From: Mete Polat <metepolat2...@gmail.com> Introduces the ability to add relations between patches. Relations are displayed in the details page of a patch. Therefore the previous 'related' row containing a list of other patches in the series has been combined with the directly above listed series name row. Related patches that are located in another projects are additionally noted.
Patch relations can be used for example for browsing different revisions of a patch. Signed-off-by: Mete Polat <metepolat2...@gmail.com> --- htdocs/css/style.css | 2 +- patchwork/migrations/0037_patch_relations.py | 28 +++++++++++ patchwork/models.py | 13 +++++ patchwork/templates/patchwork/submission.html | 47 ++++++++++++++----- 4 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 patchwork/migrations/0037_patch_relations.py diff --git a/htdocs/css/style.css b/htdocs/css/style.css index fe4ce7c..ec16904 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -192,7 +192,7 @@ table.patchmeta tr th, table.patchmeta tr td { vertical-align: top; } -.patchrelations ul { +.patchgroup ul { list-style-type: none; padding: 0; margin: 0; diff --git a/patchwork/migrations/0037_patch_relations.py b/patchwork/migrations/0037_patch_relations.py new file mode 100644 index 0000000..a7a1074 --- /dev/null +++ b/patchwork/migrations/0037_patch_relations.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.3 on 2019-09-05 18:07 + +import datetime +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import patchwork.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('patchwork', '0036_project_commit_url_format'), + ] + + operations = [ + migrations.CreateModel( + name='PatchRelation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + migrations.AddField( + model_name='patch', + name='related', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='patches', related_query_name='patch', to='patchwork.PatchRelation'), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index 32d1b3c..e547eb6 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -436,6 +436,12 @@ class Patch(Submission): default=None, null=True, help_text='The number assigned to this patch in the series') + # related patches metadata + + related = models.ForeignKey( + 'PatchRelation', null=True, blank=True, on_delete=models.SET_NULL, + related_name='patches', related_query_name='patch') + objects = PatchManager() @staticmethod @@ -832,6 +838,13 @@ class BundlePatch(models.Model): ordering = ['order'] +class PatchRelation(models.Model): + + def __str__(self): + return ', '.join(patch.name for patch in self.patches.all()) or \ + '<Empty>' + + @python_2_unicode_compatible class Check(models.Model): diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index e79dd92..599fa2d 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -72,18 +72,12 @@ function toggle_div(link_id, headers_id) <tr> <th>Series</th> <td> - <a href="{% url 'patch-list' project_id=project.linkname %}?series={{ submission.series.id }}"> - {{ submission.series }} - </a> - </td> - </tr> - <tr> - <th>Related</th> - <td> - <a id="togglepatchrelations" - href="javascript:toggle_div('togglepatchrelations', 'patchrelations')" - >show</a> - <div id="patchrelations" class="patchrelations" style="display:none;"> + <span style="width: 35px; display: inline-block"> + <a id="togglepatchseries" + href="javascript:toggle_div('togglepatchseries', 'patchseries')" + >show</a> + </span> {{ submission.series }} + <div id="patchseries" class="patchgroup" style="display:none;"> <ul> {% with submission.series.cover_letter as cover %} <li> @@ -110,6 +104,35 @@ function toggle_div(link_id, headers_id) </li> {% endfor %} </ul> + <a style="margin-top: 4px; display: inline-block" + href="{% url 'patch-list' project_id=project.linkname %}?series={{ submission.series.id }}" + >Overview</a> + </div> + </td> + </tr> +{% endif %} +{% if submission.related %} + <tr> + <th>Related</th> + <td> + <a id="togglepatchrelations" + href="javascript:toggle_div('togglepatchrelations', 'patchrelations')" + >show</a> + <div id="patchrelations" class="patchgroup" style="display:none;"> + <ul> + {% for sibling in submission.related.patches.all %} + <li> + {% if sibling != submission %} + <a href="{% url 'patch-detail' patch_id=sibling.id %}"> + {{ sibling.name|default:"[no subject]"|truncatechars:100 }} + </a> + {% if sibling.project != submission.project %} + (in {{ sibling.project }}) + {% endif %} + {% endif %} + </li> + {% endfor %} + </ul> </div> </td> </tr> -- 2.20.1 (Apple Git-117) _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork