From patchwork Sat Nov 25 23:11:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 295 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost.localdomain [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 8F4E4199DBFA for ; Sat, 25 Nov 2017 23:11:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-BL-Results: [127.0.9.2] [127.0.0.10] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Sat, 25 Nov 2017 23:11:37 +0000 (UTC) Received: from orion.archlinux.org (localhost.localdomain [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id DF511777C3DBF; Sat, 25 Nov 2017 23:11:34 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Sat, 25 Nov 2017 23:11:34 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id B9D032C078; Sat, 25 Nov 2017 23:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1511651494; bh=KY6YQyrGBIuiwCyxxFjU2B8Q2HBnHaLDE7U0EESAz7I=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=tK7RQtViX4Qdy2TTEwBSSL/PujnomdHdd5Hr3IJ/cJys1upPJw4Aw70+Af8VHeuBU YUNwIQOpP4psEhob6p6wEzLZG5xy8yfnYZKfFNV4pKrV6T7AX+PTFSOiorCd2tKHbC V8uCBkj6IRQD2OII6nl00Px0NWchtw1IM1HPv+Ml01KVbfNk0dR0YKnu9ybs4em1Yo fypSOJnzlcStiAinT3x7fkKAoOABGWVkW5SMXwwnvxzi/sozPHi/9xxIuxTCffwIIC wIVGrkXJnJFRltqe0+vutwxJoH0wXDS9C84dnMVVTGuQPP0rr08HobYfITXKway8gi 6tInDgmZKYTpOk09YBJWi6MDby4j+/thKslbtWZsfyxkk8xhixvlLD8+a+BiEIdq40 iOVtoYYhXwcB9tV2zpLAJRu54KunN/zUdr1iFgSdCKCWAouFGAEW/IidIudw5wah7T g68JcTZQgJ3eKe/QmUbspKdLoDs0+Cdty3n6V0NwBgP/LeGGv32Ftwl2ExA7JQF620 8LRowUPkVFwDBJUsgdmZ/5bLipnUpUubhJXl/0EEaiD4Gm6fDQIsWYrWNilQ5yciCI wih7wdhEfIhfCTSRMNxYzCc00AM63xYdp0THQeueb5vgN5NNasfMesE+7Bk+KyttiH SLmBaH45z6xaoNgqzlHdZboo= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 04E5A2C07D for ; Sat, 25 Nov 2017 23:11:32 +0000 (UTC) Received: from theos.kyriasis.com (theos.kyriasis.com [IPv6:2a01:7e00::f03c:91ff:fe6e:f996]) by luna.archlinux.org (Postfix) with ESMTPS for ; Sat, 25 Nov 2017 23:11:31 +0000 (UTC) Received: from theos.kyriasis.com (localhost [127.0.0.1]) by theos.kyriasis.com (OpenSMTPD) with ESMTP id 56f42741 for ; Sat, 25 Nov 2017 23:11:31 +0000 (UTC) Received: from zorg.kyriasis.com (81-236-0-220-no61.tbcn.telia.com [81.236.0.220]) by theos.kyriasis.com (OpenSMTPD) with ESMTPSA id a43329f0 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Sat, 25 Nov 2017 23:11:26 +0000 (UTC) To: arch-projects@lists.archlinux.org Date: Sun, 26 Nov 2017 00:11:15 +0100 Message-Id: <20171125231115.27917-1-johannes@kyriasis.com> X-Mailer: git-send-email 2.15.0 MIME-Version: 1.0 Subject: [arch-projects] [archweb] [PATCH] Return different dep types under different keys in JSON results X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: =?utf-8?q?Johannes_L=C3=B6thberg_via_arch-projects?= Reply-To: Arch Linux projects development discussion Cc: =?utf-8?q?Johannes_L=C3=B6thberg?= Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" Signed-off-by: Johannes Löthberg --- packages/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/utils.py b/packages/utils.py index 0f47f17..5e533b7 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -478,7 +478,7 @@ class PackageJSONEncoder(DjangoJSONEncoder): 'installed_size', 'build_date', 'last_update', 'flag_date', 'maintainers', 'packager'] pkg_list_attributes = ['groups', 'licenses', 'conflicts', - 'provides', 'replaces', 'depends'] + 'provides', 'replaces'] def default(self, obj): if hasattr(obj, '__iter__'): @@ -488,6 +488,10 @@ def default(self, obj): data = {attr: getattr(obj, attr) for attr in self.pkg_attributes} for attr in self.pkg_list_attributes: data[attr] = getattr(obj, attr).all() + all_deps = obj.depends.all() + for (deptype, name) in [('D', 'depends'), ('O', 'optdepends'), + ('M', 'makedepends'), ('C', 'checkdepends')]: + data[name] = all_deps.filter(deptype=deptype) return data if isinstance(obj, PackageFile): filename = obj.filename or ''