comparison smiley/models.py @ 991:4aadaf3bc234

Added SITE_SCHEME setting. Configure site scheme to be either http or https based on SITE_SCHEME setting. Updated code to use it.
author Brian Neal <bgneal@gmail.com>
date Sun, 01 Nov 2015 15:56:05 -0600
parents 2908859c2fe4
children
comparison
equal deleted inserted replaced
990:81b96f3c9e59 991:4aadaf3bc234
2 Models for the smiley application. 2 Models for the smiley application.
3 """ 3 """
4 import re 4 import re
5 5
6 from django.db import models 6 from django.db import models
7 from django.conf import settings
7 from django.core.cache import cache 8 from django.core.cache import cache
8 from django.contrib.sites.models import Site 9 from django.contrib.sites.models import Site
9 10
10 CACHE_TIMEOUT = 60 * 60 # seconds 11 CACHE_TIMEOUT = 60 * 60 # seconds
11 12
97 if relative_urls: 98 if relative_urls:
98 return u'![%s](%s "%s")' % (self.title, self.image.url, 99 return u'![%s](%s "%s")' % (self.title, self.image.url,
99 self.title) 100 self.title)
100 else: 101 else:
101 site = Site.objects.get_current() 102 site = Site.objects.get_current()
102 return (u'![%s](http://%s%s "%s")' % 103 return (u'![%s](%s://%s%s "%s")' % (
103 (self.title, site.domain, self.image.url, self.title)) 104 self.title, settings.SITE_SCHEME, site.domain, self.image.url, self.title))
104 return u'' 105 return u''