From patchwork Sat Dec 7 16:46:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mete Polat X-Patchwork-Id: 1205487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Vb3b017kz9sNx for ; Sun, 8 Dec 2019 03:47:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="C3BNcfDo"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47Vb3Z5wn6zDqRX for ; Sun, 8 Dec 2019 03:47:38 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::329; helo=mail-wm1-x329.google.com; envelope-from=metepolat2000@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="C3BNcfDo"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47Vb315B5hzDqYL for ; Sun, 8 Dec 2019 03:47:09 +1100 (AEDT) Received: by mail-wm1-x329.google.com with SMTP id p9so11049435wmc.2 for ; Sat, 07 Dec 2019 08:47:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nD555JZSGfxTAPQpQkFlnB6j5Co0QbfYtzM8m8MV6Pk=; b=C3BNcfDo203mSKbQMH/5sEsa24I6IRx6mYjJdPC2mm6Y5TapRwOXngRFOdQkxYaHLt ehOjxa0NFjYQYV8eKwwbr0wrm+MY5jl/kH2MLcdNxXQbtAnuj7pGncakbS1xBVmwZnO/ M9uz+hofY8mTWnd86ipgTaV4KZjY3FxtilMaMVrtpoN71lATbAojwDufWy5f+16dkiOe oYZj69PR5BIu7XiK6C5kTU5X4EusRdyMKTBExPohb3l6IT5w7lREumJRzqCHsk5CB5rh kqGm3D04A1Q/0hvk171OqgKgd9qPjV6yDh3nghIa+ATudWyLi6G33DSJRRuMqfvkwl5X 5r+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nD555JZSGfxTAPQpQkFlnB6j5Co0QbfYtzM8m8MV6Pk=; b=bUDBLoNsH3GJtjKfC5x9kK1kSjrSaU17Q2oLRY4fqLD0iJVsEQjDfzeywzO/phXQiz lohVN3V2bnz6RVYPN8S7dLYKFJFSzqmgVDiwbLBJsMA67n1LoGzjwVHoOrbNFL2M5Pxl eN3C1bXgR3wxAlH3yJq28suLkSW2F2wmmshw8hKJUHRUY08JK8RtILiYcKdhFN/c4tOe n5WmAE41TV+dpG5B7QZhAWk2g6dDCCGAFP5G7GUrdTV3RlKVfMwAsC4gTsQzTroHOiHR esK0aBdxapxaUiWvlmJ9yXfogcOVFG0YJQ63E1ozq/n0r4qikjonbaAu+grenm+xy7Re zTDQ== X-Gm-Message-State: APjAAAXc3T6DQpU6nWUz8jgSOHYKyDA7cAqfvYBY+A9pFUmY3repFC2w q/3bniVfNlGVoo5v/8GDZvws5m9G/io= X-Google-Smtp-Source: APXvYqyLBaoL5voNK9dkZuwIF9yL2KYya7o+0s37sj8D5m20aCz7fHdeZrMO6qi5NUVENasf15+5Lg== X-Received: by 2002:a1c:731a:: with SMTP id d26mr15480461wmb.130.1575737224107; Sat, 07 Dec 2019 08:47:04 -0800 (PST) Received: from Metes-MBP.fritz.box (aftr-62-216-202-157.dynamic.mnet-online.de. [62.216.202.157]) by smtp.gmail.com with ESMTPSA id u22sm22083886wru.30.2019.12.07.08.47.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Dec 2019 08:47:03 -0800 (PST) From: Mete Polat To: patchwork@lists.ozlabs.org Subject: [PATCH 2/4] models, templates: Add submission relations Date: Sat, 7 Dec 2019 17:46:19 +0100 Message-Id: <20191207164621.24234-3-metepolat2000@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191207164621.24234-1-metepolat2000@gmail.com> References: <20191207164621.24234-1-metepolat2000@gmail.com> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ralf.ramsauer@oth-regensburg.de Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Introduces the ability to add relations between submissions. Relations are displayed in the details page of a submission under 'Related'. Related submissions located in another projects can be viewed as well. Signed-off-by: Mete Polat --- .../migrations/0038_submission_relations.py | 30 +++++++++++++++ patchwork/models.py | 10 +++++ patchwork/templates/patchwork/submission.html | 37 +++++++++++++++++++ patchwork/views/patch.py | 7 ++++ 4 files changed, 84 insertions(+) create mode 100644 patchwork/migrations/0038_submission_relations.py diff --git a/patchwork/migrations/0038_submission_relations.py b/patchwork/migrations/0038_submission_relations.py new file mode 100644 index 000000000000..4c5274c64c09 --- /dev/null +++ b/patchwork/migrations/0038_submission_relations.py @@ -0,0 +1,30 @@ +# Generated by Django 2.2.6 on 2019-12-08 03:00 + +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 = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('patchwork', '0037_event_actor'), + ] + + operations = [ + migrations.CreateModel( + name='SubmissionRelation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.AddField( + model_name='submission', + name='related', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='submissions', related_query_name='submission', to='patchwork.SubmissionRelation'), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index 7f0efd489ae3..a92203b24ff2 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -374,6 +374,9 @@ class Submission(FilenameMixin, EmailMixin, models.Model): # submission metadata name = models.CharField(max_length=255) + related = models.ForeignKey( + 'SubmissionRelation', null=True, blank=True, on_delete=models.SET_NULL, + related_name='submissions', related_query_name='submission') @property def list_archive_url(self): @@ -863,6 +866,13 @@ class BundlePatch(models.Model): ordering = ['order'] +class SubmissionRelation(models.Model): + by = models.ForeignKey(User, on_delete=models.CASCADE) + + def __str__(self): + return ', '.join(s.name for s in self.submissions.all()) or '' + + @python_2_unicode_compatible class Check(models.Model): diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 77a2711ab5b4..bb0391f98ff4 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -110,6 +110,43 @@ function toggle_div(link_id, headers_id, label_show, label_hide) {% endif %} +{% if submission.related %} + + Related + + show + + + +{% endif %}
diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index f34053ce57da..0480614614ad 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -110,12 +110,19 @@ def patch_detail(request, project_id, msgid): comments = comments.only('submitter', 'date', 'id', 'content', 'submission') + if patch.related: + related_outside = patch.related.submissions \ + .exclude(project=patch.project) + else: + related_outside = [] + context['comments'] = comments context['checks'] = patch.check_set.all().select_related('user') context['submission'] = patch context['patchform'] = form context['createbundleform'] = createbundleform context['project'] = patch.project + context['related_outside'] = related_outside return render(request, 'patchwork/submission.html', context)