fixed s3 check

This commit is contained in:
vabene1111
2022-04-04 19:15:11 +02:00
parent e17da08a74
commit b7e6e7b1b0
3 changed files with 13627 additions and 3 deletions

View File

@ -10,6 +10,7 @@ from drf_writable_nested import UniqueFieldsMixin, WritableNestedModelSerializer
from rest_framework import serializers
from rest_framework.exceptions import NotFound, ValidationError
from cookbook.helper.CustomStorageClass import CachedS3Boto3Storage
from cookbook.helper.HelperFunctions import str2bool
from cookbook.helper.shopping_helper import RecipeShoppingEditor
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,
UserFile, UserPreference, ViewLog)
from cookbook.templatetags.custom_tags import markdown
from cookbook.helper.CustomStorageClass import CachedS3Boto3Storage
from recipes.settings import MEDIA_URL, AWS_S3_ENDPOINT_URL, AWS_ACCESS_KEY_ID
from recipes.settings import MEDIA_URL, AWS_ENABLED
class ExtendedRecipeMixin(serializers.ModelSerializer):
@ -55,7 +55,7 @@ class ExtendedRecipeMixin(serializers.ModelSerializer):
def get_image(self, obj):
if obj.recipe_image:
if AWS_ACCESS_KEY_ID and AWS_S3_ENDPOINT_URL:
if AWS_ENABLED:
storage = CachedS3Boto3Storage()
path = storage.url(obj.recipe_image)
else:

View File

@ -390,6 +390,8 @@ JS_REVERSE_SCRIPT_PREFIX = os.getenv('JS_REVERSE_SCRIPT_PREFIX', SCRIPT_NAME)
STATIC_URL = os.getenv('STATIC_URL', '/static/')
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', ''):
DEFAULT_FILE_STORAGE = 'cookbook.helper.CustomStorageClass.CachedS3Boto3Storage'

13622
vue/yarn.lock Normal file

File diff suppressed because it is too large Load Diff