diff --git a/formatted_data.xlsx b/formatted_data.xlsx index 313f3a1..257e248 100644 Binary files a/formatted_data.xlsx and b/formatted_data.xlsx differ diff --git a/module_activity/views.py b/module_activity/views.py index 79784b5..4658d34 100644 --- a/module_activity/views.py +++ b/module_activity/views.py @@ -208,6 +208,8 @@ class PopulateFoodIngredientView(permission.ResourcePermissionRequiredMixin, gen df = pd.read_excel(uploaded_file) + # this loop is for insert the food dataset record in table + for index, row in df.iterrows(): food_name = row['Food'].strip().capitalize() ingredients_str = row['Ingredients'].strip() @@ -220,6 +222,20 @@ class PopulateFoodIngredientView(permission.ResourcePermissionRequiredMixin, gen food = self.model(food_name=food_name, ingredients=ingredients) food.save() + # this loop is for updating the existing record in the database + + # for index, row in df.iterrows(): + # food_name = row['Food'].strip().capitalize() + # ingredients_str = row['Ingredients'].strip() + # ingredients = [ingredient.strip().capitalize() for ingredient in ingredients_str.split(',')] + + # exist_food = self.model.objects.filter(food_name=food_name) + + # if exist_food.exists(): + # exist_food.update(ingredients=ingredients) + + # print(f"{food_name} : {ingredients}") + messages.success(self.request, constants.RECORD_CREATED) return redirect(self.success_url) diff --git a/templates/module_auth/user_view.html b/templates/module_auth/user_view.html index c149702..5e57921 100644 --- a/templates/module_auth/user_view.html +++ b/templates/module_auth/user_view.html @@ -353,7 +353,7 @@ Last 7 days Last 20 days Last 30 days - Last 40 days + {% comment %} Last 40 days {% endcomment %} Last 60 days Last 90 days