fixed s3 check
This commit is contained in:
@ -10,6 +10,7 @@ from drf_writable_nested import UniqueFieldsMixin, WritableNestedModelSerializer
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.exceptions import NotFound, ValidationError
|
from rest_framework.exceptions import NotFound, ValidationError
|
||||||
|
|
||||||
|
from cookbook.helper.CustomStorageClass import CachedS3Boto3Storage
|
||||||
from cookbook.helper.HelperFunctions import str2bool
|
from cookbook.helper.HelperFunctions import str2bool
|
||||||
from cookbook.helper.shopping_helper import RecipeShoppingEditor
|
from cookbook.helper.shopping_helper import RecipeShoppingEditor
|
||||||
from cookbook.models import (Automation, BookmarkletImport, Comment, CookLog, CustomFilter,
|
from cookbook.models import (Automation, BookmarkletImport, Comment, CookLog, CustomFilter,
|
||||||
@ -20,8 +21,7 @@ from cookbook.models import (Automation, BookmarkletImport, Comment, CookLog, Cu
|
|||||||
SupermarketCategory, SupermarketCategoryRelation, Sync, SyncLog, Unit,
|
SupermarketCategory, SupermarketCategoryRelation, Sync, SyncLog, Unit,
|
||||||
UserFile, UserPreference, ViewLog)
|
UserFile, UserPreference, ViewLog)
|
||||||
from cookbook.templatetags.custom_tags import markdown
|
from cookbook.templatetags.custom_tags import markdown
|
||||||
from cookbook.helper.CustomStorageClass import CachedS3Boto3Storage
|
from recipes.settings import MEDIA_URL, AWS_ENABLED
|
||||||
from recipes.settings import MEDIA_URL, AWS_S3_ENDPOINT_URL, AWS_ACCESS_KEY_ID
|
|
||||||
|
|
||||||
|
|
||||||
class ExtendedRecipeMixin(serializers.ModelSerializer):
|
class ExtendedRecipeMixin(serializers.ModelSerializer):
|
||||||
@ -55,7 +55,7 @@ class ExtendedRecipeMixin(serializers.ModelSerializer):
|
|||||||
|
|
||||||
def get_image(self, obj):
|
def get_image(self, obj):
|
||||||
if obj.recipe_image:
|
if obj.recipe_image:
|
||||||
if AWS_ACCESS_KEY_ID and AWS_S3_ENDPOINT_URL:
|
if AWS_ENABLED:
|
||||||
storage = CachedS3Boto3Storage()
|
storage = CachedS3Boto3Storage()
|
||||||
path = storage.url(obj.recipe_image)
|
path = storage.url(obj.recipe_image)
|
||||||
else:
|
else:
|
||||||
|
@ -390,6 +390,8 @@ JS_REVERSE_SCRIPT_PREFIX = os.getenv('JS_REVERSE_SCRIPT_PREFIX', SCRIPT_NAME)
|
|||||||
STATIC_URL = os.getenv('STATIC_URL', '/static/')
|
STATIC_URL = os.getenv('STATIC_URL', '/static/')
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
||||||
|
|
||||||
|
AWS_ENABLED = True if os.getenv('S3_ACCESS_KEY', False) else False
|
||||||
|
|
||||||
if os.getenv('S3_ACCESS_KEY', ''):
|
if os.getenv('S3_ACCESS_KEY', ''):
|
||||||
DEFAULT_FILE_STORAGE = 'cookbook.helper.CustomStorageClass.CachedS3Boto3Storage'
|
DEFAULT_FILE_STORAGE = 'cookbook.helper.CustomStorageClass.CachedS3Boto3Storage'
|
||||||
|
|
||||||
|
13622
vue/yarn.lock
Normal file
13622
vue/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user