fixed keyword creation in exporter #1213
This commit is contained in:
@ -42,7 +42,7 @@ class Integration:
|
|||||||
try:
|
try:
|
||||||
last_kw = Keyword.objects.filter(name__regex=r'^(Import [0-9]+)', space=request.space).latest('created_at')
|
last_kw = Keyword.objects.filter(name__regex=r'^(Import [0-9]+)', space=request.space).latest('created_at')
|
||||||
name = f'Import {int(last_kw.name.replace("Import ", "")) + 1}'
|
name = f'Import {int(last_kw.name.replace("Import ", "")) + 1}'
|
||||||
except ObjectDoesNotExist:
|
except (ObjectDoesNotExist, ValueError):
|
||||||
name = 'Import 1'
|
name = 'Import 1'
|
||||||
|
|
||||||
parent, created = Keyword.objects.get_or_create(name='Import', space=request.space)
|
parent, created = Keyword.objects.get_or_create(name='Import', space=request.space)
|
||||||
@ -53,7 +53,7 @@ class Integration:
|
|||||||
icon=icon,
|
icon=icon,
|
||||||
space=request.space
|
space=request.space
|
||||||
)
|
)
|
||||||
except IntegrityError: # in case, for whatever reason, the name does exist append UUID to it. Not nice but works for now.
|
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(
|
self.keyword = parent.add_child(
|
||||||
name=f'{name} {str(uuid.uuid4())[0:8]}',
|
name=f'{name} {str(uuid.uuid4())[0:8]}',
|
||||||
description=description,
|
description=description,
|
||||||
@ -86,12 +86,10 @@ class Integration:
|
|||||||
export_obj.close()
|
export_obj.close()
|
||||||
export_file = export_stream.getvalue()
|
export_file = export_stream.getvalue()
|
||||||
|
|
||||||
|
|
||||||
response = HttpResponse(export_file, content_type='application/force-download')
|
response = HttpResponse(export_file, content_type='application/force-download')
|
||||||
response['Content-Disposition'] = 'attachment; filename="'+export_filename+'"'
|
response['Content-Disposition'] = 'attachment; filename="' + export_filename + '"'
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def import_file_name_filter(self, zip_info_object):
|
def import_file_name_filter(self, zip_info_object):
|
||||||
"""
|
"""
|
||||||
Since zipfile.namelist() returns all files in all subdirectories this function allows filtering of files
|
Since zipfile.namelist() returns all files in all subdirectories this function allows filtering of files
|
||||||
@ -262,7 +260,6 @@ class Integration:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError('Method not implemented in integration')
|
raise NotImplementedError('Method not implemented in integration')
|
||||||
|
|
||||||
|
|
||||||
def get_files_from_recipes(self, recipes, cookie):
|
def get_files_from_recipes(self, recipes, cookie):
|
||||||
"""
|
"""
|
||||||
Takes a list of recipe object and converts it to a array containing each file.
|
Takes a list of recipe object and converts it to a array containing each file.
|
||||||
|
Reference in New Issue
Block a user