From cd97da4ece01ace7c00f91fe4fc7caad2df59c24 Mon Sep 17 00:00:00 2001 From: Brent Mills Date: Mon, 18 Nov 2024 13:37:47 -0500 Subject: [PATCH 1/5] Add support for 72 hr vs go-bag --- pack_planner/admin.py | 8 +- pack_planner/models.py | 8 +- pack_planner/services/data_processor.py | 15 +- .../pack_planner/assessment_results.html | 145 +++++++++++++++++- pack_planner/validators.py | 20 +++ pack_planner/views.py | 6 +- 6 files changed, 194 insertions(+), 8 deletions(-) diff --git a/pack_planner/admin.py b/pack_planner/admin.py index 7a1e56c..05306d4 100644 --- a/pack_planner/admin.py +++ b/pack_planner/admin.py @@ -40,8 +40,10 @@ class ItemAdmin(admin.ModelAdmin): 'for_adults', 'for_children', 'for_pets', + 'go_bag', + 'seventy_two_hr_bag' ) - list_filter = ('importance', 'category', 'for_adults', 'for_children', 'for_pets', 'for_disabled', 'for_elderly') + list_filter = ('importance', 'category', 'for_adults', 'for_children', 'for_pets', 'for_disabled', 'for_elderly', 'go_bag', 'seventy_two_hr_bag') search_fields = ('name', 'description', 'uses', 'special_considerations') ordering = ('category', 'order', 'name') inlines = [ProductInline] @@ -72,7 +74,9 @@ class ItemAdmin(admin.ModelAdmin): 'for_on_foot', 'for_bicycle', 'for_vehicle', - 'for_public_transit' + 'for_public_transit', + 'go_bag', + 'seventy_two_hr_bag' ), 'classes': ('collapse',) }) diff --git a/pack_planner/models.py b/pack_planner/models.py index f9bd98e..61e9444 100644 --- a/pack_planner/models.py +++ b/pack_planner/models.py @@ -25,6 +25,7 @@ class Category(models.Model): ('optional', 'Optional') ] ) + go_bag = models.BooleanField(default=True) seventy_two_hr_bag = models.BooleanField(default=True) order = models.IntegerField(default=0) @@ -63,12 +64,16 @@ class Item(models.Model): for_adults = models.BooleanField(default=True) for_children = models.BooleanField(default=False) for_pets = models.BooleanField(default=False) + for_cats = models.BooleanField(default=False) + for_dogs = models.BooleanField(default=False) + for_small_animals = models.BooleanField(default=False) for_disabled = models.BooleanField(default=False) for_elderly = models.BooleanField(default=False) for_on_foot = models.BooleanField(default=True) for_bicycle = models.BooleanField(default=True) for_vehicle = models.BooleanField(default=True) for_public_transit = models.BooleanField(default=True) + go_bag = models.BooleanField(default=True) seventy_two_hr_bag = models.BooleanField(default=True) class Meta: @@ -82,5 +87,6 @@ class Product(models.Model): notes = models.TextField(blank=True) is_available = models.BooleanField(default=True) last_verified = models.DateTimeField(auto_now=True) - + + go_bag = models.BooleanField(default=True) seventy_two_hr_bag = models.BooleanField(default=True) \ No newline at end of file diff --git a/pack_planner/services/data_processor.py b/pack_planner/services/data_processor.py index 780391d..a160b53 100644 --- a/pack_planner/services/data_processor.py +++ b/pack_planner/services/data_processor.py @@ -30,7 +30,9 @@ def _process_categories(self, categories): defaults={ 'description': cat_data['description'], 'importance': cat_data['importance'], - 'order': cat_data.get('order', 0) + 'order': cat_data.get('order', 0), + 'go_bag': cat_data.get('go_bag', True), + 'seventy_two_hr_bag': cat_data.get('seventy_two_hr_bag', True) } ) if created: @@ -50,15 +52,22 @@ def _process_items(self, items): 'weight_note': item_data.get('weight_note', ''), 'special_considerations': item_data.get('special_considerations', ''), 'order': item_data.get('order', 0), + # All boolean fields with their defaults + 'conditional_applicability': item_data.get('conditional_applicability', False), 'for_adults': item_data.get('for_adults', True), 'for_children': item_data.get('for_children', False), 'for_pets': item_data.get('for_pets', False), + 'for_cats': item_data.get('for_cats', False), + 'for_dogs': item_data.get('for_dogs', False), + 'for_small_animals': item_data.get('for_small_animals', False), 'for_disabled': item_data.get('for_disabled', False), 'for_elderly': item_data.get('for_elderly', False), 'for_on_foot': item_data.get('for_on_foot', True), 'for_bicycle': item_data.get('for_bicycle', True), 'for_vehicle': item_data.get('for_vehicle', True), 'for_public_transit': item_data.get('for_public_transit', True), + 'go_bag': item_data.get('go_bag', True), + 'seventy_two_hr_bag': item_data.get('seventy_two_hr_bag', True) } ) @@ -84,7 +93,9 @@ def _process_products(self, products): 'description': prod_data['description'], 'url': prod_data.get('url', ''), 'notes': prod_data.get('notes', ''), - 'is_available': prod_data.get('is_available', True) + 'is_available': prod_data.get('is_available', True), + 'go_bag': prod_data.get('go_bag', True), + 'seventy_two_hr_bag': prod_data.get('seventy_two_hr_bag', True) } ) if created: diff --git a/pack_planner/templates/pack_planner/assessment_results.html b/pack_planner/templates/pack_planner/assessment_results.html index f95ff85..9e2fb5d 100644 --- a/pack_planner/templates/pack_planner/assessment_results.html +++ b/pack_planner/templates/pack_planner/assessment_results.html @@ -65,6 +65,89 @@

Quick Navigation

+ +
+
+
+
+

Pack Type

+ +
+

+ Currently showing Go-Bag items only +

+
+
+ +
+
+
+ + + + {% csrf_token %} @@ -103,8 +186,12 @@

{{ category.name }}