Repository: pennersr/django-allauth

Issue:
why doesn't render_to_string() inside render_mail() have access to request?
I tried to use `...{{ request.get_host }}{% url 'unsubscribe' %}...` inside a custom email template (email_confirmation_message.html), only to learn (unless I'm doing something wrong) that request wasn't available to the template.

digging into `render_mail` inside of `allauth.account.adapter.DefaultAccountAdapter` I see that the `render_to_string` method is missing the optional request parameter.

overriding the method and changing 
```
bodies[ext] = render_to_string(template_name,
                                               context).strip()
```

to 

```
bodies[ext] = render_to_string(template_name,
                                               context, self.request).strip()
```

fixes my problem. But I'm curious if

1.  I'm trying to get access to request the wrong way?
2. There's a reason why request isn't made available to the template?
3. What do I risk breaking?
fix(send_confirmation_mail): added request to email context data.
Referencing issue #2186 adds request context to email sent in send_confirmation_mail.


Discussion:


[![Coverage Status](https://coveralls.io/builds/21421140/badge)](https://coveralls.io/builds/21421140)

Coverage remained the same at 94.365% when pulling **e6c9eca0ca274f680c939f3c9bc19eb8014904ae on iarp:email-confirm-ctx-request** into **0ae1f112c812e5914a7a9a886082c74df6c52fca on pennersr:master**.


[![Coverage Status](https://coveralls.io/builds/21421140/badge)](https://coveralls.io/builds/21421140)

Coverage remained the same at 94.365% when pulling **e6c9eca0ca274f680c939f3c9bc19eb8014904ae on iarp:email-confirm-ctx-request** into **0ae1f112c812e5914a7a9a886082c74df6c52fca on pennersr:master**.


Resolving patch:
diff --git a/allauth/account/adapter.py b/allauth/account/adapter.py
--- a/allauth/account/adapter.py
+++ b/allauth/account/adapter.py
@@ -111,8 +111,9 @@ def render_mail(self, template_prefix, email, context):
         for ext in ['html', 'txt']:
             try:
                 template_name = '{0}_message.{1}'.format(template_prefix, ext)
-                bodies[ext] = render_to_string(template_name,
-                                               context).strip()
+                bodies[ext] = render_to_string(
+                    template_name, context, self.request,
+                ).strip()
             except TemplateDoesNotExist:
                 if ext == 'txt' and not bodies:
                     # We need at least one body
@@ -311,8 +312,9 @@ def add_message(self, request, level, message_template,
             try:
                 if message_context is None:
                     message_context = {}
-                message = render_to_string(message_template,
-                                           message_context).strip()
+                message = render_to_string(
+                    message_template, message_context, self.request,
+                ).strip()
                 if message:
                     messages.add_message(request, level, message,
                                          extra_tags=extra_tags)


Test patch: