fix custom_filter exports and errors on Download link

This commit is contained in:
smilerz
2023-09-01 11:36:10 -05:00
parent c72bf57ccb
commit bcfe6ca707
4 changed files with 5 additions and 48 deletions

View File

@@ -58,7 +58,7 @@ class Default(Integration):
try:
recipe_zip_obj.writestr(f'image{get_filetype(r.image.file.name)}', r.image.file.read())
except ValueError:
except (ValueError, FileNotFoundError):
pass
recipe_zip_obj.close()
@@ -71,4 +71,4 @@ class Default(Integration):
export_zip_obj.close()
return [[ self.get_export_file_name(), export_zip_stream.getvalue() ]]
return [[self.get_export_file_name(), export_zip_stream.getvalue()]]

View File

@@ -37,7 +37,6 @@ class Integration:
self.ignored_recipes = []
description = f'Imported by {request.user.get_user_display_name()} at {date_format(datetime.datetime.now(), "DATETIME_FORMAT")}. Type: {export_type}'
icon = '📥'
try:
last_kw = Keyword.objects.filter(name__regex=r'^(Import [0-9]+)', space=request.space).latest('created_at')
@@ -50,14 +49,12 @@ class Integration:
self.keyword = parent.add_child(
name=name,
description=description,
icon=icon,
space=request.space
)
except (IntegrityError, ValueError): # in case, for whatever reason, the name does exist append UUID to it. Not nice but works for now.
self.keyword = parent.add_child(
name=f'{name} {str(uuid.uuid4())[0:8]}',
description=description,
icon=icon,
space=request.space
)

View File

@@ -2,7 +2,7 @@ import re
import threading
from django.core.cache import cache
from django.http import HttpResponseRedirect, JsonResponse
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, render
from django.utils.translation import gettext as _

View File

@@ -18,25 +18,6 @@
{{ $t("All recipes") }}
</b-form-checkbox>
<!-- <multiselect
:searchable="true"
:disabled="disabled_multiselect"
v-model="recipe_list"
:options="recipes"
:close-on-select="false"
:clear-on-select="true"
:hide-selected="true"
:preserve-search="true"
placeholder="Select Recipes"
:taggable="false"
label="name"
track-by="id"
id="id_recipes"
:multiple="true"
:loading="recipes_loading"
@search-change="searchRecipes"
>
</multiselect> -->
<generic-multiselect
class="input-group-text m-0 p-0"
@change="recipe_list = $event.val"
@@ -81,10 +62,6 @@ Vue.use(BootstrapVue)
export default {
name: "ExportView",
/*mixins: [
ResolveUrlMixin,
ToastMixin,
],*/
components: { GenericMultiselect },
mixins: [ApiMixin],
data() {
@@ -92,7 +69,6 @@ export default {
export_id: window.EXPORT_ID,
loading: false,
disabled_multiselect: false,
recipe_app: "DEFAULT",
recipe_list: [],
recipes_loading: false,
@@ -103,7 +79,6 @@ export default {
},
mounted() {
if (this.export_id) this.insertRequested()
// else this.searchRecipes("")
},
methods: {
insertRequested: function () {
@@ -118,25 +93,10 @@ export default {
this.recipe_list.push(response.data)
})
.catch((err) => {
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_FETCH, err)
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
})
// .then((e) => this.searchRecipes(""))
},
// searchRecipes: function (query) {
// this.recipes_loading = true
// this.genericAPI(this.Models.RECIPE, this.Actions.LIST, { query: query })
// .then((response) => {
// this.recipes = response.data.results
// this.recipes_loading = false
// })
// .catch((err) => {
// console.log(err)
// StandardToasts.makeStandardToast(this,StandardToasts.FAIL_FETCH)
// })
// },
exportRecipe: function () {
if (this.recipe_list.length < 1 && this.export_all == false && this.filter === undefined) {
makeToast(this.$t("Error"), this.$t("Select at least one recipe"), "danger")
@@ -148,7 +108,7 @@ export default {
let formData = new FormData()
formData.append("type", this.recipe_app)
formData.append("all", this.export_all)
formData.append("filter", this.filter?.id ?? null)
formData.append("custom_filter", this.filter?.id ?? null)
for (var i = 0; i < this.recipe_list.length; i++) {
formData.append("recipes", this.recipe_list[i].id)