From nobody Sat May 4 21:02:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520501956083736.3286399611404; Thu, 8 Mar 2018 01:39:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C00B83F3D; Thu, 8 Mar 2018 09:39:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1003353B1A; Thu, 8 Mar 2018 09:39:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 07F4F4CA98; Thu, 8 Mar 2018 09:39:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w289dDbE018830 for ; Thu, 8 Mar 2018 04:39:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id DCEDF5C258; Thu, 8 Mar 2018 09:39:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D16D45C259 for ; Thu, 8 Mar 2018 09:39:10 +0000 (UTC) Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9524C5D68C for ; Thu, 8 Mar 2018 09:39:09 +0000 (UTC) Received: by mail-wr0-f194.google.com with SMTP id v111so4967459wrb.3 for ; Thu, 08 Mar 2018 01:39:09 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l33sm2611066wrl.43.2018.03.08.01.39.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 01:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=S6BnVtKUDv9kLiVTS8Vo7X/OgTLw3pXKejOrv/HdRmE=; b=BZY5edkE3Tmz1Ap+CGDaC48wUoFYVf0PK26l2PQ/VVYsEe6xQJg/U9vRIMuMuAeEzy tciABnyq5YjXLAuR6atFchwNpoFcDVPtmhll6gck7hpXDhHMtBb1Dbuy8qHVBv+KcGWm D9tXyvzoLIBfZnX189+8fSLwpl593RaFNEtv4mm0dxddIJIgQJCYdqtvL1AJPLxJpUPi Zrsti4Gz2gGEidZoBIxyOK+yZRJtC617VT3ZbLGvCLxumnxuhirn+ZG5GryA5GVUEjR4 mlK37ocztUh4HEfjUTrLHkQaJJYF2lz9Nny9Jcw9/+fCuGUO5hTikrVY+m5j4MZ2cosS cNrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=S6BnVtKUDv9kLiVTS8Vo7X/OgTLw3pXKejOrv/HdRmE=; b=H7lhq3+w2VdsOOBsItTmv8n7eEb7KCam450jyTucZEMYUZP6G2QTJfgH/JxQvsPGK0 zF8PNr38YyokSE/siitNfi4HJdeBGPz2rS7wegn+dmoMuxsCRCzyh16l88HFz0fnbZJW +6hwgKl/ctFTblD8fr2lPonj1DkcyAwAMsfpLg88q8W4JWZcaLTSJ56tuxNaf3RYrUsQ RV2nBFgsybysg/YcJP6tpZrWYXFgJMWUnGhZrt7fRYZ4t8L3XuMCHR+oXe5xkdUUeB3J KFrHEUua/3qv7xXwPzdUmf2227iFpJhThn8XysL8iugHYi6xgn3iOA9wlZmcfHq54xY0 bWOA== X-Gm-Message-State: APf1xPDrRmEM+BA6ZOKVd8npEYwZXmhnzfA5Wwz4m/UP69Q6Le7O8i6t 0bHRnJnqE1hW3L+etOO3VglSR3Gs X-Google-Smtp-Source: AG47ELsFOJPGvU55Xpf21HcioalOPSkTA8n7fqAw3YbBgdqYhiK9zcF/w8Djnxy11y6UVh7FHNkgNg== X-Received: by 10.223.139.199 with SMTP id w7mr20643245wra.219.1520501947836; Thu, 08 Mar 2018 01:39:07 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 8 Mar 2018 10:39:04 +0100 Message-Id: <20180308093906.28593-2-pbonzini@redhat.com> In-Reply-To: <20180308093906.28593-1-pbonzini@redhat.com> References: <20180308093906.28593-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Mar 2018 09:39:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Mar 2018 09:39:09 +0000 (UTC) for IP:'209.85.128.194' DOMAIN:'mail-wr0-f194.google.com' HELO:'mail-wr0-f194.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.194 mail-wr0-f194.google.com 209.85.128.194 mail-wr0-f194.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 1/3] add forgotten migration X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 08 Mar 2018 09:39:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This was not committed by mistake when adding the parent projects. Signed-off-by: Paolo Bonzini --- api/migrations/0023_auto_20180308_0810.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 api/migrations/0023_auto_20180308_0810.py diff --git a/api/migrations/0023_auto_20180308_0810.py b/api/migrations/002= 3_auto_20180308_0810.py new file mode 100644 index 0000000..ad930c2 --- /dev/null +++ b/api/migrations/0023_auto_20180308_0810.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-03-08 08:10 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0022_project_parent_project'), + ] + + operations =3D [ + migrations.AlterField( + model_name=3D'project', + name=3D'parent_project', + field=3Dmodels.ForeignKey(blank=3DTrue, help_text=3D'Parent pr= oject which this\n project belongs to= . The parent must be a\n top project = which has\n parent_project=3DNULL', n= ull=3DTrue, on_delete=3Ddjango.db.models.deletion.CASCADE, to=3D'api.Projec= t'), + ), + ] --=20 2.14.3 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sat May 4 21:02:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520501956086762.3665255295712; Thu, 8 Mar 2018 01:39:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A77C80F95; Thu, 8 Mar 2018 09:39:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C5035C258; Thu, 8 Mar 2018 09:39:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 133304CA9A; Thu, 8 Mar 2018 09:39:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w289dEPE018836 for ; Thu, 8 Mar 2018 04:39:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7B9655D6B7; Thu, 8 Mar 2018 09:39:14 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7450D5D6A8 for ; Thu, 8 Mar 2018 09:39:12 +0000 (UTC) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0508280F90 for ; Thu, 8 Mar 2018 09:39:11 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id m12so4944752wrm.13 for ; Thu, 08 Mar 2018 01:39:10 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l33sm2611066wrl.43.2018.03.08.01.39.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 01:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=drLGmupTkrQkFywAkVW2wQQs/EeNLOs/On8c3YDExwo=; b=DcSEzaGO7vL2J6D+tQGSOmLIGlM4Va3XS6AiZwtBcjGoTEQ0mQGXxIfs6ExhfL4VoS Mx6ItPiB4jY+w1VlcJyj6hV1kZ2nJ7CZCdNozSWkBz3DkyF1vC5hJHqWDm+pTc+FAlhc l+z0ba2ss/79eYSI8KSl0QkUN2MxE/PwQgWHo0LOMX7usltzLkXglCssCXfLZK124azs vOQnvzoOzo0tTAvyijCyT4Q4fJo039k1531UW++qS9yAg5eyrdEaK3+3cLBGPpT4Ns7a wxp+Nf0pdfEHskRvj0Q1J3SOTwI/ujgq0hPo99uITgjcFslRUHesp6fA9Qk7NoisJW4V ftsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=drLGmupTkrQkFywAkVW2wQQs/EeNLOs/On8c3YDExwo=; b=GDvraho15vm+r0v5PGK9JKBCRXalQD1/XhwAyr8pEwrNG1ooIYcPxdkLzq7o4R3ZAK aKG1KkRUJIY5/W0Ks5LHmp33iHQ8xgjsX4NfrINekQ3bzHVF6Ww6KRMbZxzXrm36gFZT Tgka45N4k+Tu+oQnXIb0QeP9C9kyV+ZPX+IrbwTmd7Ps8Afr3Jmg9xN5Sn8jzbJl5Q4C /sWoLv7C2HVXRMdLR+7CbNgbDBR9hvwmBQO6kEMVyA4luhaYA8ZAGoaSx19/Xn8BFfT5 dUjEAPf0t+ftWW2UZ/ld/vUKEqRKJUpbi77CMU96ilghL8wvL2+3OMpovZmVCOIT0kLy TX9w== X-Gm-Message-State: APf1xPCUixytCgiO8pK8AxmhpeP9R50du4W8c4DaE41nEFmpkffRHryd wQL1s7O6MAPQlOQ3xMp5CorKPsLh X-Google-Smtp-Source: AG47ELvroM1OSBzrtydIDN0tTGmkj2dK3HXNJ5geaOA15NzWNaD4DjzR+zYDJQYl/lLDfqxrBnK5KA== X-Received: by 10.223.197.1 with SMTP id q1mr20918552wrf.268.1520501949137; Thu, 08 Mar 2018 01:39:09 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 8 Mar 2018 10:39:05 +0100 Message-Id: <20180308093906.28593-3-pbonzini@redhat.com> In-Reply-To: <20180308093906.28593-1-pbonzini@redhat.com> References: <20180308093906.28593-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 08 Mar 2018 09:39:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 08 Mar 2018 09:39:11 +0000 (UTC) for IP:'209.85.128.195' DOMAIN:'mail-wr0-f195.google.com' HELO:'mail-wr0-f195.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.195 mail-wr0-f195.google.com 209.85.128.195 mail-wr0-f195.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 2/3] change "maintainer" from property to many-to-many relation X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 08 Mar 2018 09:39:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is the only property that is used by the Patchew core rather than the plugins. Having it as a relation makes it a bit easier to associates users with projects in the admin. (I tested the migration both ways with a local database). Signed-off-by: Paolo Bonzini --- api/admin.py | 1 + api/migrations/0024_project_maintainers.py | 22 +++++++++ .../0025_populate_project_maintainers.py | 52 ++++++++++++++++++= ++++ api/models.py | 4 +- tests/patchewtest.py | 2 + tests/test_project.py | 20 ++++++++- 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 api/migrations/0024_project_maintainers.py create mode 100644 api/migrations/0025_populate_project_maintainers.py diff --git a/api/admin.py b/api/admin.py index a595751..c7ca190 100644 --- a/api/admin.py +++ b/api/admin.py @@ -18,6 +18,7 @@ class ProjectPropertyInline(admin.TabularInline): extra =3D 0 =20 class ProjectAdmin(admin.ModelAdmin): + filter_horizontal =3D ('maintainers',) inlines =3D [ ProjectPropertyInline ] diff --git a/api/migrations/0024_project_maintainers.py b/api/migrations/00= 24_project_maintainers.py new file mode 100644 index 0000000..986d7f6 --- /dev/null +++ b/api/migrations/0024_project_maintainers.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-03-08 08:15 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies =3D [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('api', '0023_auto_20180308_0810'), + ] + + operations =3D [ + migrations.AddField( + model_name=3D'project', + name=3D'maintainers', + field=3Dmodels.ManyToManyField(blank=3DTrue, to=3Dsettings.AUT= H_USER_MODEL), + ), + ] diff --git a/api/migrations/0025_populate_project_maintainers.py b/api/migr= ations/0025_populate_project_maintainers.py new file mode 100644 index 0000000..e029e70 --- /dev/null +++ b/api/migrations/0025_populate_project_maintainers.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +from django.db.models import Count +import json + + +def maintainers_from_property(apps, schema_editor): + # We can't import the models directly as they may be a newer + # version than this migration expects. We use the historical version. + Project =3D apps.get_model('api', 'Project') + ProjectProperty =3D apps.get_model('api', 'ProjectProperty') + User =3D apps.get_model('auth', 'User') + projects =3D Project.objects.filter(projectproperty__name=3D'maintaine= rs') + for p in projects: + p.maintainers.clear() + pp =3D p.projectproperty_set.filter(name=3D'maintainers')[0] + # NOTE: this will fail if the property is a blob + maintainers =3D json.loads(pp.value) + users =3D User.objects.filter(username__in=3Dmaintainers) + p.maintainers.add(*users) + ProjectProperty.objects.filter(name=3D'maintainers').delete() + +def maintainers_to_property(apps, schema_editor): + # We can't import the models directly as they may be a newer + # version than this migration expects. We use the historical version. + Project =3D apps.get_model('api', 'Project') + ProjectProperty =3D apps.get_model('api', 'ProjectProperty') + User =3D apps.get_model('auth', 'User') + projects =3D Project.objects. \ + annotate(maintainer_count=3DCount('maintainers')). \ + filter(maintainer_count__gt=3D0) + for p in projects: + maintainers =3D [u.username for u in p.maintainers.all()] + pp =3D ProjectProperty(project=3Dp, + name=3D'maintainers', + value=3Djson.dumps(maintainers), + blob=3DFalse) + pp.save() + p.maintainers.clear() + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0024_project_maintainers'), + ] + + operations =3D [ + migrations.RunPython(maintainers_from_property, + reverse_code=3Dmaintainers_to_property), + ] diff --git a/api/models.py b/api/models.py index 0c8688a..180d6e3 100644 --- a/api/models.py +++ b/api/models.py @@ -75,6 +75,7 @@ class Project(models.Model): project belongs to. The parent must= be a top project which has parent_project=3DNULL""") + maintainers =3D models.ManyToManyField(User,blank=3DTrue) =20 def __str__(self): return self.name @@ -125,7 +126,8 @@ class Project(models.Model): def maintained_by(self, user): if user.is_superuser: return True - if user.username in self.get_property("maintainers", []): + if self.maintainers.filter(id=3Duser.id).exists() or \ + self.get_property("maintainers", []): return True return False =20 diff --git a/tests/patchewtest.py b/tests/patchewtest.py index 00ecddb..1b0a867 100644 --- a/tests/patchewtest.py +++ b/tests/patchewtest.py @@ -55,6 +55,7 @@ class PatchewTestCase(django.test.LiveServerTestCase): user =3D User.objects.create_superuser(username or self.user, self.email, password or self.password) + return user =20 def create_user(self, username=3DNone, password=3DNone, groups=3D[]): user =3D User.objects.create_user(username or self.user, @@ -63,6 +64,7 @@ class PatchewTestCase(django.test.LiveServerTestCase): if groups: user.groups =3D [Group.objects.get_or_create(name=3Dg)[0] for = g in groups] user.save() + return user =20 def cli(self, argv): """Run patchew-cli command and return (retcode, stdout, stderr)""" diff --git a/tests/test_project.py b/tests/test_project.py index 63ca709..25b9661 100755 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -15,7 +15,7 @@ from patchewtest import PatchewTestCase, main class ProjectTest(PatchewTestCase): =20 def setUp(self): - self.create_superuser() + self.admin_user =3D self.create_superuser() =20 def test_empty(self): projects =3D self.get_projects() @@ -61,5 +61,23 @@ class ProjectTest(PatchewTestCase): self.assertNotEqual(r, 0) self.assertNotEqual(b, "") =20 + def test_maintainers(self): + p =3D self.add_project("TestProject") + u1 =3D self.create_user(username=3D'buddy', password=3D'abc') + u2 =3D self.create_user(username=3D'mirage', password=3D'def') + u2.is_staff =3D True + u2.save() + p.maintainers.add(u1) + self.assertTrue(p.maintained_by(self.admin_user)) + self.assertTrue(p.maintained_by(u1)) + self.assertFalse(p.maintained_by(u2)) + p.maintainers.add(u2) + self.assertTrue(p.maintained_by(u1)) + self.assertTrue(p.maintained_by(u2)) + p.maintainers.clear() + self.assertTrue(p.maintained_by(self.admin_user)) + self.assertFalse(p.maintained_by(u1)) + self.assertFalse(p.maintained_by(u2)) + if __name__ =3D=3D '__main__': main() --=20 2.14.3 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sat May 4 21:02:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520501958107220.11160406099566; Thu, 8 Mar 2018 01:39:18 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DBD1C057FA1; Thu, 8 Mar 2018 09:39:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31D026134A; Thu, 8 Mar 2018 09:39:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 264341808850; Thu, 8 Mar 2018 09:39:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w289dGFd018865 for ; Thu, 8 Mar 2018 04:39:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6186B60F87; Thu, 8 Mar 2018 09:39:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C7E89F74 for ; Thu, 8 Mar 2018 09:39:13 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E4135AFC4 for ; Thu, 8 Mar 2018 09:39:12 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id m12so4944811wrm.13 for ; Thu, 08 Mar 2018 01:39:11 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l33sm2611066wrl.43.2018.03.08.01.39.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 01:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=7L348JoCRH8DnUkwoUZg3SR4DLb9f3y6xG5Hg1IMm/4=; b=IcfEIZ9Ob49EcX3qrzcOcxb6QMYZ4zhP90s4GTMbbIhk5uT28hX1LkVxD9pDT+DViU NOPdEyvvwkdPxk7ELow70g2j8uOarvVQ1pVOCP4n2oQaMVs/ZUZpwH47vDNqPtNWXYQU LWuckETV3GIqyNBdA9z+F+IRfi7gKRHi87VH3tXNILuS1Qv7YuGE0rCgETNM5Ds/4dle l/JA+Lqj60/Lhf8vdNSrlkZo7bEdedXZZLUhm4L2DIHaZBqPR1yJsi8sFomb9LynFtQP FqTCHxYGRJQlz4QfjCNzJ5vq7OmNXU5RVHNHJ+tLonsqHzb1rbKreaxO6+Zzb8UGt7tP Pg1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=7L348JoCRH8DnUkwoUZg3SR4DLb9f3y6xG5Hg1IMm/4=; b=H1oyCm/YKQJDVVTMH/v9hrmFVBR787p64d3ADCa2LliXyXq6U7+3QvocBSmOdmrK+R QyAdo/tASh7iRd5tEd/LPbi/EHe+G1M/yoiQZp/G8K3eu4KriOGN3jQ9SryjWmYEXB9f CC1v7f5hKk9r/5W0PelztfJHufLXpVcWrC8Dd+b3KD7Q4hCq41rOdTilJFzhSOeAS/cn Mss4Y6v6E1/qDh6gkyjOeRmseXeRCSBsd/oDZrc8XvstNtKHXbGYBAO754GVwgNC40Nk U96e5mzLQgnZUAEsOxNBNXvBoY5tBRY1TNqqqaLZY8PUd5XWxaknvwIn9SmIIkUyhbHx Ry1A== X-Gm-Message-State: APf1xPARhf6bqH9PKm/XIHZE3v1up3ZztR0VteK7e92KbDFoiHU/5UD9 ZuNKvQ87I76MYIA+8SO/aw1LiGy1 X-Google-Smtp-Source: AG47ELsLpM3SLpYKw06NkqT3CckhV4qpaAZ/2slGpo8PkC9+mKVYNdqxDico9wvnUkToNUYx/Veitg== X-Received: by 10.223.171.6 with SMTP id q6mr23436882wrc.267.1520501950371; Thu, 08 Mar 2018 01:39:10 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 8 Mar 2018 10:39:06 +0100 Message-Id: <20180308093906.28593-4-pbonzini@redhat.com> In-Reply-To: <20180308093906.28593-1-pbonzini@redhat.com> References: <20180308093906.28593-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Mar 2018 09:39:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 08 Mar 2018 09:39:12 +0000 (UTC) for IP:'209.85.128.196' DOMAIN:'mail-wr0-f196.google.com' HELO:'mail-wr0-f196.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.488 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.196 mail-wr0-f196.google.com 209.85.128.196 mail-wr0-f196.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 3/3] drop maintainers property X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 08 Mar 2018 09:39:17 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is not needed after the database is migrated to the new format. Signed-off-by: Paolo Bonzini --- api/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/models.py b/api/models.py index 180d6e3..f663783 100644 --- a/api/models.py +++ b/api/models.py @@ -126,8 +126,7 @@ class Project(models.Model): def maintained_by(self, user): if user.is_superuser: return True - if self.maintainers.filter(id=3Duser.id).exists() or \ - self.get_property("maintainers", []): + if self.maintainers.filter(id=3Duser.id).exists(): return True return False =20 --=20 2.14.3 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel