Self hosted FLOSS fitness/workout, nutrition and weight tracker
Tidy up after the weight merge
Roland Geidera240fd31b91d
diff --git a/wger/weight/management/commands/dummy-generator-body-weight.py b/wger/measurements/management/commands/dummy-generator-body-weight.pysimilarity index 100%rename from wger/weight/management/commands/dummy-generator-body-weight.pyrename to wger/measurements/management/commands/dummy-generator-body-weight.pydiff --git a/wger/measurements/migrations/0007_official_categories.py b/wger/measurements/migrations/0007_official_categories.pyindex 4d3090317..2b4e4dedc 100644--- a/wger/measurements/migrations/0007_official_categories.py+++ b/wger/measurements/migrations/0007_official_categories.py@@ -116,13 +116,5 @@ class Migration(migrations.Migration):name='extra_data',field=models.JSONField(blank=True, default=dict, verbose_name='Extra data'),),- migrations.AddConstraint(- model_name='category',- constraint=models.UniqueConstraint(- condition=models.Q(('is_official', True)),- fields=('user', 'metric_type'),- name='unique_official_category_per_metric_type',- ),- ),migrations.RunPython(migrate_weight_to_measurements, delete_official_categories),]diff --git a/wger/measurements/models/category.py b/wger/measurements/models/category.pyindex fc20e7394..6a693f4e6 100644--- a/wger/measurements/models/category.py+++ b/wger/measurements/models/category.py@@ -130,17 +130,14 @@ class Category(models.Model):'-name',]constraints = [- # official category per (user, metric_type) where is_official=True- # user-created categories are unaffected- models.UniqueConstraint(- fields=['user', 'metric_type'],- condition=models.Q(is_official=True),- name='unique_official_category_per_metric_type',- ),# A typed category is the one place its metric lives: the health# importer looks it up by type, and both manual and synced entries# have to end up in the same one. Free-form categories keep the# default type and are unaffected.+ #+ # This covers the official categories as well, since those are+ # typed by definition (is_official means the server depends on the+ # row existing for that metric type).models.UniqueConstraint(fields=['user', 'metric_type'],condition=~models.Q(metric_type=MetricType.CUSTOM),diff --git a/wger/measurements/tests/test_generator.py b/wger/measurements/tests/test_generator.pyindex 0deb116ae..96925cb65 100644--- a/wger/measurements/tests/test_generator.py+++ b/wger/measurements/tests/test_generator.py@@ -80,3 +80,15 @@ class MeasurementGeneratorTestCase(WgerTestCase):)self.assertFalse(group.measurement_set.exists())self.assertTrue(all(c.measurement_set.exists() for c in components))+++class BodyWeightGeneratorTestCase(WgerTestCase):+ def test_generator(self):+ # Arrange+ Measurement.objects.all().delete()++ # Act+ call_command('dummy-generator-body-weight', '--nr-entries', 100)++ # Assert+ self.assertEqual(Measurement.body_weight_for(1).count(), 100)diff --git a/wger/weight/tests/test_generator.py b/wger/weight/tests/test_generator.pydeleted file mode 100644index 36e48141b..000000000--- a/wger/weight/tests/test_generator.py+++ /dev/null@@ -1,32 +0,0 @@-# This file is part of wger Workout Manager.-#-# wger Workout Manager 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.-#-# wger Workout Manager 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 Affero General Public License--# Django-from django.core.management import call_command--# wger-from wger.core.tests.base_testcase import WgerTestCase-from wger.measurements.models import Measurement---class WeightEntryGeneratorTestCase(WgerTestCase):- def test_generator(self):- # Arrange- Measurement.objects.all().delete()-- # Act- call_command('dummy-generator-body-weight', '--nr-entries', 100)-- # Assert- self.assertEqual(Measurement.body_weight_for(1).count(), 100)