Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Demo mode issues #3459

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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', 'admin@example.com',
)
management.call_command('setup_demo_template_db')


def install_on_db_with_key(database_key, skip_confirm):
Expand Down