Skip to content

Commit

Permalink
Merge pull request #3459 from mathesar-foundation/demo_fix_014
Browse files Browse the repository at this point in the history
Fix Demo mode issues
  • Loading branch information
mathemancer authored Feb 26, 2024
2 parents e011123 + c9c0862 commit 7e614f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demo/management/commands/setup_demo_template_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _setup_demo_template_db():
print("Initializing demo template database...")

template_db_name = settings.MATHESAR_DEMO_TEMPLATE
django_model = Database.current_objects.get(name=settings.DATABASES["default"]["NAME"])
django_model = Database.create_from_settings_key("default")
root_engine = create_mathesar_engine(django_model)
with root_engine.connect() as conn:
conn.execution_options(isolation_level="AUTOCOMMIT")
Expand Down
4 changes: 2 additions & 2 deletions demo/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from config.settings.production import * # noqa
from config.settings import * # noqa
from config.settings.common_settings import * # noqa
from decouple import config as decouple_config

INSTALLED_APPS += [ # noqa
Expand All @@ -10,6 +9,7 @@
"demo.middleware.LiveDemoModeMiddleware",
]

MATHESAR_MODE = 'PRODUCTION'
MATHESAR_LIVE_DEMO = True
MATHESAR_LIVE_DEMO_USERNAME = decouple_config('MATHESAR_LIVE_DEMO_USERNAME', default=None)
MATHESAR_LIVE_DEMO_PASSWORD = decouple_config('MATHESAR_LIVE_DEMO_PASSWORD', default=None)
Expand Down
8 changes: 8 additions & 0 deletions mathesar/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def main(skip_static_collection=False):
install_on_db_with_key(database_key, skip_confirm)
except IntegrityError:
continue
if getattr(settings, 'MATHESAR_LIVE_DEMO', False) is True:
management.call_command(
'createsuperuser',
'--no-input',
'--username', 'demo',
'--email', '[email protected]',
)
management.call_command('setup_demo_template_db')


def install_on_db_with_key(database_key, skip_confirm):
Expand Down

0 comments on commit 7e614f8

Please sign in to comment.