diff --git a/beat/web/algorithms/migrations/0002_auto_20160630_1644.py b/beat/web/algorithms/migrations/0002_auto_20160630_1644.py deleted file mode 100644 index b2922b3c15d0afdff73698f2783fa7c81dd860e8..0000000000000000000000000000000000000000 --- a/beat/web/algorithms/migrations/0002_auto_20160630_1644.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.5 on 2016-06-30 16:44 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('algorithms', '0001_initial'), - ] - - operations = [ - migrations.AlterModelOptions( - name='algorithm', - options={'ordering': ['previous_version_id', 'fork_of_id', 'id']}, - ), - ] diff --git a/beat/web/algorithms/migrations/0003_auto_20160701_1707.py b/beat/web/algorithms/migrations/0003_auto_20160701_1707.py deleted file mode 100644 index 36700aa4e0a1bfb6817cfcab3a9620cba1f23ac9..0000000000000000000000000000000000000000 --- a/beat/web/algorithms/migrations/0003_auto_20160701_1707.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2016-07-01 17:07 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('algorithms', '0002_auto_20160630_1644'), - ] - - operations = [ - migrations.AlterModelOptions( - name='algorithm', - options={'ordering': ['version', 'id']}, - ), - ] diff --git a/beat/web/common/models.py b/beat/web/common/models.py index 382330ff779568845238d2988e4ba74a14a2ae55..66e680a071844d6d34f3280d3cfd6e300e104701 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/0003_auto_20160630_1710.py b/beat/web/databases/migrations/0003_auto_20160704_1316.py similarity index 71% rename from beat/web/databases/migrations/0003_auto_20160630_1710.py rename to beat/web/databases/migrations/0003_auto_20160704_1316.py index 9ba33dccc92e3121332148dfddb20d2aabd8d523..575732e942c2085e146b3697b3c75e0c1ff578b5 100644 --- a/beat/web/databases/migrations/0003_auto_20160630_1710.py +++ b/beat/web/databases/migrations/0003_auto_20160704_1316.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.5 on 2016-06-30 17:10 +# Generated by Django 1.9.4 on 2016-07-04 13:16 from __future__ import unicode_literals from django.db import migrations @@ -14,6 +14,6 @@ class Migration(migrations.Migration): operations = [ migrations.AlterModelOptions( name='database', - options={'ordering': ['previous_version_id', 'fork_of_id', 'id']}, + options={'ordering': ['name', '-version']}, ), ] diff --git a/beat/web/databases/migrations/0004_auto_20160701_1707.py b/beat/web/databases/migrations/0004_auto_20160701_1707.py deleted file mode 100644 index f56c20d59654ea7d76e5a2e5b474a82b6f071e3d..0000000000000000000000000000000000000000 --- a/beat/web/databases/migrations/0004_auto_20160701_1707.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2016-07-01 17:07 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('databases', '0003_auto_20160630_1710'), - ] - - operations = [ - migrations.AlterModelOptions( - name='database', - options={'ordering': ['version', 'id']}, - ), - ] diff --git a/beat/web/databases/models.py b/beat/web/databases/models.py index eeba459ca0dda08492bd47f9482421a0e196e72b..c4cb27213f48cf0987040d07b085d4e73fea90e0 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/0002_auto_20160701_1712.py b/beat/web/dataformats/migrations/0002_auto_20160704_1319.py similarity index 70% rename from beat/web/dataformats/migrations/0002_auto_20160701_1712.py rename to beat/web/dataformats/migrations/0002_auto_20160704_1319.py index 6bfb8fe68b89d7386ebeba414136a932d5b8732f..c950a9e8f2e4a077c7da3540d0566ca7b2575a79 100644 --- a/beat/web/dataformats/migrations/0002_auto_20160701_1712.py +++ b/beat/web/dataformats/migrations/0002_auto_20160704_1319.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2016-07-01 17:12 +# Generated by Django 1.9.4 on 2016-07-04 13:19 from __future__ import unicode_literals from django.db import migrations @@ -14,7 +14,7 @@ class Migration(migrations.Migration): operations = [ migrations.AlterModelOptions( name='dataformat', - options={'ordering': ['version', 'id'], 'verbose_name': 'dataformat', 'verbose_name_plural': 'dataformats'}, + options={'ordering': ['author__username', 'name', 'version'], 'verbose_name': 'dataformat', 'verbose_name_plural': 'dataformats'}, ), migrations.AlterUniqueTogether( name='dataformat', diff --git a/beat/web/experiments/migrations/0006_auto_20160630_1644.py b/beat/web/experiments/migrations/0006_auto_20160630_1644.py deleted file mode 100644 index 6a5e22b5dc9595f74225811af07fc589f48acc76..0000000000000000000000000000000000000000 --- a/beat/web/experiments/migrations/0006_auto_20160630_1644.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python -# vim: set fileencoding=utf-8 : - -############################################################################### -# # -# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/ # -# Contact: beat.support@idiap.ch # -# # -# This file is part of the beat.web module of the BEAT platform. # -# # -# Commercial License Usage # -# Licensees holding valid commercial BEAT licenses may use this file in # -# accordance with the terms contained in a written agreement between you # -# and Idiap. For further information contact tto@idiap.ch # -# # -# Alternatively, this file may be used under the terms of the GNU Affero # -# Public License version 3 as published by the Free Software and appearing # -# in the file LICENSE.AGPL included in the packaging of this file. # -# The BEAT platform 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. # -# # -# You should have received a copy of the GNU Affero Public License along # -# with the BEAT platform. If not, see http://www.gnu.org/licenses/. # -# # -############################################################################### - -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('experiments', '0005_scheduler_addons_4'), - ] - - operations = [ - migrations.AlterModelOptions( - name='block', - options={'ordering': ['id']}, - ), - ] diff --git a/beat/web/experiments/migrations/0007_auto_20160701_0909.py b/beat/web/experiments/migrations/0006_block_order.py similarity index 98% rename from beat/web/experiments/migrations/0007_auto_20160701_0909.py rename to beat/web/experiments/migrations/0006_block_order.py index 7ccca4467a7887803dc97a7cbbce5e484bdd5533..4f83b5d17c60367a19c3cca876549e8a629cebe9 100644 --- a/beat/web/experiments/migrations/0007_auto_20160701_0909.py +++ b/beat/web/experiments/migrations/0006_block_order.py @@ -80,7 +80,7 @@ def set_block_order(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ('experiments', '0006_auto_20160630_1644'), + ('experiments', '0005_scheduler_addons_4'), ] operations = [ diff --git a/beat/web/experiments/templates/experiments/view.html b/beat/web/experiments/templates/experiments/view.html index f377187845c5f3a86924e0f0782ea8f4ae45504a..f464825bedf47f94c0a73357dfeedd1ea89ecba9 100644 --- a/beat/web/experiments/templates/experiments/view.html +++ b/beat/web/experiments/templates/experiments/view.html @@ -198,7 +198,7 @@ <div class="panel-heading" role="tab" id="heading-{{ block.name }}"> <h4 class="panel-title"> - <a{% if not error_report and block.done and block_status != 'Cancelled' %} class="collapsed"{% endif %} role="button" data-toggle="collapse" data-parent="#{{ block.name }}" href="#collapse-{{ block.name }}" aria-expanded="{% if not error_report and block.done and block_status != 'Cancelled' %}true{% else %}false{% endif %}" aria-controls="collapse-{{ block.name }}"> + <a{% if error_report and block.done and block_status != 'Cancelled' %}{% else %} class="collapsed"{% endif %} role="button" data-toggle="collapse" data-parent="#{{ block.name }}" href="#collapse-{{ block.name }}" aria-expanded="{% if error_report and block.done and block_status != 'Cancelled' %}false{% else %}true{% endif %}" aria-controls="collapse-{{ block.name }}"> <i data-toggle="tooltip" data-placement="bottom" title="{{ block_status }}" {% if block_status == 'Not cached' %} class="icon-scheduled fa fa-play" @@ -218,7 +218,7 @@ </a> </h4> </div>{# panel heading #} - <div id="collapse-{{ block.name }}" class="panel-collapse collapse{% if not error_report and block.done and block_status != 'Cancelled' %} in{% endif %}" role="tabpanel" aria-labelledby="heading-{{ block.name }}"> + <div id="collapse-{{ block.name }}" class="panel-collapse collapse{% if error_report and block.done and block_status != 'Cancelled' %} in{% endif %}" role="tabpanel" aria-labelledby="heading-{{ block.name }}"> <div class="panel-body"> <ul> <li>Algorithm: <a href="{{ block.algorithm.get_absolute_url }}">{{ block.algorithm.fullname }}</a></li> @@ -256,7 +256,7 @@ </li> {% endif %} {% if block.done and block_status != 'Cancelled' %} - {% if error_report %} + {% if error_report and block_status != 'Cached' %} <li>Captured Errors (on user code): <pre class="console-output">{{ error_report }}</pre> </li> diff --git a/beat/web/libraries/migrations/0002_auto_20160630_1644.py b/beat/web/libraries/migrations/0002_auto_20160630_1644.py deleted file mode 100644 index 50dd6910c64d55220058c966c9454da993388bd7..0000000000000000000000000000000000000000 --- a/beat/web/libraries/migrations/0002_auto_20160630_1644.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.5 on 2016-06-30 16:44 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('libraries', '0001_initial'), - ] - - operations = [ - migrations.AlterModelOptions( - name='library', - options={'ordering': ['previous_version_id', 'fork_of_id', 'id'], 'verbose_name_plural': 'libraries'}, - ), - ] diff --git a/beat/web/libraries/migrations/0003_auto_20160701_1707.py b/beat/web/libraries/migrations/0003_auto_20160701_1707.py deleted file mode 100644 index 2e8dafe92ab7fcdf8910f726facea6350b5a0a5c..0000000000000000000000000000000000000000 --- a/beat/web/libraries/migrations/0003_auto_20160701_1707.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2016-07-01 17:07 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('libraries', '0002_auto_20160630_1644'), - ] - - operations = [ - migrations.AlterModelOptions( - name='library', - options={'ordering': ['version', 'id'], 'verbose_name_plural': 'libraries'}, - ), - ] diff --git a/beat/web/plotters/migrations/0002_auto_20160630_1644.py b/beat/web/plotters/migrations/0002_auto_20160630_1644.py deleted file mode 100644 index 97cac19ceed54a925ab53d8262f16cd60f3934ce..0000000000000000000000000000000000000000 --- a/beat/web/plotters/migrations/0002_auto_20160630_1644.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.5 on 2016-06-30 16:44 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('plotters', '0001_initial'), - ] - - operations = [ - migrations.AlterModelOptions( - name='plotter', - options={'ordering': ['previous_version_id', 'fork_of_id', 'id']}, - ), - migrations.AlterModelOptions( - name='plotterparameter', - options={'ordering': ['previous_version_id', 'fork_of_id', 'id']}, - ), - ] diff --git a/beat/web/plotters/migrations/0003_auto_20160701_1707.py b/beat/web/plotters/migrations/0003_auto_20160701_1707.py deleted file mode 100644 index cd1e2c23695839a9c42466a5a927f8fa2c17740e..0000000000000000000000000000000000000000 --- a/beat/web/plotters/migrations/0003_auto_20160701_1707.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2016-07-01 17:07 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('plotters', '0002_auto_20160630_1644'), - ] - - operations = [ - migrations.AlterModelOptions( - name='plotter', - options={'ordering': ['version', 'id']}, - ), - migrations.AlterModelOptions( - name='plotterparameter', - options={'ordering': ['version', 'id']}, - ), - ] diff --git a/beat/web/toolchains/migrations/0002_auto_20160630_1644.py b/beat/web/toolchains/migrations/0002_auto_20160630_1644.py deleted file mode 100644 index ce1b4cb983838337fe13de8c9bfbb90fdd74088a..0000000000000000000000000000000000000000 --- a/beat/web/toolchains/migrations/0002_auto_20160630_1644.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.5 on 2016-06-30 16:44 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('toolchains', '0001_initial'), - ] - - operations = [ - migrations.AlterModelOptions( - name='toolchain', - options={'ordering': ['previous_version_id', 'fork_of_id', 'id']}, - ), - ] diff --git a/beat/web/toolchains/migrations/0003_auto_20160701_1707.py b/beat/web/toolchains/migrations/0003_auto_20160701_1707.py deleted file mode 100644 index 321e2836022a77f0a0e7d60c3589fab92fb201f4..0000000000000000000000000000000000000000 --- a/beat/web/toolchains/migrations/0003_auto_20160701_1707.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2016-07-01 17:07 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('toolchains', '0002_auto_20160630_1644'), - ] - - operations = [ - migrations.AlterModelOptions( - name='toolchain', - options={'ordering': ['version', 'id']}, - ), - ] diff --git a/beat/web/utils/management/commands/backup.py b/beat/web/utils/management/commands/backup.py index 3c0598ab03274ad7819258276ada1fa3d4ff2993..c93586954184506b5683b6937e5a2bdd77aea21a 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: @@ -158,8 +158,24 @@ class Command(BaseCommand): arguments = copy.deepcopy(dump_arguments) logger.info("Dumping data for `%s' -> `%s'", app, destfile) + if app in only: + + app, model = only[app].split('.') + model = apps.get_model(app, model) + order = ('creation_date',) + + # This will check and correct objects with weird creation + # dates so that the dump order is consistent + while True: + queryset = model.objects.order_by(*order) + err = _check(app, queryset) + if not err: break + + arguments['primary_keys'] = \ + ','.join([str(k.id) for k in queryset]) + 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 76f1886fbf7b8105feafc043b7878817cabee159..b6b4404f5a2a0ee36caefee800d5b0e6b1388d34 100644 --- a/beat/web/utils/management/commands/beatdump.py +++ b/beat/web/utils/management/commands/xdumpdata.py @@ -150,18 +150,22 @@ 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: - yield queryset.order_by().count() + yield queryset.count() + elif primary_keys: + for pk in primary_keys: + yield queryset.get(pk=pk) else: for obj in queryset.iterator(): yield obj + # ################################################### + # patch for BEAT ends here + # ################################################### try: self.stdout.ending = None