Skip to content

Commit

Permalink
Add in settings_local
Browse files Browse the repository at this point in the history
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

use SECURE_SSL_REDIRECT = getattr(settings, 'SECURE_SSL_REDIRECT', False)
to send link by email in http or https
  • Loading branch information
ptitloup committed May 4, 2020
1 parent 6590aa0 commit 45ba303
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
27 changes: 18 additions & 9 deletions pod/video/management/commands/check_obsolete_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
CONTACT_US_EMAIL = getattr(
settings, 'CONTACT_US_EMAIL', [
mail for name, mail in getattr(settings, 'MANAGERS')])

SECURE_SSL_REDIRECT = getattr(settings, 'SECURE_SSL_REDIRECT', False)
URL_SCHEME = "https" if SECURE_SSL_REDIRECT else "http"

##
# Settings exposed in templates
#
Expand Down Expand Up @@ -90,7 +94,7 @@ def get_video_treatment_and_notify_user(self):
sites=get_current_site(
settings.SITE_ID))
for video in videos:
self.notify_user(video, step_day)
# self.notify_user(video, step_day)
if (
USE_ESTABLISHMENT and
MANAGERS and
Expand Down Expand Up @@ -194,8 +198,10 @@ def notify_user(self, video, step_day):
msg_html += _(
"you can change the removal date "
+ "by editing your video:</p>\n"
+ "<p><a href='http:%(url)s' rel='noopener' target='_blank'>"
+ "http:%(url)s</a></p>\n") % {
+ "<p><a href='%(scheme)s:%(url)s' "
+ "rel='noopener' target='_blank'>"
+ "%(scheme)s:%(url)s</a></p>\n") % {
"scheme": URL_SCHEME,
"url": video.get_full_url()}
msg_html += "<p>" + _("Regards") + "</p>\n"
else:
Expand Down Expand Up @@ -335,20 +341,23 @@ def notify_manager_of_archived_video(self, list_video):

def get_list_video_html(self, list_video, deleted):
msg_html = ""
for deadline in list_video:
for i, deadline in enumerate(list_video):
if deleted is False and deadline != '0':
msg_html += "\n"
if i != 0:
msg_html += "<br><br>"
msg_html += "\n<strong>"
msg_html += _("In %(deadline)s days") % {"deadline": deadline}
msg_html += ":"
msg_html += ":</strong>"
for vid in list_video[deadline]:
if deleted:
msg_html += "\n<br/> - " + vid
else:
msg_html += (
"\n<br/> - %(title)s : "
+ "<a href='http:%(url)s' rel='noopener'"
+ " target='_blank'>%(url)s</a>.") % {
"url": vid.get_full_url(), "title": vid
+ "<a href='%(scheme)s:%(url)s' rel='noopener'"
+ " target='_blank'>%(scheme)s:%(url)s</a>.") % {
"scheme": URL_SCHEME,
"url": vid.get_full_url(), "title": vid
}
return msg_html

Expand Down
8 changes: 6 additions & 2 deletions pod/video/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

MANAGERS = getattr(settings, 'MANAGERS', {})

SECURE_SSL_REDIRECT = getattr(settings, 'SECURE_SSL_REDIRECT', False)


# ##########################################################################
# ENCODE VIDEO : GENERIC FUNCTION
Expand Down Expand Up @@ -108,7 +110,8 @@ def send_email(msg, video_id):
def send_email_transcript(video_to_encode):
if DEBUG:
print("SEND EMAIL ON TRANSCRIPTING COMPLETION")
content_url = "http:%s" % video_to_encode.get_full_url()
url_scheme = "https" if SECURE_SSL_REDIRECT else "http"
content_url = "%s:%s" % (url_scheme, video_to_encode.get_full_url())
subject = "[%s] %s" % (
TITLE_SITE,
_(u"Transcripting #%(content_id)s completed") % {
Expand Down Expand Up @@ -195,7 +198,8 @@ def send_email_transcript(video_to_encode):
def send_email_encoding(video_to_encode):
if DEBUG:
print("SEND EMAIL ON ENCODING COMPLETION")
content_url = "http:%s" % video_to_encode.get_full_url()
url_scheme = "https" if SECURE_SSL_REDIRECT else "http"
content_url = "%s:%s" % (url_scheme, video_to_encode.get_full_url())
subject = "[%s] %s" % (
TITLE_SITE,
_(u"Encoding #%(content_id)s completed") % {
Expand Down

0 comments on commit 45ba303

Please sign in to comment.