diff --git a/TODO.md b/TODO.md index 4e5c4a7f..6ae7c4ad 100644 --- a/TODO.md +++ b/TODO.md @@ -161,3 +161,5 @@ APPS app? * Ansible orchestration *method* (methods.py) * interdependency user <-> account with the old usermodel + +* replace running_syncdb() by db_ready() diff --git a/orchestra/apps/resources/admin.py b/orchestra/apps/resources/admin.py index 89c55a30..bcd06461 100644 --- a/orchestra/apps/resources/admin.py +++ b/orchestra/apps/resources/admin.py @@ -7,7 +7,6 @@ from orchestra.admin import ExtendedModelAdmin from orchestra.admin.filters import UsedContentTypeFilter from orchestra.admin.utils import insertattr, get_modeladmin, admin_link, admin_date from orchestra.core import services -from orchestra.utils import running_syncdb from .forms import ResourceForm from .models import Resource, ResourceData, MonitorData @@ -136,8 +135,8 @@ def resource_inline_factory(resources): return ResourceInline -if not running_syncdb(): - # not run during syncdb + +def insert_resource_inlines(): for ct, resources in Resource.objects.group_by('content_type').iteritems(): inline = resource_inline_factory(resources) model = ct.model_class() diff --git a/orchestra/apps/resources/apps.py b/orchestra/apps/resources/apps.py index 1b5d8199..87b624f5 100644 --- a/orchestra/apps/resources/apps.py +++ b/orchestra/apps/resources/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from orchestra.utils import running_syncdb +from orchestra.utils import database_ready class ResourcesConfig(AppConfig): @@ -8,6 +8,8 @@ class ResourcesConfig(AppConfig): verbose_name = 'Resources' def ready(self): - if not running_syncdb(): + if database_ready(): + from .admin import insert_resource_inlines from .models import create_resource_relation create_resource_relation() + insert_resource_inlines() diff --git a/orchestra/apps/resources/serializers.py b/orchestra/apps/resources/serializers.py index a427fa62..d2c7fa1d 100644 --- a/orchestra/apps/resources/serializers.py +++ b/orchestra/apps/resources/serializers.py @@ -1,7 +1,7 @@ from rest_framework import serializers from orchestra.api import router -from orchestra.utils import running_syncdb +from orchestra.utils import database_ready from .models import Resource, ResourceData @@ -23,7 +23,7 @@ class ResourceSerializer(serializers.ModelSerializer): # Monkey-patching section -if not running_syncdb(): +if database_ready(): # TODO why this is even loaded during syncdb? # Create nested serializers on target models for ct, resources in Resource.objects.group_by('content_type').iteritems(): diff --git a/orchestra/bin/orchestra-admin b/orchestra/bin/orchestra-admin index 084096ca..9fcee96d 100755 --- a/orchestra/bin/orchestra-admin +++ b/orchestra/bin/orchestra-admin @@ -126,6 +126,7 @@ function install_requirements () { python-dev \ bind9utils \ python-cracklib \ + libz-dev \ libxml2-dev \ libxslt1-dev \ wkhtmltopdf \ @@ -140,17 +141,21 @@ function install_requirements () { django-transaction-signals==1.0.0 \ django-celery==3.1.10 \ celery==3.1.13 \ - kombu==3.0.8 \ + kombu==3.0.23 \ + billiard==3.3.0.18 \ Markdown==2.4 \ django-debug-toolbar==1.2.1 \ djangorestframework==2.3.14 \ paramiko==1.15.1 \ + ecdsa==0.11 \ Pygments==1.6 \ django-filter==0.7 \ passlib==1.6.2 \ jsonfield==0.9.22 \ lxml==3.3.5 \ - python-dateutil==2.2" + django-nose==1.2 \ + python-dateutil==2.2 \ + django-iban==0.3.0" if $testing; then APT="${APT} \ diff --git a/orchestra/utils/options.py b/orchestra/utils/options.py index 9924e166..3df7f990 100644 --- a/orchestra/utils/options.py +++ b/orchestra/utils/options.py @@ -41,3 +41,7 @@ def send_email_template(template, context, to, email_from=None, html=None, attac def running_syncdb(): return 'migrate' in sys.argv or 'syncdb' in sys.argv or 'makemigrations' in sys.argv + + +def database_ready(): + return not running_syncdb() and 'setuppostgres' not in sys.argv diff --git a/scripts/container/deploy.sh b/scripts/container/deploy.sh index 61035b0e..047b0e5a 100755 --- a/scripts/container/deploy.sh +++ b/scripts/container/deploy.sh @@ -59,7 +59,7 @@ MANAGE="$BASE_DIR/manage.py" if [[ ! $(sudo su postgres -c "psql -lqt" | awk {'print $1'} | grep '^orchestra$') ]]; then # orchestra database does not esists # Speeding up tests, don't do this in production! - POSTGRES_VERSION=$(psql --version | head -n1 | awk {'print $3'} | cut -d'.' -f1,2) + POSTGRES_VERSION=$(psql --version | head -n1 | awk {'print $3'} | sed -r "s/(^[0-9\.]*).*/\1/") sudo sed -i "s/^#fsync =\s*.*/fsync = off/" \ /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf sudo sed -i "s/^#full_page_writes =\s*.*/full_page_writes = off/" \