From patchwork Mon Aug 23 18:28:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1519913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Z7QL9wVS; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GtgkZ1VWRz9sWS for ; Tue, 24 Aug 2021 04:29:26 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GtgkZ0JJnz2yJS for ; Tue, 24 Aug 2021 04:29:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Z7QL9wVS; dkim-atps=neutral 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=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::74a; helo=mail-qk1-x74a.google.com; envelope-from=33-gjyqukcva9sfw3y66y3w.u647sbuze69230aba.6h3sta.69y@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Z7QL9wVS; dkim-atps=neutral Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) (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 4Gtgjt4rHbz2xfx for ; Tue, 24 Aug 2021 04:28:50 +1000 (AEST) Received: by mail-qk1-x74a.google.com with SMTP id e22-20020a05620a209600b003d5ff97bff7so8814630qka.1 for ; Mon, 23 Aug 2021 11:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3hvG3j6DNgGxDO5MuX2ew6doHO5uZVcfED4myevbfcI=; b=Z7QL9wVSZ0cKNtTxQ6pRtgi+56iYWTJFhf0ud2YpzZ5kVo+w1HtgIASSzy6p+t3TD/ NJCTYk0Rt6hpff9k+twCIwgANrUadVDl47s4WBzsesBMsrkzTQ/5gLza/ca4joJV8iYx /xXl6LbSJKqigDjeplyegvq1rZkZhDYGk11Cg4eOlcAO0IQmCE9oTGmyc7cVcA0fMBkW pcBsKe640sIa+zE1chw/AvL7lHxCGUm9ZhFe8jIHDbhGjdaYc3jNfVPeQxBmk8+ItDNx mSvsr8U0M7LzXmXBUax4ilhq8JL6FFMlg9W2x0gVVwN+svvgd+xtNXhvP/5vX5Dn76eR kzPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3hvG3j6DNgGxDO5MuX2ew6doHO5uZVcfED4myevbfcI=; b=jIoUIJuiNDHdaIb0gFTiibIOA1t16wEVB+/prG+9EVvTPWVtAzYflRrLuNKVHAT3A6 KliYSfJKSbhU6PXo4CvrUUEyEvIEoF5VTkGxhP9BBeKSD4+QRu/Yv77ydavBozbwVhTG 9P2GmunNf8ElmrTdebkrzq8fKbp47SA9tmqsyfovRdaFh9OEYRNJ3G1vqrKhq5HaG4cT aqwpNvYuIjWuwvWnDxunrggSYJyfC6x2dlznn/9UxhTQC3RQesir3cwpMHV46L8jLrZf 2PEOMtj28a7I7WF0URE9Q5/PerJzjP0CcAUFcpiuMAgte7dzlk3ThK7jILn6Zo0cd6kB hMqQ== X-Gm-Message-State: AOAM532GdrQjDFVr+UGNLi/17K3Dlrr+QR9IF/f0WNPGlkcIdIrR7I60 e5TBALf7I0/rvhMG0mBPM19VmA2v/pjX1jXJDNMGZysQWAtUuCGY9GJvnQGoFjiwYqKl4AFdbUS wN3rH6pFS/1OXtLk4t8RQqOxz57aFto3HQF/PVaoaZgkm+7yNTnOI/NddTGOJGijF X-Google-Smtp-Source: ABdhPJz65rDalVUh/rrhccWDrPW4Naj1XJHFXl0UkA63iKvS2irWEcTXQ9Vk0P18nCtOl7dALZjz5sYQbg== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:ad4:5bc8:: with SMTP id t8mr34274582qvt.18.1629743327987; Mon, 23 Aug 2021 11:28:47 -0700 (PDT) Date: Mon, 23 Aug 2021 18:28:33 +0000 In-Reply-To: <20210823182833.3976100-1-raxel@google.com> Message-Id: <20210823182833.3976100-6-raxel@google.com> Mime-Version: 1.0 References: <20210823182833.3976100-1-raxel@google.com> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog Subject: [PATCH v4 5/5] patch-list: add inline dropdown for delegate and state one-off changes From: Raxel Gutierrez To: patchwork@lists.ozlabs.org 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: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Add dropdown for the cell values of the Delegate and State columns for each individual patch to make one-off changes to patches. The dropdowns are only viewable if the user has patch edit permissions. Change the generic_list method to pass the list of states and maintainers to the patch list view context to populate the dropdown options. The static patch-list.js file now uses the modularity of the fetch request and update/error messages handling of rest.js. TODO: The loading of the patch-list page is very slow now because it seems that for each call to check if a patch is editable by a user, the db is accessed. Changes in the backend need to be made so this is done with only done with only one call to the db. Signed-off-by: Raxel Gutierrez --- htdocs/README.rst | 6 +++ htdocs/js/patch-list.js | 52 ++++++++++++++++++- .../patchwork/partials/patch-list.html | 35 +++++++++++-- patchwork/views/__init__.py | 6 +++ 4 files changed, 94 insertions(+), 5 deletions(-) diff --git a/htdocs/README.rst b/htdocs/README.rst index 6c435124..32550119 100644 --- a/htdocs/README.rst +++ b/htdocs/README.rst @@ -133,6 +133,12 @@ js Part of Patchwork. +``patch-list.js.`` + Event helpers and other application logic for patch-list.html. These + support patch list manipulation (e.g. inline dropdown changes). + + Part of Patchwork. + ``selectize.min.js`` Selectize is the hybrid of a ``textbox`` and `` + {% if not patch.delegate.username %} + + {% else %} + + {% endif %} + {% for maintainer in maintainers %} + + {% endfor %} + + {% else %} + {{ patch.delegate.username }} + {% endif %} + + + {% if patch.is_editable %} + + {% else %} + {{ patch.state }} + {% endif %} + {% empty %} diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 5da8046d..d41c4609 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -16,6 +16,7 @@ from patchwork.models import Bundle from patchwork.models import BundlePatch from patchwork.models import Patch from patchwork.models import Project +from patchwork.models import State from patchwork.models import Check from patchwork.paginator import Paginator @@ -177,6 +178,8 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, 'project': project, 'projects': Project.objects.all(), 'filters': filters, + 'maintainers': project.maintainer_project.all(), + 'states': State.objects.all(), } # pagination @@ -287,6 +290,9 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, Prefetch('check_set', queryset=Check.objects.only( 'context', 'user_id', 'patch_id', 'state', 'date'))) + for patch in patches: + patch.is_editable = patch.is_editable(user) + paginator = Paginator(request, patches) context.update({