Merge pull request #35 from WDI-Ideas/bobby_dev
refactore(dataset):script to update the data of dataset
This commit is contained in:
Binary file not shown.
@@ -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)
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user