]> git.parisson.com Git - mezzo.git/commitdiff
Add default organization creation command, cleanup
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 3 Jan 2017 22:33:59 +0000 (23:33 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 3 Jan 2017 22:33:59 +0000 (23:33 +0100)
app/bin/app.sh
app/local_settings.py
app/organization/network/management/commands/create-default-organization.py [new file with mode: 0644]
docker-compose.yml
env/eve.yml [deleted file]
env/prestashop.yml [deleted file]

index 1605c3e70eb39ed8e05b3a6721d3c7340a3d7c62..5ea92239ef0839a094263e5d4c35f6f449db40d3 100755 (executable)
@@ -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
index 47f22b9d4422a18fe31da1f04bd4a05bb71da481..cdb3e95e4cce12f1c62d841f7a3cf9e951e71a7b 100644 (file)
@@ -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 (file)
index 0000000..c0590ee
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+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')
index b4a7262e3c14649835207b54c0533b59d781391a..d30b0466ab61619676ebdc75b88df362f929773b 100644 (file)
@@ -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 (file)
index dffbc25..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2015 Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-# 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 <http://www.gnu.org/licenses/>.
-
-# Authors:
-# Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-
-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 (file)
index b64717c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2015 Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-# 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 <http://www.gnu.org/licenses/>.
-
-# Authors:
-# Guillaume Pellerin <guillaume.pellerin@ircam.fr>
-
-
-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