[Django] #22752: PasswordResetForm email context is missing current_app

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #22752: PasswordResetForm email context is missing current_app

Django
#22752: PasswordResetForm email context is missing current_app
-------------------------------+--------------------
     Reporter:  bendavis78     |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  contrib.auth   |    Version:  master
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  1              |      UI/UX:  0
-------------------------------+--------------------
 I have multiple namespace instances for password reset urls. The email
 template rendered by the default PasswordResetForm does not included a
 `current_app` context. It's an easy fix, though, ass the PasswordResetForm
 already has `self.current_app`. Just need to wrap the context instance
 passed to the email template:

 {{{
 #!diff
 diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
 index 6e07d45..baef873 100644
 --- a/django/contrib/auth/forms.py
 +++ b/django/contrib/auth/forms.py
 @@ -4,7 +4,7 @@ from collections import OrderedDict

  from django import forms
  from django.forms.utils import flatatt
 -from django.template import loader
 +from django.template import loader, Context
  from django.utils.encoding import force_bytes
  from django.utils.html import format_html, format_html_join
  from django.utils.http import urlsafe_base64_encode
 @@ -264,10 +264,13 @@ class PasswordResetForm(forms.Form):
                  'token': token_generator.make_token(user),
                  'protocol': 'https' if use_https else 'http',
              }
 -            subject = loader.render_to_string(subject_template_name, c)
 +            context_instance = Context(current_app=self.current_app)
 +            subject = loader.render_to_string(
 +                subject_template_name, c, context_instance)
              # Email subject *must not* contain newlines
              subject = ''.join(subject.splitlines())
 -            email = loader.render_to_string(email_template_name, c)
 +            email = loader.render_to_string(
 +                email_template_name, c, context_instance)

              if html_email_template_name:
                  html_email =
 loader.render_to_string(html_email_template_name, c)
 ~
 }}}

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/053.e9b491401308056935aff3766eab00cc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
#22752: PasswordResetForm email context is missing current_app
-------------------------------+--------------------------------------
     Reporter:  bendavis78     |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  contrib.auth   |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  1              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by bendavis78):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Correction, PasswordResetForm does not have current_app built in. That
 needs to be added as well.

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.71cae3ed6f61082bd4e2062b93acff8c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
In reply to this post by Django
#22752: PasswordResetForm email context is missing current_app
-------------------------------+--------------------------------------
     Reporter:  bendavis78     |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  contrib.auth   |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  1              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by bendavis78):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Correction, PasswordResetForm does not have current_app built in. That
 needs to be added as well.

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.3da498862a16bbbe2824b29e51f3d622%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
In reply to this post by Django
#22752: PasswordResetForm email context is missing current_app
-------------------------------+--------------------------------------
     Reporter:  bendavis78     |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  contrib.auth   |                  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 EvilDMP):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * easy:  1 => 0
 * needs_docs:   => 0


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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.0356716ba3ee2beb03ca112cc153e755%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
In reply to this post by Django
#22752: PasswordResetForm email context is missing current_app
--------------------------------------+------------------------------------
     Reporter:  bendavis78            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.auth          |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  1
  Needs tests:  1                     |  Patch needs improvement:  1
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by bmispelon):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1
 * needs_docs:  0 => 1
 * has_patch:  0 => 1
 * type:  Uncategorized => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 Hi,

 I agree that it would be good to have the current app while rendering the
 body of the email because it would help with reversing URLs inside it.
 However, I don't really understand the use-case behind having the current
 app when rendering the subject line.

 In any case, the provided patch doesn't apply on master and it's also
 going to require tests and documentation.

 Thanks.

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.66ef2985cb23052b0a35e470cc8f5785%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
In reply to this post by Django
#22752: PasswordResetForm email context is missing current_app
--------------------------------------+------------------------------------
     Reporter:  bendavis78            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.auth          |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  1
  Needs tests:  1                     |  Patch needs improvement:  1
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by bendavis78):

 @bmispelon, I think one would expect the context to be identical in both
 the body and the subject. Whether or not there's a use case, I can't think
 of any justification for making them separate. I plan on working on this
 (as well as various other tickets I've submitted) once I get a little more
 free time.

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.f46e83564edd545da4d55709048b99c1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
In reply to this post by Django
#22752: PasswordResetForm email context is missing current_app
--------------------------------------+------------------------------------
     Reporter:  bendavis78            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.auth          |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  1                     |      Needs documentation:  1
  Needs tests:  1                     |  Patch needs improvement:  1
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by bendavis78):

 * cc: bendavis78 (added)


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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.19f48dea83f7d01d8af4278379e8171f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #22752: PasswordResetForm email context is missing current_app

Django
In reply to this post by Django
#22752: PasswordResetForm email context is missing current_app
-------------------------------------+-------------------------------------
     Reporter:  Ben Davis            |                    Owner:  Hasan
         Type:                       |  Ramezani
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.auth         |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

 * owner:  nobody => Hasan Ramezani
 * status:  new => assigned


Comment:

 @felixxm Do we still need this ticket?

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.b0d96f1847e9ee2a141144a5e8a0ad02%40djangoproject.com.