standalone
Simon Caminada 8 years ago
parent 277851681b
commit ef2c114f35

@ -1,4 +1,3 @@
DEBUG=True
STAGE=local
DEFAULT_HAYSTACK_URL=es+http://es:9200/index-*
DATABASE_URL=postgres://postgres@postgres:5432/db

@ -47,7 +47,6 @@ RUN pip-reqs compile && \
--requirement requirements.urls
# </PYTHON>
RUN mkdir -p /usr/share/whoosh/data && chmod -R 777 /usr/share/whoosh/data
# <SOURCE>
COPY . /app

@ -5,13 +5,11 @@ services:
build: "."
links:
- "db:postgres"
# - "es:es"
ports:
- "8009:80"
volumes:
- ".:/app:rw"
- "./data:/data:rw"
- "./whoosh:/usr/share/whoosh/data:rw"
command: python manage.py runserver 0.0.0.0:80
env_file: .env-local
@ -22,21 +20,3 @@ services:
volumes:
- ".:/app:rw"
# es:
# image: elasticsearch:2.4-alpine
# ulimits:
# memlock:
# soft: 5120
# hard: 5120
# environment:
# - "ES_JAVA_OPTS=-server -Xms10m -Xmx10m"
# - "ES_HEAP_SIZE=10m"
# - "MAX_LOCKED_MEMORY=5120"
# - index.number_of_shards=1
# - index.number_of_replicas=0
# - network.tcp.block=1
# - bootstrap.memory_lock=1
# volumes:
# - "./esdata:/usr/share/elasticsearch/data:rw"
# expose:
# - "9200"

@ -11,7 +11,6 @@ https://control.divio.com/api/v1/apps/serve/djangocms-picture/2.0.6/005e8663-d1c
https://control.divio.com/api/v1/apps/serve/djangocms-text-ckeditor/3.5.3/a7b5179f-cea5-4af8-b235-6b7f709c4e6a/djangocms-text-ckeditor-3.5.3.tar.gz#egg=djangocms-text-ckeditor==3.5.3
https://control.divio.com/api/v1/apps/serve/django-filer/1.3.0.1/bcb7d25b-6922-48a9-a252-9bc165f6403e/django-filer-1.3.0.1.tar.gz#egg=django-filer==1.3.0.1
# </INSTALLED_ADDONS>
Whoosh==2.7.4
django-haystack==2.7.0
aldryn-search==0.5.0
django-fontawesome==0.3.1

@ -57,18 +57,15 @@ ALDRYN_SEARCH_INDEX_BASE_CLASS = 'project.search.SearchIndex'
HAYSTACK_CUSTOM_HIGHLIGHTER = 'project.search.Highlighter'
HAYSTACK_DEFAULT_OPERATOR = 'OR'
HAYSTACK_INDEX_PATH = os.path.join('/usr/share/whoosh/data', 'index')
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(HAYSTACK_INDEX_PATH, 'default'),
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
}
for lang_code, lang in LANGUAGES:
HAYSTACK_CONNECTIONS[lang_code] = {}
HAYSTACK_CONNECTIONS[lang_code].update({
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(HAYSTACK_INDEX_PATH, lang_code),
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
})
HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter', ]

@ -6,12 +6,11 @@ from django.core.files.storage import default_storage
from django.conf import settings
from django.db import models
from django.core.urlresolvers import reverse_lazy
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from image_cropping import ImageRatioField
from parler.models import TranslatableModel, TranslatedFields
#from portal.storage import PrivateS3MediaStorage
from portal.storage import PrivateS3MediaStorage
from project.utils import CroppableFilerImageField
@ -92,8 +91,7 @@ class DownloadTag(TranslatableModel):
if getattr(settings, 'DEFAULT_STORAGE_DSN', None):
# protected_file_storage = PrivateS3MediaStorage()
protected_file_storage = default_storage
protected_file_storage = PrivateS3MediaStorage()
else:
protected_file_storage = default_storage

@ -1,58 +1,57 @@
# -*- coding: utf-8 -*-
#import re
#from aldryn_django.storage import S3MediaStorage
#from django.conf import settings
#
#from boto.s3.connection import (
# SubdomainCallingFormat,
# OrdinaryCallingFormat,
#)
#
#
#class PrivateS3MediaStorage(S3MediaStorage):
# def __init__(self):
# bucket_name = settings.AWS_MEDIA_STORAGE_BUCKET_NAME
#
# if '.' in bucket_name:
# calling_format = OrdinaryCallingFormat()
# else:
# calling_format = SubdomainCallingFormat()
#
# # We cannot use a function call or a partial here. Instead, we have to
# # create a subclass because django tries to recreate a new object by
# # calling the __init__ of the returned object (with no arguments).
# super(S3MediaStorage, self).__init__(
# access_key=settings.AWS_MEDIA_ACCESS_KEY_ID,
# secret_key=settings.AWS_MEDIA_SECRET_ACCESS_KEY,
# bucket_name=bucket_name,
# location=settings.AWS_MEDIA_BUCKET_PREFIX,
# host=settings.AWS_MEDIA_STORAGE_HOST,
# custom_domain=settings.AWS_MEDIA_DOMAIN,
# calling_format=calling_format,
# # Setting an ACL requires us to grant the user the PutObjectAcl
# # permission as well, even if it matches the default bucket ACL.
# # XXX: Ideally we would thus set it to `None`, but due to how
# # easy_thumbnails works internally, that causes thumbnail
# # generation to fail...
# default_acl='private',
# querystring_auth=True,
# )
# # MEDIA_HEADERS is a list of tuples containing a regular expression
# # to match against a path, and a dictionary of HTTP headers to be
# # returned with the resource identified by the path when it is
# # requested.
# # The headers are applied in the order they where declared, and
# # processing stops at the first match.
# # E.g.:
# #
# # MEDIA_HEADERS = [
# # (r'media/cache/.*', {
# # 'Cache-Control': 'max-age={}'.format(3600 * 24 * 365),
# # })
# # ]
# #
# media_headers = getattr(settings, 'MEDIA_HEADERS', [])
# self.media_headers = [
# (re.compile(r), headers) for r, headers in media_headers
# ]
#
import re
from aldryn_django.storage import S3MediaStorage
from django.conf import settings
from boto.s3.connection import (
SubdomainCallingFormat,
OrdinaryCallingFormat,
)
class PrivateS3MediaStorage(S3MediaStorage):
def __init__(self):
bucket_name = settings.AWS_MEDIA_STORAGE_BUCKET_NAME
if '.' in bucket_name:
calling_format = OrdinaryCallingFormat()
else:
calling_format = SubdomainCallingFormat()
# We cannot use a function call or a partial here. Instead, we have to
# create a subclass because django tries to recreate a new object by
# calling the __init__ of the returned object (with no arguments).
super(S3MediaStorage, self).__init__(
access_key=settings.AWS_MEDIA_ACCESS_KEY_ID,
secret_key=settings.AWS_MEDIA_SECRET_ACCESS_KEY,
bucket_name=bucket_name,
location=settings.AWS_MEDIA_BUCKET_PREFIX,
host=settings.AWS_MEDIA_STORAGE_HOST,
custom_domain=settings.AWS_MEDIA_DOMAIN,
calling_format=calling_format,
# Setting an ACL requires us to grant the user the PutObjectAcl
# permission as well, even if it matches the default bucket ACL.
# XXX: Ideally we would thus set it to `None`, but due to how
# easy_thumbnails works internally, that causes thumbnail
# generation to fail...
default_acl='private',
querystring_auth=True,
)
# MEDIA_HEADERS is a list of tuples containing a regular expression
# to match against a path, and a dictionary of HTTP headers to be
# returned with the resource identified by the path when it is
# requested.
# The headers are applied in the order they where declared, and
# processing stops at the first match.
# E.g.:
#
# MEDIA_HEADERS = [
# (r'media/cache/.*', {
# 'Cache-Control': 'max-age={}'.format(3600 * 24 * 365),
# })
# ]
#
media_headers = getattr(settings, 'MEDIA_HEADERS', [])
self.media_headers = [
(re.compile(r), headers) for r, headers in media_headers
]

Loading…
Cancel
Save