From 715e01be693de938605bd3f0037478a38e7953cb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 2 May 2019 13:17:12 +0200 Subject: Rebase migrations --- .../migrations/0091_auto_20190327_1854.py | 179 --------------------- .../migrations/0092_auto_20190327_1854.py | 179 +++++++++++++++++++++ .../0092_ishtarsiteprofile_display_srs.py | 21 --- .../migrations/0093_auto_20190429_0950.py | 53 ------ .../0093_ishtarsiteprofile_display_srs.py | 21 +++ .../migrations/0094_auto_20190429_0950.py | 53 ++++++ .../migrations/0094_auto_20190429_1041.py | 44 ----- .../migrations/0095_auto_20190429_1041.py | 44 +++++ ishtar_common/migrations/0095_tinyurl.py | 22 --- ishtar_common/migrations/0096_tinyurl.py | 22 +++ ishtar_common/models.py | 21 ++- 11 files changed, 329 insertions(+), 330 deletions(-) delete mode 100644 ishtar_common/migrations/0091_auto_20190327_1854.py create mode 100644 ishtar_common/migrations/0092_auto_20190327_1854.py delete mode 100644 ishtar_common/migrations/0092_ishtarsiteprofile_display_srs.py delete mode 100644 ishtar_common/migrations/0093_auto_20190429_0950.py create mode 100644 ishtar_common/migrations/0093_ishtarsiteprofile_display_srs.py create mode 100644 ishtar_common/migrations/0094_auto_20190429_0950.py delete mode 100644 ishtar_common/migrations/0094_auto_20190429_1041.py create mode 100644 ishtar_common/migrations/0095_auto_20190429_1041.py delete mode 100644 ishtar_common/migrations/0095_tinyurl.py create mode 100644 ishtar_common/migrations/0096_tinyurl.py (limited to 'ishtar_common') diff --git a/ishtar_common/migrations/0091_auto_20190327_1854.py b/ishtar_common/migrations/0091_auto_20190327_1854.py deleted file mode 100644 index 8fb0ea0b2..000000000 --- a/ishtar_common/migrations/0091_auto_20190327_1854.py +++ /dev/null @@ -1,179 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.18 on 2019-03-27 18:54 -from __future__ import unicode_literals - -import django.contrib.gis.db.models.fields -import django.contrib.postgres.fields.jsonb -from django.db import migrations, models -import django.db.models.deletion -import virtualtime - - -class Migration(migrations.Migration): - - dependencies = [ - ('ishtar_common', '0090_ishtarsiteprofile_locate_warehouses'), - ] - - operations = [ - migrations.CreateModel( - name='StatsCache', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('model', models.CharField(max_length=200, verbose_name='Model name')), - ('model_pk', models.IntegerField(verbose_name='Associated primary key')), - ('values', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default={})), - ('updated', models.DateTimeField(default=virtualtime.virtual_datetime.now)), - ('update_requested', models.DateTimeField(blank=True, null=True)), - ], - options={ - 'verbose_name_plural': 'Caches for stats', - 'verbose_name': 'Cache for stats', - }, - ), - migrations.AlterField( - model_name='administrationtask', - name='state', - field=models.CharField(choices=[('S', 'Planifié'), ('P', 'En cours'), ('FE', 'Terminé avec des erreurs'), ('F', 'Terminé')], default='S', max_length=2, verbose_name='État'), - ), - migrations.AlterField( - model_name='customformjsonfield', - name='label', - field=models.CharField(blank=True, default='', max_length=200, verbose_name='Dénomination'), - ), - migrations.AlterField( - model_name='document', - name='title', - field=models.TextField(blank=True, default='', verbose_name='Titre'), - ), - migrations.AlterField( - model_name='documenttemplate', - name='associated_object_name', - field=models.CharField(choices=[('archaeological_operations.models.AdministrativeAct', 'Acte administratif')], max_length=100, verbose_name='Objet associé'), - ), - migrations.AlterField( - model_name='documenttemplate', - name='template', - field=models.FileField(help_text='La taille maximale supportée pour le fichier est de 100 Mo.', upload_to='templates/%Y/', verbose_name='Patron'), - ), - migrations.AlterField( - model_name='formatertype', - name='formater_type', - field=models.CharField(choices=[('IntegerFormater', 'Entier'), ('FloatFormater', 'Nombre à virgule'), ('UnicodeFormater', 'Chaîne de caractères'), ('DateFormater', 'Date'), ('TypeFormater', 'Type'), ('YearFormater', 'Année'), ('InseeFormater', 'Code INSEE'), ('StrToBoolean', 'Chaîne de caractères vers booléen'), ('FileFormater', 'Fichier'), ('UnknowType', 'Type inconnu')], max_length=20, verbose_name='Formater type'), - ), - migrations.AlterField( - model_name='historicalorganization', - name='town', - field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), - ), - migrations.AlterField( - model_name='historicalperson', - name='old_title', - field=models.CharField(blank=True, choices=[('Mr', 'M.'), ('Ms', 'Mlle'), ('Mr and Miss', 'M. et Mme'), ('Md', 'Mme'), ('Dr', 'Dr.')], max_length=100, null=True, verbose_name='Titre'), - ), - migrations.AlterField( - model_name='historicalperson', - name='town', - field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), - ), - migrations.AlterField( - model_name='import', - name='encoding', - field=models.CharField(choices=[('windows-1252', 'windows-1252'), ('ISO-8859-15', 'ISO-8859-15'), ('utf-8', 'utf-8')], default='utf-8', max_length=15, verbose_name='Codage'), - ), - migrations.AlterField( - model_name='import', - name='error_file', - field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=255, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier erreur'), - ), - migrations.AlterField( - model_name='import', - name='imported_file', - field=models.FileField(help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=220, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier importé'), - ), - migrations.AlterField( - model_name='import', - name='imported_images', - field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=220, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Images associées (fichier zip)'), - ), - migrations.AlterField( - model_name='import', - name='match_file', - field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=255, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier de correspondance'), - ), - migrations.AlterField( - model_name='import', - name='result_file', - field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=255, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier résultant'), - ), - migrations.AlterField( - model_name='import', - name='state', - field=models.CharField(choices=[('C', 'Créé'), ('AP', 'Analyse en cours'), ('A', 'Analysé'), ('HQ', 'Vérification des modifications dans la file'), ('IQ', "Import en file d'attente"), ('HP', 'Vérification des modifications en cours'), ('IP', 'Import en cours'), ('PI', 'Importé partiellement'), ('FE', 'Terminé avec des erreurs'), ('F', 'Terminé'), ('AC', 'Archivé')], default='C', max_length=2, verbose_name='État'), - ), - migrations.AlterField( - model_name='ishtarsiteprofile', - name='archaeological_site_label', - field=models.CharField(choices=[('site', 'Site'), ('entity', 'Entité (EA)')], default='site', max_length=200, verbose_name='Type de site archéologique'), - ), - migrations.AlterField( - model_name='ishtarsiteprofile', - name='config', - field=models.CharField(blank=True, choices=[('DRASSM', 'DRASSM')], help_text='Choisir une configuration alternative pour les libellés, gestion des index', max_length=200, null=True, verbose_name='Configuration alternative'), - ), - migrations.AlterField( - model_name='ishtarsiteprofile', - name='default_center', - field=django.contrib.gis.db.models.fields.PointField(default='SRID=4326;POINT(2.4397 46.5528)', srid=4326, verbose_name='Cartes - centre par défaut'), - ), - migrations.AlterField( - model_name='ishtarsiteprofile', - name='default_zoom', - field=models.IntegerField(default=6, verbose_name='Cartes - zoom par défaut'), - ), - migrations.AlterField( - model_name='ishtarsiteprofile', - name='find_index', - field=models.CharField(choices=[('O', 'Opérations'), ('CR', "Unités d'Enregistrement")], default='O', help_text="Pour éviter des index non pertinents, ne changer ce paramètre que s'il n'y a pas encore de mobilier dans cette base de données", max_length=2, verbose_name='Index mobilier basé sur'), - ), - migrations.AlterField( - model_name='ishtarsiteprofile', - name='use_town_for_geo', - field=models.BooleanField(default=True, verbose_name='Utiliser la commune pour la localisation quand les coordonnées manques'), - ), - migrations.AlterField( - model_name='jsondatafield', - name='value_type', - field=models.CharField(choices=[('T', 'Texte'), ('LT', 'Texte long'), ('I', 'Entier'), ('B', 'Booléen'), ('F', 'Nombre à virgule'), ('D', 'Date'), ('C', 'Choix')], default='T', max_length=10, verbose_name='Type'), - ), - migrations.AlterField( - model_name='organization', - name='precise_town', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Town', verbose_name='Commune (précis)'), - ), - migrations.AlterField( - model_name='organization', - name='town', - field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), - ), - migrations.AlterField( - model_name='person', - name='old_title', - field=models.CharField(blank=True, choices=[('Mr', 'M.'), ('Ms', 'Mlle'), ('Mr and Miss', 'M. et Mme'), ('Md', 'Mme'), ('Dr', 'Dr.')], max_length=100, null=True, verbose_name='Titre'), - ), - migrations.AlterField( - model_name='person', - name='precise_town', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Town', verbose_name='Commune (précis)'), - ), - migrations.AlterField( - model_name='person', - name='town', - field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), - ), - migrations.AlterField( - model_name='town', - name='center', - field=django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=27572, verbose_name='Localisation'), - ), - ] diff --git a/ishtar_common/migrations/0092_auto_20190327_1854.py b/ishtar_common/migrations/0092_auto_20190327_1854.py new file mode 100644 index 000000000..69c6a9e56 --- /dev/null +++ b/ishtar_common/migrations/0092_auto_20190327_1854.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-03-27 18:54 +from __future__ import unicode_literals + +import django.contrib.gis.db.models.fields +import django.contrib.postgres.fields.jsonb +from django.db import migrations, models +import django.db.models.deletion +import virtualtime + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0091_auto_20190502_1223'), + ] + + operations = [ + migrations.CreateModel( + name='StatsCache', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('model', models.CharField(max_length=200, verbose_name='Model name')), + ('model_pk', models.IntegerField(verbose_name='Associated primary key')), + ('values', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default={})), + ('updated', models.DateTimeField(default=virtualtime.virtual_datetime.now)), + ('update_requested', models.DateTimeField(blank=True, null=True)), + ], + options={ + 'verbose_name_plural': 'Caches for stats', + 'verbose_name': 'Cache for stats', + }, + ), + migrations.AlterField( + model_name='administrationtask', + name='state', + field=models.CharField(choices=[('S', 'Planifié'), ('P', 'En cours'), ('FE', 'Terminé avec des erreurs'), ('F', 'Terminé')], default='S', max_length=2, verbose_name='État'), + ), + migrations.AlterField( + model_name='customformjsonfield', + name='label', + field=models.CharField(blank=True, default='', max_length=200, verbose_name='Dénomination'), + ), + migrations.AlterField( + model_name='document', + name='title', + field=models.TextField(blank=True, default='', verbose_name='Titre'), + ), + migrations.AlterField( + model_name='documenttemplate', + name='associated_object_name', + field=models.CharField(choices=[('archaeological_operations.models.AdministrativeAct', 'Acte administratif')], max_length=100, verbose_name='Objet associé'), + ), + migrations.AlterField( + model_name='documenttemplate', + name='template', + field=models.FileField(help_text='La taille maximale supportée pour le fichier est de 100 Mo.', upload_to='templates/%Y/', verbose_name='Patron'), + ), + migrations.AlterField( + model_name='formatertype', + name='formater_type', + field=models.CharField(choices=[('IntegerFormater', 'Entier'), ('FloatFormater', 'Nombre à virgule'), ('UnicodeFormater', 'Chaîne de caractères'), ('DateFormater', 'Date'), ('TypeFormater', 'Type'), ('YearFormater', 'Année'), ('InseeFormater', 'Code INSEE'), ('StrToBoolean', 'Chaîne de caractères vers booléen'), ('FileFormater', 'Fichier'), ('UnknowType', 'Type inconnu')], max_length=20, verbose_name='Formater type'), + ), + migrations.AlterField( + model_name='historicalorganization', + name='town', + field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), + ), + migrations.AlterField( + model_name='historicalperson', + name='old_title', + field=models.CharField(blank=True, choices=[('Mr', 'M.'), ('Ms', 'Mlle'), ('Mr and Miss', 'M. et Mme'), ('Md', 'Mme'), ('Dr', 'Dr.')], max_length=100, null=True, verbose_name='Titre'), + ), + migrations.AlterField( + model_name='historicalperson', + name='town', + field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), + ), + migrations.AlterField( + model_name='import', + name='encoding', + field=models.CharField(choices=[('windows-1252', 'windows-1252'), ('ISO-8859-15', 'ISO-8859-15'), ('utf-8', 'utf-8')], default='utf-8', max_length=15, verbose_name='Codage'), + ), + migrations.AlterField( + model_name='import', + name='error_file', + field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=255, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier erreur'), + ), + migrations.AlterField( + model_name='import', + name='imported_file', + field=models.FileField(help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=220, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier importé'), + ), + migrations.AlterField( + model_name='import', + name='imported_images', + field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=220, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Images associées (fichier zip)'), + ), + migrations.AlterField( + model_name='import', + name='match_file', + field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=255, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier de correspondance'), + ), + migrations.AlterField( + model_name='import', + name='result_file', + field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=255, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Fichier résultant'), + ), + migrations.AlterField( + model_name='import', + name='state', + field=models.CharField(choices=[('C', 'Créé'), ('AP', 'Analyse en cours'), ('A', 'Analysé'), ('HQ', 'Vérification des modifications dans la file'), ('IQ', "Import en file d'attente"), ('HP', 'Vérification des modifications en cours'), ('IP', 'Import en cours'), ('PI', 'Importé partiellement'), ('FE', 'Terminé avec des erreurs'), ('F', 'Terminé'), ('AC', 'Archivé')], default='C', max_length=2, verbose_name='État'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='archaeological_site_label', + field=models.CharField(choices=[('site', 'Site'), ('entity', 'Entité (EA)')], default='site', max_length=200, verbose_name='Type de site archéologique'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='config', + field=models.CharField(blank=True, choices=[('DRASSM', 'DRASSM')], help_text='Choisir une configuration alternative pour les libellés, gestion des index', max_length=200, null=True, verbose_name='Configuration alternative'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='default_center', + field=django.contrib.gis.db.models.fields.PointField(default='SRID=4326;POINT(2.4397 46.5528)', srid=4326, verbose_name='Cartes - centre par défaut'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='default_zoom', + field=models.IntegerField(default=6, verbose_name='Cartes - zoom par défaut'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='find_index', + field=models.CharField(choices=[('O', 'Opérations'), ('CR', "Unités d'Enregistrement")], default='O', help_text="Pour éviter des index non pertinents, ne changer ce paramètre que s'il n'y a pas encore de mobilier dans cette base de données", max_length=2, verbose_name='Index mobilier basé sur'), + ), + migrations.AlterField( + model_name='ishtarsiteprofile', + name='use_town_for_geo', + field=models.BooleanField(default=True, verbose_name='Utiliser la commune pour la localisation quand les coordonnées manques'), + ), + migrations.AlterField( + model_name='jsondatafield', + name='value_type', + field=models.CharField(choices=[('T', 'Texte'), ('LT', 'Texte long'), ('I', 'Entier'), ('B', 'Booléen'), ('F', 'Nombre à virgule'), ('D', 'Date'), ('C', 'Choix')], default='T', max_length=10, verbose_name='Type'), + ), + migrations.AlterField( + model_name='organization', + name='precise_town', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Town', verbose_name='Commune (précis)'), + ), + migrations.AlterField( + model_name='organization', + name='town', + field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), + ), + migrations.AlterField( + model_name='person', + name='old_title', + field=models.CharField(blank=True, choices=[('Mr', 'M.'), ('Ms', 'Mlle'), ('Mr and Miss', 'M. et Mme'), ('Md', 'Mme'), ('Dr', 'Dr.')], max_length=100, null=True, verbose_name='Titre'), + ), + migrations.AlterField( + model_name='person', + name='precise_town', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Town', verbose_name='Commune (précis)'), + ), + migrations.AlterField( + model_name='person', + name='town', + field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Commune (saisie libre)'), + ), + migrations.AlterField( + model_name='town', + name='center', + field=django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=27572, verbose_name='Localisation'), + ), + ] diff --git a/ishtar_common/migrations/0092_ishtarsiteprofile_display_srs.py b/ishtar_common/migrations/0092_ishtarsiteprofile_display_srs.py deleted file mode 100644 index 60936de59..000000000 --- a/ishtar_common/migrations/0092_ishtarsiteprofile_display_srs.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.18 on 2019-03-27 22:07 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('ishtar_common', '0091_auto_20190327_1854'), - ] - - operations = [ - migrations.AddField( - model_name='ishtarsiteprofile', - name='display_srs', - field=models.ForeignKey(blank=True, help_text='Spatial Reference System used for display when no SRS is defined', null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.SpatialReferenceSystem', verbose_name='Spatial Reference System for display'), - ), - ] diff --git a/ishtar_common/migrations/0093_auto_20190429_0950.py b/ishtar_common/migrations/0093_auto_20190429_0950.py deleted file mode 100644 index a68c91dc2..000000000 --- a/ishtar_common/migrations/0093_auto_20190429_0950.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.18 on 2019-04-29 09:50 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion -from django.utils.text import slugify - - -CLASS_NAMES = { - 'archaeological_operations.models.AdministrativeAct': "Acte administratif" -} - - -def migrate_to_model_fk(apps, schema_editor): - ImporterModel = apps.get_model('ishtar_common', 'ImporterModel') - DocumentTemplate = apps.get_model('ishtar_common', 'DocumentTemplate') - importer_models = {} - for doc in DocumentTemplate.objects.all(): - if doc.associated_object_name not in importer_models: - if doc.associated_object_name in CLASS_NAMES: - name = CLASS_NAMES[doc.associated_object_name] - else: - name = "-" - importer_models[doc.associated_object_name], __ = \ - ImporterModel.objects.get_or_create( - klass=doc.associated_object_name, - defaults={"name": name} - ) - if not doc.slug: - doc.slug = slugify(doc.name) - doc.associated_model = importer_models[doc.associated_object_name] - doc.save() - - -class Migration(migrations.Migration): - - dependencies = [ - ('ishtar_common', '0092_ishtarsiteprofile_display_srs'), - ] - - operations = [ - migrations.AlterModelOptions( - name='importermodel', - options={'ordering': ('name',), 'verbose_name': 'Model', 'verbose_name_plural': 'Models'}, - ), - migrations.AddField( - model_name='documenttemplate', - name='associated_model', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterModel'), - ), - migrations.RunPython(migrate_to_model_fk), - ] diff --git a/ishtar_common/migrations/0093_ishtarsiteprofile_display_srs.py b/ishtar_common/migrations/0093_ishtarsiteprofile_display_srs.py new file mode 100644 index 000000000..6afdfdd2b --- /dev/null +++ b/ishtar_common/migrations/0093_ishtarsiteprofile_display_srs.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-03-27 22:07 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0092_auto_20190327_1854'), + ] + + operations = [ + migrations.AddField( + model_name='ishtarsiteprofile', + name='display_srs', + field=models.ForeignKey(blank=True, help_text='Spatial Reference System used for display when no SRS is defined', null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.SpatialReferenceSystem', verbose_name='Spatial Reference System for display'), + ), + ] diff --git a/ishtar_common/migrations/0094_auto_20190429_0950.py b/ishtar_common/migrations/0094_auto_20190429_0950.py new file mode 100644 index 000000000..4d82e2034 --- /dev/null +++ b/ishtar_common/migrations/0094_auto_20190429_0950.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-04-29 09:50 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +from django.utils.text import slugify + + +CLASS_NAMES = { + 'archaeological_operations.models.AdministrativeAct': "Acte administratif" +} + + +def migrate_to_model_fk(apps, schema_editor): + ImporterModel = apps.get_model('ishtar_common', 'ImporterModel') + DocumentTemplate = apps.get_model('ishtar_common', 'DocumentTemplate') + importer_models = {} + for doc in DocumentTemplate.objects.all(): + if doc.associated_object_name not in importer_models: + if doc.associated_object_name in CLASS_NAMES: + name = CLASS_NAMES[doc.associated_object_name] + else: + name = "-" + importer_models[doc.associated_object_name], __ = \ + ImporterModel.objects.get_or_create( + klass=doc.associated_object_name, + defaults={"name": name} + ) + if not doc.slug: + doc.slug = slugify(doc.name) + doc.associated_model = importer_models[doc.associated_object_name] + doc.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0093_ishtarsiteprofile_display_srs'), + ] + + operations = [ + migrations.AlterModelOptions( + name='importermodel', + options={'ordering': ('name',), 'verbose_name': 'Model', 'verbose_name_plural': 'Models'}, + ), + migrations.AddField( + model_name='documenttemplate', + name='associated_model', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterModel'), + ), + migrations.RunPython(migrate_to_model_fk), + ] diff --git a/ishtar_common/migrations/0094_auto_20190429_1041.py b/ishtar_common/migrations/0094_auto_20190429_1041.py deleted file mode 100644 index 58f3231e8..000000000 --- a/ishtar_common/migrations/0094_auto_20190429_1041.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.18 on 2019-04-29 10:41 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('ishtar_common', '0093_auto_20190429_0950'), - ] - - operations = [ - migrations.AlterModelOptions( - name='documenttemplate', - options={'ordering': ['associated_model', 'name'], 'verbose_name': 'Patron de document', 'verbose_name_plural': 'Patrons de document'}, - ), - migrations.RemoveField( - model_name='documenttemplate', - name='associated_object_name', - ), - migrations.AddField( - model_name='documenttemplate', - name='for_labels', - field=models.BooleanField(default=False, verbose_name='Used for labels'), - ), - migrations.AddField( - model_name='documenttemplate', - name='label_per_page', - field=models.IntegerField(blank=True, help_text='Only relevant for label template', null=True, verbose_name='Number of label per page'), - ), - migrations.AlterField( - model_name='documenttemplate', - name='associated_model', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterModel'), - ), - migrations.AlterField( - model_name='documenttemplate', - name='slug', - field=models.SlugField(max_length=100, unique=True, verbose_name='Identifiant texte'), - ), - ] diff --git a/ishtar_common/migrations/0095_auto_20190429_1041.py b/ishtar_common/migrations/0095_auto_20190429_1041.py new file mode 100644 index 000000000..c73f9cb77 --- /dev/null +++ b/ishtar_common/migrations/0095_auto_20190429_1041.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-04-29 10:41 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0094_auto_20190429_0950'), + ] + + operations = [ + migrations.AlterModelOptions( + name='documenttemplate', + options={'ordering': ['associated_model', 'name'], 'verbose_name': 'Patron de document', 'verbose_name_plural': 'Patrons de document'}, + ), + migrations.RemoveField( + model_name='documenttemplate', + name='associated_object_name', + ), + migrations.AddField( + model_name='documenttemplate', + name='for_labels', + field=models.BooleanField(default=False, verbose_name='Used for labels'), + ), + migrations.AddField( + model_name='documenttemplate', + name='label_per_page', + field=models.IntegerField(blank=True, help_text='Only relevant for label template', null=True, verbose_name='Number of label per page'), + ), + migrations.AlterField( + model_name='documenttemplate', + name='associated_model', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterModel'), + ), + migrations.AlterField( + model_name='documenttemplate', + name='slug', + field=models.SlugField(max_length=100, unique=True, verbose_name='Identifiant texte'), + ), + ] diff --git a/ishtar_common/migrations/0095_tinyurl.py b/ishtar_common/migrations/0095_tinyurl.py deleted file mode 100644 index dfe752c8c..000000000 --- a/ishtar_common/migrations/0095_tinyurl.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.18 on 2019-05-01 16:04 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('ishtar_common', '0094_auto_20190429_1041'), - ] - - operations = [ - migrations.CreateModel( - name='TinyUrl', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('link', models.URLField()), - ], - ), - ] diff --git a/ishtar_common/migrations/0096_tinyurl.py b/ishtar_common/migrations/0096_tinyurl.py new file mode 100644 index 000000000..58d5ce385 --- /dev/null +++ b/ishtar_common/migrations/0096_tinyurl.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.18 on 2019-05-01 16:04 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0095_auto_20190429_1041'), + ] + + operations = [ + migrations.CreateModel( + name='TinyUrl', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('link', models.URLField()), + ], + ), + ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index e5721d922..15b341cb7 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -37,6 +37,9 @@ import time from io import BytesIO from subprocess import Popen, PIPE from PIL import Image +from ooopy.OOoPy import OOoPy +from ooopy.Transformer import Transformer as OOTransformer +import ooopy.Transforms as OOTransforms from django import forms from django.apps import apps @@ -3221,20 +3224,16 @@ class DocumentTemplate(models.Model): output = open(output_name, 'wb') output.write(result) output_name = main_output_name + suffix - # TODO: merge docs - return the last for now - from ooopy.OOoPy import OOoPy - from ooopy.Transformer import Transformer - import ooopy.Transforms as Transforms o = OOoPy(infile=names[0], outfile=output_name) if len(names) > 1: - t = Transformer( + t = OOTransformer( o.mimetype, - Transforms.get_meta(o.mimetype), - Transforms.Concatenate(*(names[1:])), - Transforms.renumber_all(o.mimetype), - Transforms.set_meta(o.mimetype), - Transforms.Fix_OOo_Tag(), - Transforms.Manifest_Append() + OOTransforms.get_meta(o.mimetype), + OOTransforms.Concatenate(*(names[1:])), + OOTransforms.renumber_all(o.mimetype), + OOTransforms.set_meta(o.mimetype), + OOTransforms.Fix_OOo_Tag(), + OOTransforms.Manifest_Append() ) t.transform (o) o.close() -- cgit v1.2.3