From f4a1c15e888b8303cfe84f49130971e11697fe16 Mon Sep 17 00:00:00 2001 From: Kate Cook Date: Tue, 21 Oct 2025 11:40:32 -0400 Subject: [PATCH] add is_TDS flag --- pptp/forms/products.py | 2 ++ ..._tds_alter_product_is_supplemented_food.py | 28 +++++++++++++++++++ pptp/models/products.py | 6 +++- .../pptp/products/combined_upload.html | 6 ++++ pptp/templates/pptp/products/dashboard.html | 3 ++ pptp/views/products.py | 1 + 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 pptp/migrations/0015_product_is_tds_alter_product_is_supplemented_food.py diff --git a/pptp/forms/products.py b/pptp/forms/products.py index a7edbdc..e606169 100644 --- a/pptp/forms/products.py +++ b/pptp/forms/products.py @@ -37,6 +37,7 @@ class Meta: 'package_size', 'package_size_unit', 'is_supplemented_food', + 'is_TDS', 'is_variety_pack', 'is_individually_packaged', 'has_preparation_instructions', @@ -72,6 +73,7 @@ class Meta: 'class': 'form-select' }), 'is_supplemented_food': forms.CheckboxInput(attrs={'class': 'form-check-input'}), + 'is_TDS': forms.CheckboxInput(attrs={'class': 'form-check-input'}), 'is_variety_pack': forms.CheckboxInput(attrs={'class': 'form-check-input'}), 'is_individually_packaged': forms.CheckboxInput(attrs={'class': 'form-check-input'}), 'has_preparation_instructions': forms.CheckboxInput(attrs={'class': 'form-check-input'}), diff --git a/pptp/migrations/0015_product_is_tds_alter_product_is_supplemented_food.py b/pptp/migrations/0015_product_is_tds_alter_product_is_supplemented_food.py new file mode 100644 index 0000000..220d64c --- /dev/null +++ b/pptp/migrations/0015_product_is_tds_alter_product_is_supplemented_food.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.3 on 2025-10-21 15:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("pptp", "0014_product_has_disease_risk_reduction_claim_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="product", + name="is_TDS", + field=models.BooleanField( + default=False, + help_text="Check if this product is part of the Total Diet Study", + ), + ), + migrations.AlterField( + model_name="product", + name="is_supplemented_food", + field=models.BooleanField( + default=False, + help_text="Check if this is a Supplemented Food as defined by the regulations (whether or not it has a supplemental caution label)", + ), + ), + ] diff --git a/pptp/models/products.py b/pptp/models/products.py index 06eb36b..f484eb7 100644 --- a/pptp/models/products.py +++ b/pptp/models/products.py @@ -71,7 +71,11 @@ class Product(models.Model): ) is_supplemented_food = models.BooleanField( default=False, - help_text=_("Check if this is a Supplemented Food as indicated by the front-of-pack caution identifier and supplemented food facts table") + help_text=_("Check if this is a Supplemented Food as defined by the regulations (whether or not it has a supplemental caution label)") + ) + is_TDS = models.BooleanField( + default=False, + help_text=_("Check if this product is part of the Total Diet Study") ) is_individually_packaged = models.BooleanField( default=False, diff --git a/pptp/templates/pptp/products/combined_upload.html b/pptp/templates/pptp/products/combined_upload.html index f259d36..3c81fba 100644 --- a/pptp/templates/pptp/products/combined_upload.html +++ b/pptp/templates/pptp/products/combined_upload.html @@ -102,6 +102,12 @@

Product Submission

{{ form.is_supplemented_food.label }} +
+ {{ form.is_TDS }} + +
diff --git a/pptp/templates/pptp/products/dashboard.html b/pptp/templates/pptp/products/dashboard.html index 0e7b60d..59b9057 100644 --- a/pptp/templates/pptp/products/dashboard.html +++ b/pptp/templates/pptp/products/dashboard.html @@ -177,6 +177,9 @@
{{ product.product_name }}
{% if product.is_supplemented_food %} {% trans "Supplemented Food" %} {% endif %} + {% if product.is_TDS %} + {% trans "TDS" %} + {% endif %} {% empty %} diff --git a/pptp/views/products.py b/pptp/views/products.py index f424258..9879b1c 100644 --- a/pptp/views/products.py +++ b/pptp/views/products.py @@ -37,6 +37,7 @@ def get_context_data(self, **kwargs): context['variety_packs'] = user_products.filter(is_variety_pack=True).count() context['supplemented_foods'] = user_products.filter(is_supplemented_food=True).count() + context['TDS'] = user_products.filter(is_TDS=True).count() thirty_days_ago = timezone.now() - timedelta(days=30) context['recent_products'] = user_products.filter(created_at__gte=thirty_days_ago).count()