diff --git a/resources/saleor/2.11.1-populatedb.py b/resources/saleor/2.11.1-populatedb.py index 5811b4e..94aa7d9 100644 --- a/resources/saleor/2.11.1-populatedb.py +++ b/resources/saleor/2.11.1-populatedb.py @@ -1,5 +1,6 @@ from io import StringIO import os.path + from django.apps import apps from django.conf import settings from django.core.management import call_command @@ -22,7 +23,9 @@ from ...utils.random_data import ( create_warehouses, set_homepage_collection, ) - + +ADMIN_EMAIL = os.environ.get("ADMIN_EMAIL") +ADMIN_PASS = os.environ.get("ADMIN_PASS") class Command(BaseCommand): help = "Populate database with test objects" @@ -43,6 +46,13 @@ class Command(BaseCommand): default=False, help="Create sample products, etc..", ) + parser.add_argument( + "--fastdata", + action="store_true", + dest="fastdata", + default=False, + help="Sacrifice some of the safeguards of sqlite3 for speed.", + ) parser.add_argument( "--withoutimages", action="store_true", @@ -50,6 +60,13 @@ class Command(BaseCommand): default=False, help="Don't create product images", ) + parser.add_argument( + "--withoutsearch", + action="store_true", + dest="withoutsearch", + default=False, + help="Don't update search index", + ) parser.add_argument( "--skipsequencereset", action="store_true", @@ -60,7 +77,6 @@ class Command(BaseCommand): def make_database_faster(self): """Sacrifice some of the safeguards of sqlite3 for speed. - Users are not likely to run this command in a production environment. They are even less likely to run it in production while using sqlite3. """ @@ -71,7 +87,6 @@ class Command(BaseCommand): def sequence_reset(self): """Run a SQL sequence reset on all saleor.* apps. - When a value is manually assigned to an auto-incrementing field it doesn't update the field's sequence, which might cause a conflict later on. @@ -93,18 +108,11 @@ class Command(BaseCommand): "saleor.payment.gateways.dummy_credit_card.plugin." "DummyCreditCardGatewayPlugin", ] - - ADMIN_EMAIL = os.environ.get("ADMIN_EMAIL") - ADMIN_PASS = os.environ.get("ADMIN_PASS") - if options["createsuperuser"]: - credentials = {"email": ADMIN_EMAIL, "password": ADMIN_PASS} - msg = create_superuser(credentials) - self.stdout.write(msg) - add_address_to_admin(credentials["email"]) + if options["fastdata"]: + self.make_database_faster() if options["sampledata"]: - self.make_database_faster() create_images = not options["withoutimages"] for msg in create_shipping_zones(): self.stdout.write(msg) @@ -128,9 +136,15 @@ class Command(BaseCommand): self.stdout.write(msg) for msg in create_menus(): self.stdout.write(msg) - + + if options["createsuperuser"]: + credentials = {"email": ADMIN_EMAIL, "password": ADMIN_PASS} + msg = create_superuser(credentials) + self.stdout.write(msg) + add_address_to_admin(credentials["email"]) + if not options["skipsequencereset"]: self.sequence_reset() for msg in create_permission_groups(): - self.stdout.write(msg) + self.stdout.write(msg) \ No newline at end of file diff --git a/resources/saleor/2.11.1-settings.py b/resources/saleor/2.11.1-settings.py index 3bed3f2..735f9ae 100644 --- a/resources/saleor/2.11.1-settings.py +++ b/resources/saleor/2.11.1-settings.py @@ -10,7 +10,6 @@ import jaeger_client import jaeger_client.config import pkg_resources import sentry_sdk -import sentry_sdk.utils from django.core.exceptions import ImproperlyConfigured from django.core.management.utils import get_random_secret_key from pytimeparse import parse @@ -44,7 +43,7 @@ def get_bool_from_env(name, default_value): return default_value -DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False' +DEBUG = get_bool_from_env("DEBUG", False) SITE_ID = 1 @@ -167,7 +166,7 @@ ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL = get_bool_from_env( "ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL", True ) -ENABLE_SSL = True +ENABLE_SSL = get_bool_from_env("ENABLE_SSL", True) if ENABLE_SSL: SECURE_SSL_REDIRECT = not DEBUG @@ -351,7 +350,7 @@ LOGGING = { "saleor": {"level": "DEBUG", "propagate": True}, "saleor.graphql.errors.handled": { "handlers": ["default"], - "level": "INFO", + "level": "ERROR", "propagate": False, }, "graphql.execution.utils": {"propagate": False}, @@ -378,6 +377,9 @@ DEFAULT_CURRENCY_CODE_LENGTH = 3 # Following the recommendation of https://tools.ietf.org/html/rfc5322#section-2.1.1 DEFAULT_MAX_EMAIL_DISPLAY_NAME_LENGTH = 78 +# note: having multiple currencies is not supported yet +AVAILABLE_CURRENCIES = [DEFAULT_CURRENCY] + COUNTRIES_OVERRIDE = {"EU": "European Union"} OPENEXCHANGERATES_API_KEY = os.environ.get("OPENEXCHANGERATES_API_KEY") @@ -427,10 +429,6 @@ GS_PROJECT_ID = os.environ.get("GS_PROJECT_ID") GS_STORAGE_BUCKET_NAME = os.environ.get("GS_STORAGE_BUCKET_NAME") GS_MEDIA_BUCKET_NAME = os.environ.get("GS_MEDIA_BUCKET_NAME") GS_AUTO_CREATE_BUCKET = get_bool_from_env("GS_AUTO_CREATE_BUCKET", False) -GS_QUERYSTRING_AUTH = get_bool_from_env("GS_QUERYSTRING_AUTH", False) -GS_DEFAULT_ACL = os.environ.get("GS_DEFAULT_ACL", None) -GS_MEDIA_CUSTOM_ENDPOINT = os.environ.get("GS_MEDIA_CUSTOM_ENDPOINT", None) -GS_EXPIRATION = os.environ.get("GS_EXPIRATION", None) # If GOOGLE_APPLICATION_CREDENTIALS is set there is no need to load OAuth token # See https://django-storages.readthedocs.io/en/latest/backends/gcloud.html @@ -498,15 +496,13 @@ CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", None) # e.g. HTTP_CF_Connecting_IP for Cloudflare or X_FORWARDED_FOR REAL_IP_ENVIRON = os.environ.get("REAL_IP_ENVIRON", "REMOTE_ADDR") +# The maximum length of a graphql query to log in tracings +OPENTRACING_MAX_QUERY_LENGTH_LOG = 2000 + # Slugs for menus precreated in Django migrations DEFAULT_MENUS = {"top_menu_name": "navbar", "bottom_menu_name": "footer"} -# Slug for channel precreated in Django migrations -DEFAULT_CHANNEL_SLUG = os.environ.get("DEFAULT_CHANNEL_SLUG", "default-channel") - - # Sentry -sentry_sdk.utils.MAX_STRING_LENGTH = 4096 SENTRY_DSN = os.environ.get("SENTRY_DSN") if SENTRY_DSN: sentry_sdk.init( @@ -598,4 +594,4 @@ JWT_TTL_REFRESH = timedelta(seconds=parse(os.environ.get("JWT_TTL_REFRESH", "30 JWT_TTL_REQUEST_EMAIL_CHANGE = timedelta( seconds=parse(os.environ.get("JWT_TTL_REQUEST_EMAIL_CHANGE", "1 hour")), -) +) \ No newline at end of file diff --git a/resources/saleor/template.env b/resources/saleor/template.env index 2405123..a04cf1f 100644 --- a/resources/saleor/template.env +++ b/resources/saleor/template.env @@ -26,4 +26,5 @@ MEDIA_URL="{media}" #GOOGLE_ANALYTICS_TRACKING_ID="{gatid}" ADMIN_EMAIL="{adminemail}" -DEBUG=False \ No newline at end of file +DEBUG=False +ENABLE_SSL=True \ No newline at end of file