Commit f3081a06 authored by Will LaShell's avatar Will LaShell
Browse files

Merge branch 'release/3.0.0alpha2'

parents ef270d74 f51c0240
Will LaShell <wlashell@lyrical.net>
Eric Medchill <eric.medchill@gmail.com>
Chris Ayoub <chriswayoub@gmail.com>
Joey Wilhelm <tarkatronic@gmail.com>
\ No newline at end of file
......@@ -2,13 +2,15 @@ include LICENSE
include NOTICE
include AUTHORS
include ChangeLog
recursive-include site_content/templates *
recursive-include site_content/static *
recursive-include site_content/doc *
recursive-include site_seo/templates *
recursive-include site_seo/static *
recursive-include site_slider/templates *
recursive-include site_slider/static *
recursive-include site_tracking/templates *
recursive-include site_tracking/static *
prune build
\ No newline at end of file
recursive-include lyrical/site_content/templates *
recursive-include lyrical/site_content/static *
recursive-include lyrical/site_content/doc *
recursive-include lyrical/site_seo/templates *
recursive-include lyrical/site_seo/static *
recursive-include lyrical/site_slider/templates *
recursive-include lyrical/site_slider/static *
recursive-include lyrical/site_tracking/templates *
recursive-include lyrical/site_tracking/static *
recursive-include lyrical/site_news/templates *
recursive-include lyrical/site_news/static *
prune build
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
__version__ = '3.0.0alpha2'
......@@ -3,8 +3,8 @@ from django.contrib.admin import site, ModelAdmin, StackedInline, TabularInline
from django.core import urlresolvers
from django.http import HttpResponseRedirect
from site_content.settings import ENABLE_BUILTIN_MEDIA, RTE_CONFIG_URI
from site_content.models import InheritanceQuerySet, SitePage, SitePageTemplateSelection, SiteMenu, SiteMenuItem, MenuItemLink, MenuItemPage, SiteBlock, SitePageAlias, SitePageRedirect, SitePosition, SitePagePositionBlock
from lyrical.site_content.settings import ENABLE_BUILTIN_MEDIA, RTE_CONFIG_URI
from lyrical.site_content.models import InheritanceQuerySet, SitePage, SitePageTemplateSelection, SiteMenu, SiteMenuItem, MenuItemLink, MenuItemPage, SiteBlock, SitePageAlias, SitePageRedirect, SitePosition, SitePagePositionBlock
class SitePageTemplateSelectionAdmin(ModelAdmin):
......@@ -105,13 +105,13 @@ class SiteMenuItemAdmin(ModelAdmin):
return qs
def url(self, obj):
if obj.url:
if getattr(obj, 'url', None):
return obj.url
else:
return None
def page(self, obj):
if obj.page:
if getattr(obj, 'page', None):
return obj.page
else:
return None
......
......@@ -4,7 +4,7 @@ import shutil
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
import site_content.settings
import lyrical.site_content.settings
class Command(BaseCommand):
......@@ -52,7 +52,7 @@ class Command(BaseCommand):
except IOError:
raise CommandError('Holding directory write error has occurred. Please check your path configuration.')
files_to_copy = getattr(site_content.settings, 'STATICFILES_TO_COPY')
files_to_copy = getattr(lyrical.site_content.settings, 'STATICFILES_TO_COPY')
for file_to_copy in files_to_copy['css']:
if os.path.exists(os.path.join(selected_filedir, 'css', file_to_copy)):
......@@ -60,7 +60,7 @@ class Command(BaseCommand):
elif not os.access(os.path.join(selected_filedir, 'css'), os.W_OK):
raise CommandError('%s cannot be created. Files will not be installed.' % file_to_copy)
else:
shutil.copy(os.path.join(site_content.settings.SITE_CONTENT_DOC_ROOT, file_to_copy),
shutil.copy(os.path.join(lyrical.site_content.settings.SITE_CONTENT_DOC_ROOT, file_to_copy),
os.path.join(selected_filedir, 'css', file_to_copy))
for file_to_copy in files_to_copy['js']:
......@@ -70,7 +70,7 @@ class Command(BaseCommand):
print 'tried: %s' % os.path.join(selected_filedir, 'js', file_to_copy)
raise CommandError('%s cannot be created. Files will not be installed.' % file_to_copy)
else:
shutil.copy(os.path.join(site_content.settings.SITE_CONTENT_DOC_ROOT, file_to_copy),
shutil.copy(os.path.join(lyrical.site_content.settings.SITE_CONTENT_DOC_ROOT, file_to_copy),
os.path.join(selected_filedir, 'js', file_to_copy))
print 'All files have been installed correctly.'
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.cache import cache
from django.http import Http404
from django.http import Http404
from django.template.response import TemplateResponse
from site_content.views import site_page
from lyrical.site_content.views import SitePageView
def make_tls_property(default=None):
......@@ -30,8 +31,29 @@ def make_tls_property(default=None):
return TLSProperty()
def _patch_setattr(obj):
"""Purpose of this is to allow changes to settings object again after it is
changed to tls property.
Without this patch the following is not possible::
settings.SITE_ID = 1
settings.SITE_ID = 42
assert settings.SITE_ID == 42 # this fails without this patch
"""
old_setattr = obj.__setattr__
def wrap_setattr(self, name, value):
try:
getattr(self.__class__, name).value = value
except AttributeError:
old_setattr(name, value)
obj.__class__.__setattr__ = wrap_setattr
_patch_setattr(settings)
_default_site_id = getattr(settings, 'SITE_ID', None)
SITE_ID = settings.__class__.SITE_ID = make_tls_property()
settings.__class__.SITE_ID = make_tls_property()
class SitePageFallbackMiddleware(object):
......@@ -51,7 +73,7 @@ class SitePageFallbackMiddleware(object):
cache_key = 'LyricalPage:Site:domain:%s' % domain
site = cache.get(cache_key)
if site:
SITE_ID.value = site
settings.SITE_ID = site
else:
try:
site = Site.objects.get(domain=domain)
......@@ -78,22 +100,25 @@ class SitePageFallbackMiddleware(object):
# Set SITE_ID for this thread/request
if site:
SITE_ID.value = site.pk
settings.SITE_ID = site.pk
else:
SITE_ID.value = _default_site_id
settings.SITE_ID = _default_site_id
cache.set(cache_key, SITE_ID.value, 5 * 60)
cache.set(cache_key, settings.SITE_ID, 5 * 60)
def process_response(self, request, response):
if response.status_code != 404:
return response
try:
return site_page(request, request.path_info)
response = SitePageView.as_view()(request)
if isinstance(response, TemplateResponse):
response.render()
return response
except Http404:
if 'site_seo' in settings.INSTALLED_APPS:
import site_seo.common
import lyrical.site_seo.common
site_seo.common.add_404_url(request)
return response
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment