From: Guillaume Pellerin Date: Tue, 3 Jan 2017 22:33:59 +0000 (+0100) Subject: Add default organization creation command, cleanup X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=cd1d987782ce1c87cc67e5e33c8fc6cf5be46e80;p=mezzo.git Add default organization creation command, cleanup --- diff --git a/app/bin/app.sh b/app/bin/app.sh index 1605c3e7..5ea92239 100755 --- a/app/bin/app.sh +++ b/app/bin/app.sh @@ -23,9 +23,9 @@ gid='www-data' # pip install -U https://forge.ircam.fr/p/django-eve/source/download/dev/ # pip install https://forge.ircam.fr/p/django-prestashop/source/download/master/ --src /srv/lib # pip install -U https://github.com/stephenmcd/grappelli-safe/archive/dynamic_stacked.zip -pip install django-querysetsequence==0.6.1 django==1.9.11 -#pip install django-autocomplete-light django-querysetsequence -#/usr/bin/yes | pip uninstall django-orderable +# pip install django-querysetsequence==0.6.1 django==1.9.11 +# pip install django-autocomplete-light django-querysetsequence +# /usr/bin/yes | pip uninstall django-orderable chown -R $uid:$gid $media @@ -33,10 +33,13 @@ chown -R $uid:$gid $media sh $app/bin/wait.sh # django setup +python $manage migrate python $manage wait-for-db # python $manage migrate --noinput # python $manage bower_install -- --allow-root python $manage create-admin-user +python $manage create-default-organization + # @todo searching every fixtures file in each folder python $manage loaddata $app/organization/job/fixtures/organization-job.json python $manage loaddata $app/organization/projects/fixtures/organization-projects-repositorysystems.json diff --git a/app/local_settings.py b/app/local_settings.py index 47f22b9d..cdb3e95e 100644 --- a/app/local_settings.py +++ b/app/local_settings.py @@ -34,8 +34,6 @@ ADMINS = ( SECRET_KEY = "j1qa@u$5ktqr^0_kwh@-j@*-80t$)ht!4-=ybz1xc%@3+r(r&tzefoih" NEVERCACHE_KEY = "m)u^%r@uh#r3wu0&$=#$1ogx)uy4hv93^2lt%c3@xi=^gifoj8paozijdihazefd" -DATABASE_ROUTERS = ['eve.routers.EveRouter', 'prestashop.routers.PrestaRouter'] - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', @@ -47,27 +45,6 @@ DATABASES = { }, } -if os.environ.get('EVEDB_ENV_POSTGRES_PASSWORD'): - DATABASES['eve'] = { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'eve', - 'USER': 'eve', - 'PASSWORD': os.environ.get('EVEDB_ENV_POSTGRES_PASSWORD'), - 'HOST': 'evedb', - 'PORT': '5432', - } - -if os.environ.get('PRESTADB_ENV_MYSQL_PASSWORD'): - DATABASES['prestashop'] = { - 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'USER': 'ircam_shops', # Not used with sqlite3. - 'PASSWORD': os.environ.get('PRESTADB_ENV_MYSQL_PASSWORD'), # Not used with sqlite3. - 'NAME': 'ircam_shops', - 'HOST': 'prestadb', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '3306', # Set to empty string for default. Not used with sqlite3. - } - - # EXTENSIONS AND FORMATS # Allowed Extensions for File Upload. Lower case is important. FILEBROWSER_EXTENSIONS = { diff --git a/app/organization/network/management/commands/create-default-organization.py b/app/organization/network/management/commands/create-default-organization.py new file mode 100644 index 00000000..c0590ee5 --- /dev/null +++ b/app/organization/network/management/commands/create-default-organization.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2016-2017 Ircam +# Copyright (c) 2016-2017 Guillaume Pellerin +# Copyright (c) 2016-2017 Emilie Zawadzki + +# This file is part of mezzanine-organization. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from organization.network.models import Organization + + +class Command(BaseCommand): + help = "Create a default organization if it doesn't exist." + + name = 'Default Organization' + + def handle(self, *args, **options): + organizations = Organization.objects.filter(is_host=True) + if not organizations: + organization = Organization(name=self.name, is_host=True) + organization.save() + print('Default organization created') diff --git a/docker-compose.yml b/docker-compose.yml index b4a7262e..d30b0466 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,7 +62,7 @@ app: nginx: image: nginx ports: - - "8020:80" + - "10020:80" volumes: - ./etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf volumes_from: diff --git a/env/eve.yml b/env/eve.yml deleted file mode 100644 index dffbc255..00000000 --- a/env/eve.yml +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (c) 2015 Guillaume Pellerin - -# Manifeste is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# Manifeste is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with Manifeste. If not, see . - -# Authors: -# Guillaume Pellerin - - -evedb: - image: postgres:9.5 - volumes_from: - - var - volumes: - - ./data/external/eve/postgresql/data/:/var/lib/postgresql/data - environment: - - POSTGRES_USER=eve - - POSTGRES_DB=eve - - POSTGRES_PASSWORD=q2nqzt0WGnwWé,256 - -app: - links: - - db - - evedb diff --git a/env/prestashop.yml b/env/prestashop.yml deleted file mode 100644 index b64717cf..00000000 --- a/env/prestashop.yml +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (c) 2015 Guillaume Pellerin - -# Manifeste is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# Manifeste is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with Manifeste. If not, see . - -# Authors: -# Guillaume Pellerin - - -prestadb: - image: mariadb - volumes_from: - - var - volumes: - - ./data/external/prestashop/mysql/:/var/lib/mysql - environment: - - MYSQL_ROOT_PASSWORD=mysecretpassword - - MYSQL_DATABASE=ircam_shops - - MYSQL_USER=ircam_shops - - MYSQL_PASSWORD=pUmt97e4MgR9EP4knyWea0n - -app: - links: - - db - - prestadb