From f7f9d0bd6dce242b25f68d84a27808de88dc551e Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Mon, 4 Jul 2016 11:12:22 +0200 Subject: [PATCH] Revert most ordering changes in 1.1.5rc's, Restore patched dumpdata --- .../migrations/0004_auto_20160704_1109.py | 19 +++++++++++++++ beat/web/common/models.py | 5 ++-- .../migrations/0005_auto_20160704_1109.py | 19 +++++++++++++++ beat/web/databases/models.py | 5 ---- .../migrations/0003_auto_20160704_1109.py | 19 +++++++++++++++ .../migrations/0004_auto_20160704_1109.py | 19 +++++++++++++++ .../migrations/0004_auto_20160704_1109.py | 23 +++++++++++++++++++ .../migrations/0004_auto_20160704_1109.py | 19 +++++++++++++++ beat/web/utils/management/commands/backup.py | 4 ++-- .../commands/{beatdump.py => xdumpdata.py} | 15 ++++++++---- 10 files changed, 132 insertions(+), 15 deletions(-) create mode 100644 beat/web/algorithms/migrations/0004_auto_20160704_1109.py create mode 100644 beat/web/databases/migrations/0005_auto_20160704_1109.py create mode 100644 beat/web/dataformats/migrations/0003_auto_20160704_1109.py create mode 100644 beat/web/libraries/migrations/0004_auto_20160704_1109.py create mode 100644 beat/web/plotters/migrations/0004_auto_20160704_1109.py create mode 100644 beat/web/toolchains/migrations/0004_auto_20160704_1109.py rename beat/web/utils/management/commands/{beatdump.py => xdumpdata.py} (93%) diff --git a/beat/web/algorithms/migrations/0004_auto_20160704_1109.py b/beat/web/algorithms/migrations/0004_auto_20160704_1109.py new file mode 100644 index 000000000..c1ba409b4 --- /dev/null +++ b/beat/web/algorithms/migrations/0004_auto_20160704_1109.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-07-04 11:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('algorithms', '0003_auto_20160701_1707'), + ] + + operations = [ + migrations.AlterModelOptions( + name='algorithm', + options={'ordering': ['author__username', 'name', 'version']}, + ), + ] diff --git a/beat/web/common/models.py b/beat/web/common/models.py index 382330ff7..66e680a07 100644 --- a/beat/web/common/models.py +++ b/beat/web/common/models.py @@ -381,9 +381,7 @@ class Versionable(Shareable): class Meta(Shareable.Meta): abstract = True - - # setup ordering so that the dump order respects self dependencies - ordering = ['version', 'id'] + ordering = ['name', '-version'] #_____ Static Methods __________ @@ -554,6 +552,7 @@ class Contribution(Versionable): class Meta(Versionable.Meta): abstract = True + ordering = ['author__username', 'name', 'version'] unique_together = ('author', 'name', 'version') diff --git a/beat/web/databases/migrations/0005_auto_20160704_1109.py b/beat/web/databases/migrations/0005_auto_20160704_1109.py new file mode 100644 index 000000000..08830e327 --- /dev/null +++ b/beat/web/databases/migrations/0005_auto_20160704_1109.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-07-04 11:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('databases', '0004_auto_20160701_1707'), + ] + + operations = [ + migrations.AlterModelOptions( + name='database', + options={'ordering': ['name', '-version']}, + ), + ] diff --git a/beat/web/databases/models.py b/beat/web/databases/models.py index eeba459ca..c4cb27213 100755 --- a/beat/web/databases/models.py +++ b/beat/web/databases/models.py @@ -192,11 +192,6 @@ class Database(Versionable): class Meta(Versionable.Meta): unique_together = ('name', 'version') - # setup ordering so that the dump order respects self dependencies - # note: Versionable already has the right ordering - not sure why - # `django makemigrations' is not detecting it though. - ordering = ['version', 'id'] - #_____ Utilities __________ diff --git a/beat/web/dataformats/migrations/0003_auto_20160704_1109.py b/beat/web/dataformats/migrations/0003_auto_20160704_1109.py new file mode 100644 index 000000000..b434ca036 --- /dev/null +++ b/beat/web/dataformats/migrations/0003_auto_20160704_1109.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-07-04 11:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('dataformats', '0002_auto_20160701_1712'), + ] + + operations = [ + migrations.AlterModelOptions( + name='dataformat', + options={'ordering': ['author__username', 'name', 'version'], 'verbose_name': 'dataformat', 'verbose_name_plural': 'dataformats'}, + ), + ] diff --git a/beat/web/libraries/migrations/0004_auto_20160704_1109.py b/beat/web/libraries/migrations/0004_auto_20160704_1109.py new file mode 100644 index 000000000..6d541b08d --- /dev/null +++ b/beat/web/libraries/migrations/0004_auto_20160704_1109.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-07-04 11:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('libraries', '0003_auto_20160701_1707'), + ] + + operations = [ + migrations.AlterModelOptions( + name='library', + options={'ordering': ['author__username', 'name', 'version'], 'verbose_name_plural': 'libraries'}, + ), + ] diff --git a/beat/web/plotters/migrations/0004_auto_20160704_1109.py b/beat/web/plotters/migrations/0004_auto_20160704_1109.py new file mode 100644 index 000000000..e7de40106 --- /dev/null +++ b/beat/web/plotters/migrations/0004_auto_20160704_1109.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-07-04 11:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('plotters', '0003_auto_20160701_1707'), + ] + + operations = [ + migrations.AlterModelOptions( + name='plotter', + options={'ordering': ['author__username', 'name', 'version']}, + ), + migrations.AlterModelOptions( + name='plotterparameter', + options={'ordering': ['author__username', 'name', 'version']}, + ), + ] diff --git a/beat/web/toolchains/migrations/0004_auto_20160704_1109.py b/beat/web/toolchains/migrations/0004_auto_20160704_1109.py new file mode 100644 index 000000000..555d2d6dc --- /dev/null +++ b/beat/web/toolchains/migrations/0004_auto_20160704_1109.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.5 on 2016-07-04 11:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('toolchains', '0003_auto_20160701_1707'), + ] + + operations = [ + migrations.AlterModelOptions( + name='toolchain', + options={'ordering': ['author__username', 'name', 'version']}, + ), + ] diff --git a/beat/web/utils/management/commands/backup.py b/beat/web/utils/management/commands/backup.py index 3c0598ab0..1245b207e 100644 --- a/beat/web/utils/management/commands/backup.py +++ b/beat/web/utils/management/commands/backup.py @@ -149,7 +149,7 @@ class Command(BaseCommand): destfile = os.path.join(tmpdir, 'initial.json') logger.info("Dumping initial (unspecified) data -> `%s'", destfile) arguments['output'] = destfile #new in Django-1.8.x - call_command('beatdump', **arguments) + call_command('xdumpdata', **arguments) # and backs-up the apps respecting the imposed order for app in use_apps: @@ -159,7 +159,7 @@ class Command(BaseCommand): logger.info("Dumping data for `%s' -> `%s'", app, destfile) arguments['output'] = destfile #new in Django-1.8.x - call_command('beatdump', only.get(app, app), **arguments) + call_command('xdumpdata', only.get(app, app), **arguments) # copy prefix data path = os.path.join(settings.PREFIX, app) diff --git a/beat/web/utils/management/commands/beatdump.py b/beat/web/utils/management/commands/xdumpdata.py similarity index 93% rename from beat/web/utils/management/commands/beatdump.py rename to beat/web/utils/management/commands/xdumpdata.py index 76f1886fb..fcddbea38 100644 --- a/beat/web/utils/management/commands/beatdump.py +++ b/beat/web/utils/management/commands/xdumpdata.py @@ -150,14 +150,19 @@ class Command(BaseCommand): else: objects = model._default_manager - # BEAT PATCH: let default order take place + # ################################################### + # patch for BEAT starts here: respect self ordering + # ################################################### queryset = objects.using(using) - # ORIGINAL LINE - #queryset = objects.using(using).order_by(model._meta.pk.name) if primary_keys: - queryset = queryset.filter(pk__in=primary_keys) - if count_only: + # in case the user specifies PKs, respect order + for pk in [int(k) for k in primary_keys]: + yield queryset.get(pk=pk) + elif count_only: + # ################################################### + # patch for BEAT ends here + # ################################################### yield queryset.order_by().count() else: for obj in queryset.iterator(): -- GitLab