Merge pull request #35 from WDI-Ideas/bobby_dev

refactore(dataset):script to update the data of dataset
This commit is contained in:
BOBBY VISHWAKARMA
2024-05-13 12:08:58 +05:30
committed by GitHub
3 changed files with 17 additions and 1 deletions

Binary file not shown.

View File

@@ -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)

View File

@@ -353,7 +353,7 @@
<a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(7)">Last 7 days</a>
<a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(20)">Last 20 days</a>
<a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(30)">Last 30 days</a>
<a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(40)">Last 40 days</a>
{% comment %} <a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(40)">Last 40 days</a> {% endcomment %}
<a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(60)">Last 60 days</a>
<a class="dropdown-item" href="javascript:void(0)" onclick="getReportData(90)">Last 90 days</a>
</div>