Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Use regular loaddata when loading the online fixtures

Roland Geider1b6d29c3a435
diff --git a/requirements.txt b/requirements.txt
index a72ef3e39..18bd95282 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,7 +5,7 @@
# Application
bleach[css]~=6.1
crispy-bootstrap5==2023.10
-tqdm
+tqdm==4.66.1
# this is a fork of django-bootstrap-breadcrumbs
# we might need to think about migrating away from this completely
@@ -23,7 +23,7 @@ django_compressor~=4.4
django_extensions~=3.2
django-storages~=1.14
django-environ==0.11.2
-drf-spectacular[sidecar]==0.27.0
+drf-spectacular[sidecar]==0.27.1
easy-thumbnails==2.8.5
fontawesomefree~=6.5.1
icalendar==5.0.11
diff --git a/wger/core/management/commands/loaddata-progress.py b/wger/core/management/commands/loaddata-progress.py
deleted file mode 100644
index 9544af88a..000000000
--- a/wger/core/management/commands/loaddata-progress.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from django.core.management.commands.loaddata import Command as LoadDataCommand
-from django.core.management.base import BaseCommand, CommandError
-from tqdm import tqdm # Assuming you have the tqdm library installed
-
-class Command(LoadDataCommand):
- help = 'Load data from fixture files into the database with progress tracking.'
-
- def add_arguments(self, parser):
- super().add_arguments(parser)
- parser.add_argument(
- '--progress',
- action='store_true',
- dest='progress',
- help='Show progress bar for loaddata process.',
- )
-
- def handle(self, *fixture_labels, **options):
- fixture_labels = self.track_progress(fixture_labels)
- super().handle(*fixture_labels, **options)
-
- def track_progress(self, fixture_labels):
- return tqdm(fixture_labels, desc='Loading fixtures', unit='fixture', ncols=80)
-
-# Usage example:
-# python manage.py custom_loaddata --progress my_fixture.json
diff --git a/wger/tasks.py b/wger/tasks.py
index f279bfa10..3c6caf77f 100644
--- a/wger/tasks.py
+++ b/wger/tasks.py
@@ -34,22 +34,18 @@ from django.utils.crypto import get_random_string
import requests
from invoke import task
-
logger = logging.getLogger(__name__)
FIXTURE_URL = 'https://github.com/wger-project/data/raw/master/fixtures/'
@task(
help={
- 'address':
- 'Address to bind to. Default: localhost',
- 'port':
- 'Port to use. Default: 8000',
- 'settings-path':
- 'Path to settings file (absolute path). Leave empty for default',
+ 'address': 'Address to bind to. Default: localhost',
+ 'port': 'Port to use. Default: 8000',
+ 'settings-path': 'Path to settings file (absolute path). Leave empty for default',
'extra-args':
- 'Additional arguments to pass to the builtin server. Pass as string: '
- '"--arg1 --arg2=value". Default: none'
+ 'Additional arguments to pass to the builtin server. Pass as string: '
+ '"--arg1 --arg2=value". Default: none'
}
)
def start(context, address='localhost', port=8000, settings_path=None, extra_args=''):
@@ -70,10 +66,8 @@ def start(context, address='localhost', port=8000, settings_path=None, extra_arg
@task(
help={
- 'settings-path': 'Path to settings file (absolute path). Leave empty for '
- 'default',
- 'database-path': 'Path to sqlite database (absolute path). Leave empty '
- 'for default'
+ 'settings-path': 'Path to settings file (absolute path). Leave empty for default',
+ 'database-path': 'Path to sqlite database (absolute path). Leave empty for default'
}
)
def bootstrap(context, settings_path=None, database_path=None):
@@ -104,12 +98,9 @@ def bootstrap(context, settings_path=None, database_path=None):
@task(
help={
- 'settings-path': 'Path to settings file (absolute path). Leave empty for '
- 'default',
- 'database-path': 'Path to sqlite database (absolute path). Leave empty '
- 'for default',
- 'database-type': 'Database type to use. Supported: sqlite3, postgresql. Default: '
- 'sqlite3',
+ 'settings-path': 'Path to settings file (absolute path). Leave empty for default',
+ 'database-path': 'Path to sqlite database (absolute path). Leave empty for default',
+ 'database-type': 'Database type to use. Supported: sqlite3, postgresql. Default: sqlite3',
'key-length': 'Length of the generated secret key. Default: 50'
}
)
@@ -181,8 +172,7 @@ def create_settings(
settings_file.write(settings_content)
-@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for '
- 'default'})
+@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for default'})
def create_or_reset_admin(context, settings_path=None):
"""
Creates an admin user or resets the password for an existing one
@@ -207,8 +197,7 @@ def create_or_reset_admin(context, settings_path=None):
call_command("loaddata", path + "users.json")
-@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for '
- 'default'})
+@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for default'})
def migrate_db(context, settings_path=None):
"""
Run all database migrations
@@ -220,8 +209,7 @@ def migrate_db(context, settings_path=None):
call_command("migrate")
-@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for '
- 'default'})
+@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for default'})
def load_fixtures(context, settings_path=None):
"""
Loads all fixtures
@@ -261,13 +249,13 @@ def load_fixtures(context, settings_path=None):
@task(help={'settings-path': 'Path to settings file (absolute path). Leave empty for '
- 'default'})
+ 'default'})
def load_online_fixtures(context, settings_path=None):
"""
Downloads fixtures from server and installs them (at the moment only ingredients)
"""
- # Find the path to the settings and setup the django environment
+ # Find the path to the settings and set up the django environment
setup_django_environment(settings_path)
# Prepare the download
@@ -288,7 +276,8 @@ def load_online_fixtures(context, settings_path=None):
f.write(data)
pbar.update(len(data))
f.close()
- call_command("loaddata-progress", f.name)
+ print('Loading downloaded data, this may take a while...')
+ call_command("loaddata", f.name)
print('-> removing temp file')
print('')
os.unlink(f.name)