Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

fibre/fibres/fibers -> fiber

Dieter Plaetinckb234b2e1bc2e
diff --git a/wger/nutrition/api/filtersets.py b/wger/nutrition/api/filtersets.py
index 3e9a0d45a..44fdfbfdf 100644
--- a/wger/nutrition/api/filtersets.py
+++ b/wger/nutrition/api/filtersets.py
@@ -34,7 +34,7 @@ class IngredientFilterSet(filters.FilterSet):
'energy': ['exact'],
'fat': ['exact'],
'fat_saturated': ['exact'],
- 'fibres': ['exact'],
+ 'fiber': ['exact'],
'name': ['exact'],
'protein': ['exact'],
'sodium': ['exact'],
diff --git a/wger/nutrition/api/serializers.py b/wger/nutrition/api/serializers.py
index d3e31ae78..301e3ad93 100644
--- a/wger/nutrition/api/serializers.py
+++ b/wger/nutrition/api/serializers.py
@@ -124,7 +124,7 @@ class IngredientSerializer(serializers.ModelSerializer):
'carbohydrates_sugar',
'fat',
'fat_saturated',
- 'fibres',
+ 'fiber',
'sodium',
'license',
'license_title',
@@ -160,7 +160,7 @@ class IngredientInfoSerializer(serializers.ModelSerializer):
'carbohydrates_sugar',
'fat',
'fat_saturated',
- 'fibres',
+ 'fiber',
'sodium',
'weight_units',
'language',
@@ -265,7 +265,7 @@ class NutritionalValuesSerializer(serializers.Serializer):
carbohydrates_sugar = serializers.FloatField()
fat = serializers.FloatField()
fat_saturated = serializers.FloatField()
- fibres = serializers.FloatField()
+ fiber = serializers.FloatField()
sodium = serializers.FloatField()
@@ -312,7 +312,7 @@ class NutritionPlanSerializer(serializers.ModelSerializer):
'goal_protein',
'goal_carbohydrates',
'goal_fat',
- 'goal_fibers',
+ 'goal_fiber',
# 'nutritional_values',
]
@@ -336,6 +336,6 @@ class NutritionPlanInfoSerializer(serializers.ModelSerializer):
'goal_protein',
'goal_carbohydrates',
'goal_fat',
- 'goal_fibers',
+ 'goal_fiber',
'meals',
]
diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.py
index 7b0ac078d..c7a7d6ff9 100644
--- a/wger/nutrition/api/views.py
+++ b/wger/nutrition/api/views.py
@@ -129,7 +129,7 @@ class IngredientViewSet(viewsets.ReadOnlyModelViewSet):
'carbohydrates_sugar': 0,
'fat': 0,
'fat_saturated': 0,
- 'fibres': 0,
+ 'fiber': 0,
'sodium': 0,
'errors': [],
}
diff --git a/wger/nutrition/fixtures/test-ingredients.json b/wger/nutrition/fixtures/test-ingredients.json
index d4152ebef..3e019d812 100644
--- a/wger/nutrition/fixtures/test-ingredients.json
+++ b/wger/nutrition/fixtures/test-ingredients.json
@@ -15,7 +15,7 @@
"fat": "8.19",
"carbohydrates_sugar": "0.0",
"fat_saturated": "3.244",
- "fibres": "0.0",
+ "fiber": "0.0",
"protein": "25.63",
"carbohydrates": "0.1251",
"code": "1234567890987654321",
@@ -42,7 +42,7 @@
"fat": "9",
"carbohydrates_sugar": "1",
"fat_saturated": "3",
- "fibres": "5.0",
+ "fiber": "5.0",
"protein": "25.63",
"carbohydrates": "0.1251",
"code": "1234567890",
@@ -69,7 +69,7 @@
"fat": "9",
"carbohydrates_sugar": "1",
"fat_saturated": "3",
- "fibres": "5.0",
+ "fiber": "5.0",
"protein": "25.63",
"carbohydrates": "0.1551",
"code": "1223334444",
@@ -96,7 +96,7 @@
"fat": "1",
"carbohydrates_sugar": "99",
"fat_saturated": "0",
- "fibres": "0",
+ "fiber": "0",
"protein": "0",
"carbohydrates": "99.0",
"code": "0987654321",
@@ -123,7 +123,7 @@
"fat": "1",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "0",
+ "fiber": "0",
"protein": "0",
"carbohydrates": "5.0",
"code": "555555555",
@@ -150,7 +150,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "1112222333333334444444",
@@ -177,7 +177,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "11222222333",
@@ -204,7 +204,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "9988877766655",
@@ -231,7 +231,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "123454321",
@@ -258,7 +258,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "0009999888777",
@@ -285,7 +285,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "7787878787878787",
@@ -312,7 +312,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "29292929292929",
@@ -339,7 +339,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "19191919191",
@@ -366,7 +366,7 @@
"fat": "2",
"carbohydrates_sugar": "4",
"fat_saturated": "0",
- "fibres": "20",
+ "fiber": "20",
"protein": "10",
"carbohydrates": "5.0",
"code": "4444444444444",
diff --git a/wger/nutrition/forms.py b/wger/nutrition/forms.py
index 85e4df1c7..976e5bac5 100644
--- a/wger/nutrition/forms.py
+++ b/wger/nutrition/forms.py
@@ -343,7 +343,7 @@ class IngredientForm(forms.ModelForm):
'carbohydrates_sugar',
'fat',
'fat_saturated',
- 'fibres',
+ 'fiber',
'sodium',
'license',
'license_author',
@@ -371,7 +371,7 @@ class IngredientForm(forms.ModelForm):
Column('fat_saturated', css_class='col-6'),
css_class='form-row',
),
- 'fibres',
+ 'fiber',
'sodium',
Row(
Column('license', css_class='col-6'),
diff --git a/wger/nutrition/helpers.py b/wger/nutrition/helpers.py
index 39d3879d4..634b6121b 100644
--- a/wger/nutrition/helpers.py
+++ b/wger/nutrition/helpers.py
@@ -74,8 +74,8 @@ class BaseMealItem:
if self.ingredient.fat_saturated:
values.fat_saturated = self.ingredient.fat_saturated * item_weight / 100
- if self.ingredient.fibres:
- values.fibres = self.ingredient.fibres * item_weight / 100
+ if self.ingredient.fiber:
+ values.fiber = self.ingredient.fiber * item_weight / 100
if self.ingredient.sodium:
values.sodium = self.ingredient.sodium * item_weight / 100
@@ -110,7 +110,7 @@ class NutritionalValues:
carbohydrates_sugar: Union[Decimal, int, float, None] = None
fat: Union[Decimal, int, float] = 0
fat_saturated: Union[Decimal, int, float, None] = None
- fibres: Union[Decimal, int, float, None] = None
+ fiber: Union[Decimal, int, float, None] = None
sodium: Union[Decimal, int, float, None] = None
@property
@@ -132,9 +132,9 @@ class NutritionalValues:
fat_saturated=self.fat_saturated + other.fat_saturated
if self.fat_saturated and other.fat_saturated
else self.fat_saturated or other.fat_saturated,
- fibres=self.fibres + other.fibres
- if self.fibres and other.fibres
- else self.fibres or other.fibres,
+ fiber=self.fiber + other.fiber
+ if self.fiber and other.fiber
+ else self.fiber or other.fiber,
sodium=self.sodium + other.sodium
if self.sodium and other.sodium
else self.sodium or other.sodium,
diff --git a/wger/nutrition/migrations/0022_fiber_spelling.py b/wger/nutrition/migrations/0022_fiber_spelling.py
new file mode 100644
index 000000000..ad28bd083
--- /dev/null
+++ b/wger/nutrition/migrations/0022_fiber_spelling.py
@@ -0,0 +1,23 @@
+# Generated by Django 4.2.6 on 2024-05-21 19:32
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('nutrition', '0021_add_fibers_field'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='ingredient',
+ name='fibres',
+ ),
+ migrations.AddField(
+ model_name='ingredient',
+ name='fiber',
+ field=models.DecimalField(blank=True, decimal_places=3, help_text='In g per 100g of product', max_digits=6, null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Fiber'),
+ ),
+ ]
diff --git a/wger/nutrition/migrations/0023_rename_goal_fibers_nutritionplan_goal_fiber.py b/wger/nutrition/migrations/0023_rename_goal_fibers_nutritionplan_goal_fiber.py
new file mode 100644
index 000000000..8a26f5140
--- /dev/null
+++ b/wger/nutrition/migrations/0023_rename_goal_fibers_nutritionplan_goal_fiber.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.6 on 2024-05-21 19:40
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('nutrition', '0022_fiber_spelling'),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name='nutritionplan',
+ old_name='goal_fibers',
+ new_name='goal_fiber',
+ ),
+ ]
diff --git a/wger/nutrition/models/ingredient.py b/wger/nutrition/models/ingredient.py
index 252bbf085..b2c9fe2be 100644
--- a/wger/nutrition/models/ingredient.py
+++ b/wger/nutrition/models/ingredient.py
@@ -171,12 +171,12 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
validators=[MinValueValidator(0), MaxValueValidator(100)],
)
- fibres = models.DecimalField(
+ fiber = models.DecimalField(
decimal_places=3,
max_digits=6,
blank=True,
null=True,
- verbose_name=_('Fibres'),
+ verbose_name=_('Fiber'),
help_text=_('In g per 100g of product'),
validators=[MinValueValidator(0), MaxValueValidator(100)],
)
@@ -339,7 +339,7 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
'energy',
'fat',
'fat_saturated',
- 'fibres',
+ 'fiber',
'name',
'protein',
'sodium',
diff --git a/wger/nutrition/models/plan.py b/wger/nutrition/models/plan.py
index 257c56f18..8cea374fb 100644
--- a/wger/nutrition/models/plan.py
+++ b/wger/nutrition/models/plan.py
@@ -82,7 +82,7 @@ class NutritionPlan(models.Model):
goal_carbohydrates = models.IntegerField(null=True, default=None)
- goal_fibers = models.IntegerField(null=True, default=None)
+ goal_fiber = models.IntegerField(null=True, default=None)
goal_fat = models.IntegerField(null=True, default=None)
diff --git a/wger/nutrition/off.py b/wger/nutrition/off.py
index 9e99f141c..aac8307ad 100644
--- a/wger/nutrition/off.py
+++ b/wger/nutrition/off.py
@@ -49,7 +49,7 @@ class IngredientData:
carbohydrates_sugar: float
fat: float
fat_saturated: float
- fibres: Optional[float]
+ fiber: Optional[float]
sodium: Optional[float]
code: str
source_name: str
@@ -101,7 +101,7 @@ def extract_info_from_off(product_data, language: int):
# these are optional
sodium = product_data['nutriments'].get('sodium_100g', None)
- fibre = product_data['nutriments'].get('fiber_100g', None)
+ fiber = product_data['nutriments'].get('fiber_100g', None)
brand = product_data.get('brands', None)
# License and author info
@@ -119,7 +119,7 @@ def extract_info_from_off(product_data, language: int):
carbohydrates_sugar=sugars,
fat=fat,
fat_saturated=saturated,
- fibres=fibre,
+ fiber=fiber,
sodium=sodium,
code=code,
source_name=source_name,
diff --git a/wger/nutrition/static/js/nutrition.js b/wger/nutrition/static/js/nutrition.js
index 888417729..4efe2f2d9 100644
--- a/wger/nutrition/static/js/nutrition.js
+++ b/wger/nutrition/static/js/nutrition.js
@@ -39,7 +39,7 @@ function updateIngredientValue(url) {
$('#value-carbohydrates-sugar').html(parseFloat(data.carbohydrates_sugar).toFixed(2));
$('#value-fat').html(parseFloat(data.fat).toFixed(2));
$('#value-fat-saturated').html(parseFloat(data.fat_saturated).toFixed(2));
- $('#value-fibres').html(parseFloat(data.fibres).toFixed(2));
+ $('#value-fiber').html(parseFloat(data.fiber).toFixed(2));
$('#value-sodium').html(parseFloat(data.sodium).toFixed(2));
});
}
diff --git a/wger/nutrition/sync.py b/wger/nutrition/sync.py
index 3f3f491df..3a0631afc 100644
--- a/wger/nutrition/sync.py
+++ b/wger/nutrition/sync.py
@@ -226,7 +226,7 @@ def sync_ingredients(
'fat': data['fat'],
'fat_saturated': data['fat_saturated'],
'protein': data['protein'],
- 'fibres': data['fibres'],
+ 'fiber': data['fiber'],
'sodium': data['sodium'],
},
)
diff --git a/wger/nutrition/templates/ingredient/view.html b/wger/nutrition/templates/ingredient/view.html
index 27a9d03f5..3adc780f9 100644
--- a/wger/nutrition/templates/ingredient/view.html
+++ b/wger/nutrition/templates/ingredient/view.html
@@ -131,10 +131,10 @@ the search.{% endblocktranslate %}
</thead>
<tbody>
<tr>
- <td>{% translate "Fibres" %}</td>
+ <td>{% translate "Fiber" %}</td>
<td itemprop="fiberContent" class="text-right">
- {% if ingredient.fibres %}
- <span id="value-fibres">{{ingredient.fibres|floatformat:1}}</span> {% translate "g" context "weight unit, i.e. grams" %}
+ {% if ingredient.fiber %}
+ <span id="value-fiber">{{ingredient.fiber|floatformat:1}}</span> {% translate "g" context "weight unit, i.e. grams" %}
{% else %}
{% translate "n.A." %}
{% endif %}
diff --git a/wger/nutrition/tests/test_ingredient.py b/wger/nutrition/tests/test_ingredient.py
index 51afabd4d..b9f3362a1 100644
--- a/wger/nutrition/tests/test_ingredient.py
+++ b/wger/nutrition/tests/test_ingredient.py
@@ -85,7 +85,7 @@ class EditIngredientTestCase(WgerEditTestCase):
'fat': 10,
'carbohydrates_sugar': 5,
'fat_saturated': 3.14,
- 'fibres': 2.1,
+ 'fiber': 2.1,
'protein': 20,
'carbohydrates': 10,
'license': 2,
@@ -119,7 +119,7 @@ class AddIngredientTestCase(WgerAddTestCase):
'fat': 10,
'carbohydrates_sugar': 5,
'fat_saturated': 3.14,
- 'fibres': 2.1,
+ 'fiber': 2.1,
'protein': 20,
'carbohydrates': 10,
'license': 2,
@@ -154,7 +154,7 @@ class IngredientNameShortTestCase(WgerTestCase):
'fat': 10,
'carbohydrates_sugar': 5,
'fat_saturated': 3.14,
- 'fibres': 2.1,
+ 'fiber': 2.1,
'protein': 20,
'carbohydrates': 10,
'license': 2,
@@ -324,7 +324,7 @@ class IngredientValuesTestCase(WgerTestCase):
'fat': 0.0819,
'carbohydrates_sugar': None,
'fat_saturated': 0.03244,
- 'fibres': None,
+ 'fiber': None,
'protein': 0.2563,
'carbohydrates': 0.00125,
},
@@ -348,7 +348,7 @@ class IngredientValuesTestCase(WgerTestCase):
'fat': 9.13185,
'carbohydrates_sugar': None,
'fat_saturated': 3.61706,
- 'fibres': None,
+ 'fiber': None,
'protein': 28.57745,
'carbohydrates': 0.139375,
},
@@ -506,7 +506,7 @@ class IngredientModelTestCase(WgerTestCase):
self.assertEqual(ingredient.fat, 40)
self.assertEqual(ingredient.fat_saturated, 11)
self.assertEqual(ingredient.sodium, 5)
- self.assertEqual(ingredient.fibres, None)
+ self.assertEqual(ingredient.fiber, None)
self.assertEqual(ingredient.brand, 'The bar company')
self.assertEqual(ingredient.license_author, 'open food facts, MrX')
diff --git a/wger/nutrition/tests/test_ingredient_overview.py b/wger/nutrition/tests/test_ingredient_overview.py
index 449144936..59f152814 100644
--- a/wger/nutrition/tests/test_ingredient_overview.py
+++ b/wger/nutrition/tests/test_ingredient_overview.py
@@ -37,7 +37,7 @@ class IngredientOverviewTestCase(WgerTestCase):
'fat': 8.19,
'carbohydrates_sugar': 0.0,
'fat_saturated': 3.24,
- 'fibres': 0.0,
+ 'fiber': 0.0,
'protein': 25.63,
'carbohydrates': 0.0,
'license': 1,
diff --git a/wger/nutrition/tests/test_nutritional_calculations.py b/wger/nutrition/tests/test_nutritional_calculations.py
index c2244daf6..0bcc745fa 100644
--- a/wger/nutrition/tests/test_nutritional_calculations.py
+++ b/wger/nutrition/tests/test_nutritional_calculations.py
@@ -60,7 +60,7 @@ class NutritionalValuesCalculationsTestCase(WgerTestCase):
self.assertAlmostEqual(item_values.fat, ingredient.fat, 2)
self.assertAlmostEqual(item_values.fat_saturated, ingredient.fat_saturated, 2)
self.assertAlmostEqual(item_values.sodium, ingredient.sodium, 2)
- self.assertAlmostEqual(item_values.fibres, None, 2)
+ self.assertAlmostEqual(item_values.fiber, None, 2)
meal_nutritional_values = meal.get_nutritional_values()
self.assertEqual(item_values, meal_nutritional_values)
diff --git a/wger/nutrition/tests/test_nutritional_values.py b/wger/nutrition/tests/test_nutritional_values.py
index 903774ede..c92ba6866 100644
--- a/wger/nutrition/tests/test_nutritional_values.py
+++ b/wger/nutrition/tests/test_nutritional_values.py
@@ -40,7 +40,7 @@ class NutritionalValuesTestCase(SimpleTestCase):
carbohydrates_sugar=70,
fat=60,
fat_saturated=50,
- fibres=40,
+ fiber=40,
sodium=30,
)
values2 = NutritionalValues(
@@ -50,7 +50,7 @@ class NutritionalValuesTestCase(SimpleTestCase):
carbohydrates_sugar=7,
fat=6,
fat_saturated=5,
- fibres=4,
+ fiber=4,
sodium=3,
)
values3 = values1 + values2
@@ -64,7 +64,7 @@ class NutritionalValuesTestCase(SimpleTestCase):
carbohydrates_sugar=77,
fat=66,
fat_saturated=55,
- fibres=44,
+ fiber=44,
sodium=33,
),
)
@@ -73,7 +73,7 @@ class NutritionalValuesTestCase(SimpleTestCase):
"""Test that the addition works correctly for the nullable values"""
values1 = NutritionalValues()
- values2 = NutritionalValues(carbohydrates_sugar=10, fat_saturated=20, fibres=30, sodium=40)
+ values2 = NutritionalValues(carbohydrates_sugar=10, fat_saturated=20, fiber=30, sodium=40)
values3 = values1 + values2
self.assertEqual(
@@ -85,7 +85,7 @@ class NutritionalValuesTestCase(SimpleTestCase):
carbohydrates_sugar=10,
fat=0,
fat_saturated=20,
- fibres=30,
+ fiber=30,
sodium=40,
),
)
diff --git a/wger/nutrition/tests/test_off.py b/wger/nutrition/tests/test_off.py
index de652c26e..d2d7e8171 100644
--- a/wger/nutrition/tests/test_off.py
+++ b/wger/nutrition/tests/test_off.py
@@ -67,7 +67,7 @@ class ExtractInfoFromOffTestCase(SimpleTestCase):
carbohydrates_sugar=30,
fat=40,
fat_saturated=11,
- fibres=None,
+ fiber=None,
sodium=5,
code='1234',
source_name='Open Food Facts',
diff --git a/wger/nutrition/tests/test_sync.py b/wger/nutrition/tests/test_sync.py
index 0609ec802..a53f9ac30 100644
--- a/wger/nutrition/tests/test_sync.py
+++ b/wger/nutrition/tests/test_sync.py
@@ -50,7 +50,7 @@ class MockIngredientResponse:
"carbohydrates_sugar": "27.000",
"fat": "18.000",
"fat_saturated": "4.500",
- "fibres": "2.000",
+ "fiber": "2.000",
"sodium": "0.356",
"license": 5,
"license_title": " Gâteau double chocolat ",
@@ -73,7 +73,7 @@ class MockIngredientResponse:
"carbohydrates_sugar": "5.600",
"fat": "11.000",
"fat_saturated": "4.600",
- "fibres": None,
+ "fiber": None,
"sodium": "0.820",
"license": 5,
"license_title": " Maxi Hot Dog New York Style",
diff --git a/wger/nutrition/views/plan.py b/wger/nutrition/views/plan.py
index 86af162e7..cbdb7d30a 100644
--- a/wger/nutrition/views/plan.py
+++ b/wger/nutrition/views/plan.py
@@ -276,8 +276,8 @@ def export_pdf(request, id: int):
)
data.append(
[
- Paragraph(_('Fibres'), styleSheet['Normal']),
- Paragraph(str(plan_data['total'].fibres), styleSheet['Normal']),
+ Paragraph(_('Fiber'), styleSheet['Normal']),
+ Paragraph(str(plan_data['total'].fiber), styleSheet['Normal']),
]
)
data.append(
@@ -299,7 +299,7 @@ def export_pdf(request, id: int):
table_style.append(('BACKGROUND', (0, 6), (-1, 6), row_color)) # Fats
table_style.append(('SPAN', (1, 7), (-1, 7))) # Saturated fats
table_style.append(('LEFTPADDING', (0, 7), (0, 7), 15))
- table_style.append(('SPAN', (1, 8), (-1, 8))) # Fibres
+ table_style.append(('SPAN', (1, 8), (-1, 8))) # Fiber
table_style.append(('SPAN', (1, 9), (-1, 9))) # Sodium
t = Table(data, style=table_style)
t._argW[0] = 6 * cm