Merge branch 'aureplop/yolo/misc' into 'yolo'
Misc fix for supportBDS See merge request !271
This commit is contained in:
commit
cf2a3f64d5
12 changed files with 49 additions and 19 deletions
|
@ -111,11 +111,11 @@ Vous pouvez maintenant installer les dépendances Python depuis le fichier
|
|||
pip install -U pip
|
||||
pip install -r requirements-devel.txt
|
||||
|
||||
Pour terminer, copier le fichier `cof/settings/secret_example.py` vers
|
||||
`cof/settings/secret.py`. Sous Linux ou Mac, préférez plutôt un lien symbolique
|
||||
pour profiter de façon transparente des mises à jour du fichier:
|
||||
Pour terminer, copier le fichier `gestioCOF/settings/secret_example.py` vers
|
||||
`gestioCOF/settings/secret.py`. Sous Linux ou Mac, préférez plutôt un lien
|
||||
symbolique pour profiter de façon transparente des mises à jour du fichier:
|
||||
|
||||
ln -s secret_example.py cof/settings/secret.py
|
||||
ln -s secret_example.py gestioCOF/settings/secret.py
|
||||
|
||||
|
||||
#### Fin d'installation
|
||||
|
|
|
@ -31,21 +31,21 @@ class Command(BaseCommand):
|
|||
def check_users(self):
|
||||
self.stdout.write("* Utilisateurs... ", ending='')
|
||||
|
||||
self.u1 = User.objects.get(username='user1')
|
||||
self.u1 = User.objects.get(username='cbds_user1')
|
||||
assert self.u1.profile.login_clipper == 'user1'
|
||||
assert self.g_staff in self.u1.groups.all()
|
||||
assert self.g_members in self.u1.groups.all()
|
||||
assert self.u1.has_perm('cof.buro')
|
||||
assert self.u1.has_perm('cof.member')
|
||||
|
||||
self.u2 = User.objects.get(username='user2')
|
||||
self.u2 = User.objects.get(username='cbds_user2')
|
||||
assert self.u2.profile.login_clipper == 'user2'
|
||||
assert self.g_staff not in self.u2.groups.all()
|
||||
assert self.g_members in self.u2.groups.all()
|
||||
assert not self.u2.has_perm('cof.buro')
|
||||
assert self.u2.has_perm('cof.member')
|
||||
|
||||
self.u3 = User.objects.get(username='user3')
|
||||
self.u3 = User.objects.get(username='cbds_user3')
|
||||
assert self.u3.profile.login_clipper == 'user3'
|
||||
assert self.g_staff not in self.u3.groups.all()
|
||||
assert self.g_members not in self.u3.groups.all()
|
||||
|
|
|
@ -34,13 +34,13 @@ def load_olddata(apps, schema_editor):
|
|||
)
|
||||
|
||||
# Setup users.
|
||||
u1 = load_user(apps, 'user1', is_cof=True)
|
||||
u1 = load_user(apps, 'cbds_user1', is_cof=True)
|
||||
u1.profile.is_buro = True
|
||||
u1.profile.save()
|
||||
|
||||
u2 = load_user(apps, 'user2', is_cof=True)
|
||||
u2 = load_user(apps, 'cbds_user2', is_cof=True)
|
||||
|
||||
u3 = load_user(apps, 'user3')
|
||||
u3 = load_user(apps, 'cbds_user3')
|
||||
|
||||
# Setup clubs.
|
||||
Club = apps.get_model('cof', 'Club')
|
||||
|
|
|
@ -4,11 +4,15 @@ from __future__ import unicode_literals
|
|||
from django.db import migrations, models
|
||||
from django.db.models import F
|
||||
|
||||
from utils.models import sqlsequencereset
|
||||
|
||||
|
||||
def profiles_to_gestion(apps, schema_editor):
|
||||
OldProfile = apps.get_model('cof', 'CofProfile')
|
||||
NewProfile = apps.get_model('gestion', 'Profile')
|
||||
|
||||
connection = schema_editor.connection
|
||||
|
||||
# New profiles are massively imported from the old profiles.
|
||||
# IDs are kept identical to ease the migration of models which were
|
||||
# referencing the CofProfile model.
|
||||
|
@ -30,6 +34,8 @@ def profiles_to_gestion(apps, schema_editor):
|
|||
|
||||
NewProfile.objects.bulk_create(new_profiles)
|
||||
|
||||
sqlsequencereset([NewProfile], conn=connection)
|
||||
|
||||
OldProfile.objects.all().update(profile_id=F('id'))
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.db import migrations
|
||||
|
||||
from utils.models import sqlsequencereset
|
||||
|
||||
|
||||
def event_to_gestion(apps, schema_editor):
|
||||
# Fetching the models that have be moved from cof to gestion
|
||||
|
@ -11,6 +13,8 @@ def event_to_gestion(apps, schema_editor):
|
|||
Location = apps.get_model('gestion', 'Location')
|
||||
Association = apps.get_model('gestion', 'Association')
|
||||
|
||||
connection = schema_editor.connection
|
||||
|
||||
# The old Event.location field becomes a table: we need to create an entry
|
||||
# in this table for each value of the old `location` field.
|
||||
locations = set() # A set to prevent duplicate entries
|
||||
|
@ -31,6 +35,8 @@ def event_to_gestion(apps, schema_editor):
|
|||
for event in new_events
|
||||
])
|
||||
|
||||
sqlsequencereset([NewEvent], conn=connection)
|
||||
|
||||
# Do not forget to link all the existing event to the COF association
|
||||
cof_assoc = Association.objects.get(name="COF")
|
||||
cof_assoc.events.add(*NewEvent.objects.all())
|
||||
|
@ -57,6 +63,7 @@ def event_to_gestion(apps, schema_editor):
|
|||
ToModel(**values)
|
||||
for values in FromModel.objects.values()
|
||||
])
|
||||
sqlsequencereset([ToModel], conn=connection)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
@ -2,6 +2,6 @@ import os
|
|||
from channels.asgi import get_channel_layer
|
||||
|
||||
if "DJANGO_SETTINGS_MODULE" not in os.environ:
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings")
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gestioCOF.settings.local")
|
||||
|
||||
channel_layer = get_channel_layer()
|
||||
|
|
|
@ -41,11 +41,11 @@ sudo -H -u ubuntu ~ubuntu/venv/bin/pip install -r /vagrant/requirements-devel.tx
|
|||
|
||||
# Préparation de Django
|
||||
cd /vagrant
|
||||
ln -s -f secret_example.py cof/settings/secret.py
|
||||
ln -s -f secret_example.py gestioCOF/settings/secret.py
|
||||
sudo -H -u ubuntu \
|
||||
DJANGO_SETTINGS_MODULE='cof.settings.dev' \
|
||||
DJANGO_SETTINGS_MODULE='gestioCOF.settings.dev' \
|
||||
bash -c ". ~/venv/bin/activate && bash provisioning/prepare_django.sh"
|
||||
/home/ubuntu/venv/bin/python manage.py collectstatic --noinput --settings cof.settings.dev
|
||||
/home/ubuntu/venv/bin/python manage.py collectstatic --noinput --settings gestioCOF.settings.dev
|
||||
|
||||
# Installation du cron pour les mails de rappels
|
||||
sudo -H -u ubuntu crontab provisioning/cron.dev
|
||||
|
@ -61,7 +61,7 @@ systemctl start worker.service
|
|||
# Mise en place du .bash_profile pour tout configurer lors du `vagrant ssh`
|
||||
cat >> ~ubuntu/.bashrc <<EOF
|
||||
# On utilise la version de développement de GestioCOF
|
||||
export DJANGO_SETTINGS_MODULE='cof.settings.dev'
|
||||
export DJANGO_SETTINGS_MODULE='gestioCOF.settings.dev'
|
||||
|
||||
# Charge le virtualenv
|
||||
source ~/venv/bin/activate
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# On utilise la version de développement de GestioCOF
|
||||
DJANGO_SETTINGS_MODULE='cof.settings.dev'
|
||||
DJANGO_SETTINGS_MODULE='gestioCOF.settings.dev'
|
||||
|
||||
# Identifiants MySQL
|
||||
DBUSER="cof_gestion"
|
||||
|
|
|
@ -8,9 +8,9 @@ User=ubuntu
|
|||
Group=ubuntu
|
||||
TimeoutSec=300
|
||||
WorkingDirectory=/vagrant
|
||||
Environment="DJANGO_SETTINGS_MODULE=cof.settings.dev"
|
||||
Environment="DJANGO_SETTINGS_MODULE=gestioCOF.settings.dev"
|
||||
ExecStart=/home/ubuntu/venv/bin/daphne -u /srv/gestiocof/gestiocof.sock \
|
||||
cof.asgi:channel_layer
|
||||
gestioCOF.asgi:channel_layer
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -9,7 +9,7 @@ User=ubuntu
|
|||
Group=ubuntu
|
||||
TimeoutSec=300
|
||||
WorkingDirectory=/vagrant
|
||||
Environment="DJANGO_SETTINGS_MODULE=cof.settings.dev"
|
||||
Environment="DJANGO_SETTINGS_MODULE=gestioCOF.settings.dev"
|
||||
ExecStart=/home/ubuntu/venv/bin/python manage.py runworker
|
||||
|
||||
[Install]
|
||||
|
|
0
utils/__init__.py
Normal file
0
utils/__init__.py
Normal file
17
utils/models.py
Normal file
17
utils/models.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from django.core.management.color import no_style
|
||||
from django.db import connection
|
||||
|
||||
|
||||
def sqlsequencereset(models, conn=connection):
|
||||
"""
|
||||
Update sequences of fields of `models`.
|
||||
|
||||
This function should be called after manually assigning a value to an
|
||||
`AutoField`.
|
||||
https://docs.djangoproject.com/en/1.11/ref/databases/#manually-specifying-values-of-auto-incrementing-primary-keys
|
||||
"""
|
||||
sequence_sql = conn.ops.sequence_reset_sql(no_style(), models)
|
||||
if sequence_sql:
|
||||
with conn.cursor() as cursor:
|
||||
for line in sequence_sql:
|
||||
cursor.execute(line)
|
Loading…
Reference in a new issue