Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Move database method to utils

Roland Geider92c5870e5416
diff --git a/tasks.py b/tasks.py
index c98b9a4ac..7b8c67359 100644
--- a/tasks.py
+++ b/tasks.py
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU Affero General Public License
import os
-import sys
import time
import django
import base64
@@ -35,6 +34,7 @@ from wger.utils.main import (
get_user_config_path,
detect_listen_opts,
setup_django_environment,
+ database_exists
)
os.environ.setdefault(django.conf.ENVIRONMENT_VARIABLE, 'settings')
@@ -63,7 +63,6 @@ def start_wger(address='localhost', port=8000, extra_args=[]):
execute_from_command_line(argv)
-
@task
def bootstrap_app(settings=None, address='localhost', port=8000, browser=False, upgrade_db=False, reset_admin=False):
'''
@@ -106,29 +105,6 @@ def bootstrap_app(settings=None, address='localhost', port=8000, browser=False,
start_app(addr, port, browser=browser)
-@task
-def database_exists():
- """Detect if the database exists"""
-
- # can't be imported in global scope as they already require
- # the settings module during import
- from django.db import DatabaseError
- from django.core.exceptions import ImproperlyConfigured
- from wger.manager.models import User
-
- try:
- # TODO: Use another model, the User could be deactivated
- User.objects.count()
- except DatabaseError:
- return False
- except ImproperlyConfigured:
- print("Your settings file seems broken")
- sys.exit(0)
- else:
- return True
-
-
-
@task
def create_settings(settings_path=None, database_path=None, url=None, database_type='sqlite3', key_length=30):
if settings_path is None:
@@ -226,20 +202,6 @@ def migrate_db():
'''
call_command("migrate")
- '''
- call_command(["migrate", "core"])
- call_command(["migrate", "gym"])
- call_command(["migrate", "config"])
- call_command(["migrate", "manager"])
- call_command(["migrate", "exercises"])
- call_command(["migrate", "nutrition"])
- call_command(["migrate", "weight"])
-
- # Other apps
- call_command(["migrate", "easy_thumbnails"])
- call_command(["migrate", "tastypie"])
- '''
-
@task
def load_fixtures():
diff --git a/wger/utils/main.py b/wger/utils/main.py
index e011437dc..2d17ef07d 100644
--- a/wger/utils/main.py
+++ b/wger/utils/main.py
@@ -94,3 +94,24 @@ def setup_django_environment(settings_path):
settings_module_dir = os.path.dirname(settings_path)
sys.path.append(settings_module_dir)
os.environ[django.conf.ENVIRONMENT_VARIABLE] = '%s' % settings_module_name
+
+
+def database_exists():
+ """Detect if the database exists"""
+
+ # can't be imported in global scope as they already require
+ # the settings module during import
+ from django.db import DatabaseError
+ from django.core.exceptions import ImproperlyConfigured
+ from wger.manager.models import User
+
+ try:
+ # TODO: Use another model, the User could be deactivated
+ User.objects.count()
+ except DatabaseError:
+ return False
+ except ImproperlyConfigured:
+ print("Your settings file seems broken")
+ sys.exit(0)
+ else:
+ return True