Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add stubs to sync images and videos with celery
Roland Geider5fbd58bd7848
diff --git a/extras/docker/development/settings.py b/extras/docker/development/settings.pyindex 845d1d90b..38ade751d 100644--- a/extras/docker/development/settings.py+++ b/extras/docker/development/settings.py@@ -97,6 +97,8 @@ WGER_SETTINGS["DOWNLOAD_INGREDIENT_IMAGES"] = env.str("DOWNLOAD_INGREDIENT_IMAGEWGER_SETTINGS["EXERCISE_CACHE_TTL"] = env.int("EXERCISE_CACHE_TTL", 3600)WGER_SETTINGS["MIN_ACCOUNT_AGE_TO_TRUST"] = env.int("MIN_ACCOUNT_AGE_TO_TRUST", 21) # in daysWGER_SETTINGS["SYNC_EXERCISES_CELERY"] = env.bool("SYNC_EXERCISES_CELERY", False)+WGER_SETTINGS["SYNC_EXERCISE_IMAGES_CELERY"] = env.bool("SYNC_EXERCISE_IMAGES_CELERY", False)+WGER_SETTINGS["SYNC_EXERCISE_VIDEOS_CELERY"] = env.bool("SYNC_EXERCISE_VIDEOS_CELERY", False)WGER_SETTINGS["USE_CELERY"] = env.bool("USE_CELERY", False)# Cachediff --git a/wger/exercises/tasks.py b/wger/exercises/tasks.pyindex 4d4268947..be42becc1 100644--- a/wger/exercises/tasks.py+++ b/wger/exercises/tasks.py@@ -50,6 +50,22 @@ def sync_exercises_task():delete_entries(logger.info)+def sync_images_task():+ """+ Fetches the exercise images from the default wger instance+ """+ pass+++def sync_videos_task():+ """+ Fetches the exercise videos from the default wger instance+ """+ pass++@app.on_after_finalize.connectdef setup_periodic_tasks(sender, **kwargs):if settings.WGER_SETTINGS['SYNC_EXERCISES_CELERY']:@@ -60,5 +76,27 @@ def setup_periodic_tasks(sender, **kwargs):day_of_week=random.randint(0, 6),),sync_exercises_task.s(),- name='Regularly sync exercises',+ name='Sync exercises',+ )++ if settings.WGER_SETTINGS['SYNC_EXERCISE_IMAGES_CELERY']:+ sender.add_periodic_task(+ crontab(+ hour=random.randint(0, 23),+ minute=random.randint(0, 59),+ day_of_week=random.randint(0, 6),+ ),+ sync_images_task.s(),+ name='Sync exercise images',+ )++ if settings.WGER_SETTINGS['SYNC_EXERCISE_VIDEOS_CELERY']:+ sender.add_periodic_task(+ crontab(+ hour=random.randint(0, 23),+ minute=random.randint(0, 59),+ day_of_week=random.randint(0, 6),+ ),+ sync_videos_task.s(),+ name='Sync exercise videos',)diff --git a/wger/settings_global.py b/wger/settings_global.pyindex 9f183c8b3..b317049d6 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -491,6 +491,8 @@ WGER_SETTINGS = {'EXERCISE_CACHE_TTL': 3600,'MIN_ACCOUNT_AGE_TO_TRUST': 21,'SYNC_EXERCISES_CELERY': False,+ 'SYNC_EXERCISE_IMAGES_CELERY': False,+ 'SYNC_EXERCISE_VIDEOS_CELERY': False,'TWITTER': False,'USE_CELERY': False,'USE_RECAPTCHA': False,