Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1516052/?format=api
{ "id": 1516052, "url": "http://patchwork.ozlabs.org/api/patches/1516052/?format=api", "web_url": "http://patchwork.ozlabs.org/project/patchwork/patch/20210811213705.36293-13-stephen@that.guru/", "project": { "id": 16, "url": "http://patchwork.ozlabs.org/api/projects/16/?format=api", "name": "Patchwork", "link_name": "patchwork", "list_id": "patchwork.lists.ozlabs.org", "list_email": "patchwork@lists.ozlabs.org", "web_url": "http://jk.ozlabs.org/projects/patchwork/", "scm_url": "git://github.com/getpatchwork/patchwork", "webscm_url": "https://github.com/getpatchwork/patchwork", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20210811213705.36293-13-stephen@that.guru>", "list_archive_url": null, "date": "2021-08-11T21:36:58", "name": "[RFC,12/19] view: Simplify user opt-in, opt-out", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": false, "hash": "5d2c487c5bc0acb699deb941f56ceaf95471c818", "submitter": { "id": 69991, "url": "http://patchwork.ozlabs.org/api/people/69991/?format=api", "name": "Stephen Finucane", "email": "stephen@that.guru" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/patchwork/patch/20210811213705.36293-13-stephen@that.guru/mbox/", "series": [ { "id": 257699, "url": "http://patchwork.ozlabs.org/api/series/257699/?format=api", "web_url": "http://patchwork.ozlabs.org/project/patchwork/list/?series=257699", "date": "2021-08-11T21:36:49", "name": "Integrate Bulma", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/257699/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1516052/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1516052/checks/", "tags": {}, "related": [ { "id": 1523343, "url": "http://patchwork.ozlabs.org/api/patches/1523343/?format=api", "web_url": "http://patchwork.ozlabs.org/project/patchwork/patch/20210901165756.181192-13-stephen@that.guru/", "msgid": "<20210901165756.181192-13-stephen@that.guru>", "list_archive_url": null, "date": "2021-09-01T16:57:49", "name": "[RFC,v2,12/19] view: Simplify user opt-in, opt-out", "mbox": "http://patchwork.ozlabs.org/project/patchwork/patch/20210901165756.181192-13-stephen@that.guru/mbox/" } ], "headers": { "Return-Path": "\n <patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "patchwork@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "patchwork@lists.ozlabs.org" ], "Authentication-Results": [ "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=112.213.38.117; helo=lists.ozlabs.org;\n envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=<UNKNOWN>)", "ozlabs.org;\n\tdkim=fail reason=\"key not found in DNS\" header.d=that.guru\n header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=VKTg0d8O;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n\tdkim=fail reason=\"key not found in DNS\" header.d=that.guru\n header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=VKTg0d8O;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=that.guru\n (client-ip=136.175.108.154; helo=mail-108-mta154.mxroute.com;\n envelope-from=stephen@that.guru; receiver=<UNKNOWN>)", "lists.ozlabs.org;\n dkim=fail reason=\"key not found in DNS\" header.d=that.guru\n header.i=@that.guru\n header.a=rsa-sha256 header.s=x header.b=VKTg0d8O;\n dkim-atps=neutral" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4GlPCd4NdMz9sSs\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Aug 2021 08:10:53 +1000 (AEST)", "from boromir.ozlabs.org (localhost [IPv6:::1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4GlPCd2g8fz3cKv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Aug 2021 08:10:53 +1000 (AEST)", "from mail-108-mta154.mxroute.com (mail-108-mta154.mxroute.com\n [136.175.108.154])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by lists.ozlabs.org (Postfix) with ESMTPS id 4GlPBt5TTvz3bmn\n for <patchwork@lists.ozlabs.org>; Thu, 12 Aug 2021 08:10:14 +1000 (AEST)", "from filter004.mxroute.com ([149.28.56.236] filter004.mxroute.com)\n (Authenticated sender: mN4UYu2MZsgR)\n by mail-108-mta154.mxroute.com (ZoneMTA) with ESMTPSA id\n 17b3743f77600074ba.002 for <patchwork@lists.ozlabs.org>\n (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256);\n Wed, 11 Aug 2021 22:10:06 +0000" ], "X-Zone-Loop": "d137a9ac0415d90c5e864a370b950057f42d8bdaaf5b", "X-Originating-IP": "[149.28.56.236]", "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru;\n s=x;\n h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:\n Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:\n Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n List-Post:List-Owner:List-Archive;\n bh=2ki0d7GcplR0dWcO9kWZbbcpQLlU0/0xXK9nfBfEJO4=; b=VKTg0d8OFLRyAU7zhw82X1RfwB\n YeOfxnOBeSyI1zbgj88/Ifi9dAW44oJu09LKAsgBH0UGszw2krHs/P4u9KsxTKKjnJyS9TsRgBQ5W\n jGkTJsMR8xVPX4LpyR3NmHDUiu0w8AdlXB3h26u8eUWaZ4SCFmsGhYUJORYKOTy5ypYNBGsLuk/IL\n GlqH3ENFcRdNGxZ8OGlQdL/1LRBfyJmE9oyeamZruvtMAgPuDh8kngoqpHLV2sjgOXO9RJ9HGkvG5\n k/Bpq2X6lctJKF1oDrBVpeNHNMkWVvFyu9q4u7COdL8nuJugtJSbHJp8HNxHuPOlQRHmXs5qaetsC\n BZ05TpTg==;", "From": "Stephen Finucane <stephen@that.guru>", "To": "patchwork@lists.ozlabs.org", "Subject": "[RFC PATCH 12/19] view: Simplify user opt-in, opt-out", "Date": "Wed, 11 Aug 2021 22:36:58 +0100", "Message-Id": "<20210811213705.36293-13-stephen@that.guru>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<20210811213705.36293-1-stephen@that.guru>", "References": "<20210811213705.36293-1-stephen@that.guru>", "MIME-Version": "1.0", "X-AuthUser": "stephen@that.guru", "X-Zone-Spam-Resolution": "no action", "X-Zone-Spam-Status": "No, score=5, required=15, tests=[ARC_NA=0,\n MID_CONTAINS_FROM=1, FROM_HAS_DN=0, RCPT_COUNT_THREE=0, TO_DN_SOME=0,\n R_MISSING_CHARSET=2.5, RCVD_COUNT_ZERO=0, FROM_EQ_ENVFROM=0, MIME_TRACE=0,\n BROKEN_CONTENT_TYPE=1.5, NEURAL_SPAM=0]", "X-BeenThere": "patchwork@lists.ozlabs.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Patchwork development <patchwork.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/patchwork>,\n <mailto:patchwork-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/patchwork/>", "List-Post": "<mailto:patchwork@lists.ozlabs.org>", "List-Help": "<mailto:patchwork-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/patchwork>,\n <mailto:patchwork-request@lists.ozlabs.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org", "Sender": "\"Patchwork\"\n <patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>" }, "content": "If we already have a user account associated with an email address, why\nmake the user jump through hoops when opting in or out of emails. It's\nsilly.\n\nSigned-off-by: Stephen Finucane <stephen@that.guru>\n---\n patchwork/views/user.py | 78 +++++++++--------------------------------\n 1 file changed, 16 insertions(+), 62 deletions(-)", "diff": "diff --git patchwork/views/user.py patchwork/views/user.py\nindex d1a1180e..440aa38a 100644\n--- patchwork/views/user.py\n+++ patchwork/views/user.py\n@@ -103,50 +103,6 @@ def register_confirm(request, conf):\n return render(request, 'patchwork/registration-confirm.html')\n \n \n-def _opt_in(request, email):\n- conf = EmailConfirmation(type='optin', email=email)\n- conf.save()\n-\n- context = {'confirmation': conf}\n- subject = render_to_string('patchwork/mails/optin-request-subject.txt')\n- message = render_to_string(\n- 'patchwork/mails/optin-request.txt', context, request=request)\n-\n- try:\n- send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [email])\n- except smtplib.SMTPException:\n- messages.error(\n- request,\n- 'An error occurred while submitting this request. '\n- 'Please contact an administrator.'\n- )\n- return False\n-\n- return True\n-\n-\n-def _opt_out(request, email):\n- conf = EmailConfirmation(type='optout', email=email)\n- conf.save()\n-\n- context = {'confirmation': conf}\n- subject = render_to_string('patchwork/mails/optout-request-subject.txt')\n- message = render_to_string(\n- 'patchwork/mails/optout-request.txt', context, request=request)\n-\n- try:\n- send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [email])\n- except smtplib.SMTPException:\n- messages.error(\n- request,\n- 'An error occurred while submitting this request. '\n- 'Please contact an administrator.'\n- )\n- return False\n-\n- return True\n-\n-\n def _send_confirmation_email(request, email):\n conf = EmailConfirmation(type='userperson', user=request.user, email=email)\n conf.save()\n@@ -228,30 +184,28 @@ def profile(request):\n user_email_optin_form = forms.UserEmailOptinForm(\n user=request.user, data=request.POST)\n if user_email_optin_form.is_valid():\n- if _opt_in(\n- request, user_email_optin_form.cleaned_data['email'],\n- ):\n- messages.success(\n- request,\n- 'Requested opt-in to email from Patchwork. '\n- 'Check your email for confirmation.',\n- )\n- return HttpResponseRedirect(reverse('user-profile'))\n+ EmailOptout.objects.filter(\n+ email=user_email_optin_form.cleaned_data['email'],\n+ ).delete()\n+ messages.success(\n+ request,\n+ 'Opt-in into email from Patchwork.'\n+ )\n+ return HttpResponseRedirect(reverse('user-profile'))\n \n messages.error(request, 'Error opting into email.')\n elif form_name == forms.UserEmailOptoutForm.name:\n user_email_optout_form = forms.UserEmailOptoutForm(\n user=request.user, data=request.POST)\n if user_email_optout_form.is_valid():\n- if _opt_out(\n- request, user_email_optout_form.cleaned_data['email'],\n- ):\n- messages.success(\n- request,\n- 'Requested opt-out from email from Patchwork. '\n- 'Check your email for confirmation.',\n- )\n- return HttpResponseRedirect(reverse('user-profile'))\n+ EmailOptout(\n+ email=user_email_optout_form.cleaned_data['email'],\n+ ).save()\n+ messages.success(\n+ request,\n+ 'Opted-out from email from Patchwork.'\n+ )\n+ return HttpResponseRedirect(reverse('user-profile'))\n \n messages.error(request, 'Error opting out of email.')\n elif form_name == UserForm.name:\n", "prefixes": [ "RFC", "12/19" ] }