[Django] #30499: PasswordResetView should be allowed to set `domain_override`

11 views
Skip to first unread message

Django

unread,
May 22, 2019, 10:43:26 AM5/22/19
to django-...@googlegroups.com
#30499: PasswordResetView should be allowed to set `domain_override`
-------------------------------------------+------------------------
Reporter: Mattia Procopio | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
Actually if the domain of the link sent within the mail needs to be
overridden, the view `form_valid` method should be replaced or the view
should subclass an own instance of PasswordContextMixin.
I think allowing to inject a custom domain from `urls.py` would help with
DRY in this case as the new domain can be passed when declaring
`PasswordResetView.as_view(domain_override="mynew.domain.com"`)

I am thinking of adding simply domain_override = None as new class
attribute and adding it to opts:


{{{
class PasswordResetView(PasswordContextMixin, FormView):
...
domain_override = None

def form_valid(self, form):
opts = {
'use_https': self.request.is_secure(),
'token_generator': self.token_generator,
'from_email': self.from_email,
'email_template_name': self.email_template_name,
'subject_template_name': self.subject_template_name,
'request': self.request,
'html_email_template_name': self.html_email_template_name,
'extra_email_context': self.extra_email_context,
'domain_override': self.domain_override,
}
form.save(**opts)
return super().form_valid(form)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30499>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 22, 2019, 10:45:00 AM5/22/19
to django-...@googlegroups.com
#30499: PasswordResetView should be allowed to set `domain_override`
-------------------------------------+-------------------------------------
Reporter: Mattia Procopio | Owner: Mattia
| Procopio
Type: New feature | Status: assigned
Component: Uncategorized | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mattia Procopio):

* status: new => assigned
* owner: nobody => Mattia Procopio


--
Ticket URL: <https://code.djangoproject.com/ticket/30499#comment:1>

Django

unread,
May 22, 2019, 11:21:59 AM5/22/19
to django-...@googlegroups.com
#30499: PasswordResetView should be allowed to set `domain_override`
-------------------------------------+-------------------------------------
Reporter: Mattia Procopio | Owner: Mattia
| Procopio
Type: New feature | Status: assigned
Component: Uncategorized | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

OK, yes, it seems a reasonable addition.

--
Ticket URL: <https://code.djangoproject.com/ticket/30499#comment:2>

Django

unread,
May 24, 2019, 4:46:04 AM5/24/19
to django-...@googlegroups.com
#30499: PasswordResetView should be allowed to set `domain_override`
-------------------------------------+-------------------------------------
Reporter: Mattia Procopio | Owner: Mattia
| Procopio
Type: New feature | Status: assigned
Component: Uncategorized | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mattia Procopio):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/11406 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30499#comment:3>

Django

unread,
May 27, 2019, 5:44:28 AM5/27/19
to django-...@googlegroups.com
#30499: PasswordResetView should be allowed to set `domain_override`.

-------------------------------------+-------------------------------------
Reporter: Mattia Procopio | Owner: Mattia
| Procopio
Type: New feature | Status: closed
Component: Uncategorized | Version: master
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: assigned => closed
* resolution: => invalid


Comment:

Mattia, Thanks for your work and sorry, but `domain` can be override
easily with the current implementation, e.g.
{{{
views.PasswordResetView.as_view(extra_email_context={'domain':
'custom.example.com'}).
}}}

I think that providing an extra `kwargs` for that is pointless.

--
Ticket URL: <https://code.djangoproject.com/ticket/30499#comment:4>

Reply all
Reply to author
Forward
0 new messages