All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: yocto@yoctoproject.org
Subject: [layerindex-web][PATCH] views: add ability to force https URL in layer review emails
Date: Fri, 21 Jul 2017 11:40:23 +0200	[thread overview]
Message-ID: <20170721094023.21649-1-paul.eggleton@linux.intel.com> (raw)

At the moment the URL that is presented in the review email will have
http:// or https:// prefix depending on what the user who submitted the
layer was using, but that's irrelevant - we actually want https:// if
the server is capable of it since the reviewer may be redirected to log
in (and Django's login_required decorator will always redirect to the
login page if http is being used as far as I observed, which is a bit
annoying if you are already logged in.) Add a setting which if enabled
will substitute https:// as the prefix.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 layerindex/views.py | 5 ++++-
 settings.py         | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/layerindex/views.py b/layerindex/views.py
index 2f7d45e..eaeb5c3 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -169,10 +169,13 @@ def edit_layer_view(request, template_name, branch='master', slug=None):
                             user_name = user.first_name
                         else:
                             user_name = user.username
+                        layer_url = request.build_absolute_uri(reverse('layer_review', args=(layeritem.name,)))
+                        if getattr(settings, 'FORCE_REVIEW_HTTPS', False) and layer_url.startswith('http:'):
+                            layer_url = 'https:' + layer_url.split(':', 1)[1]
                         d = Context({
                             'user_name': user_name,
                             'layer_name': layeritem.name,
-                            'layer_url': request.build_absolute_uri(reverse('layer_review', args=(layeritem.name,))),
+                            'layer_url': layer_url,
                         })
                         subject = '%s - %s' % (settings.SUBMIT_EMAIL_SUBJECT, layeritem.name)
                         from_email = settings.SUBMIT_EMAIL_FROM
diff --git a/settings.py b/settings.py
index 3318af1..92146f8 100644
--- a/settings.py
+++ b/settings.py
@@ -217,6 +217,10 @@ UPDATE_PURGE_DAYS = 30
 # Remove layer dependencies that are not specified in conf/layer.conf
 REMOVE_LAYER_DEPENDENCIES = False
 
+# Always use https:// for review URLs in emails (since it may be redirected to
+# the login page)
+FORCE_REVIEW_HTTPS = False
+
 # Settings for layer submission feature
 SUBMIT_EMAIL_FROM = 'noreply@example.com'
 SUBMIT_EMAIL_SUBJECT = 'OE Layerindex layer submission'
-- 
2.9.4



                 reply	other threads:[~2017-07-21  9:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170721094023.21649-1-paul.eggleton@linux.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.