tweaked chef tap import

This commit is contained in:
vabene1111
2021-03-28 18:04:12 +02:00
parent d6e6ab24c2
commit 6143e31e1a
3 changed files with 6 additions and 4 deletions

View File

@ -124,6 +124,7 @@ class ImportForm(ImportExportBase):
class ExportForm(ImportExportBase):
recipes = forms.ModelMultipleChoiceField(widget=MultiSelectWidget, queryset=Recipe.objects.none())
all = forms.BooleanField()
def __init__(self, *args, **kwargs):
space = kwargs.pop('space')

View File

@ -13,9 +13,6 @@ class ChefTap(Integration):
print("testing", zip_info_object.filename)
return re.match(r'^recipes/([A-Za-z\d\w\s-])+.txt$', zip_info_object.filename)
def is_duplicate(self, recipe):
return None
def get_recipe_from_file(self, file):
source_url = ''
@ -45,6 +42,7 @@ class ChefTap(Integration):
if source_url != '':
step.instruction += '\n' + source_url
step.save()
for ingredient in ingredients:
amount, unit, ingredient, note = parse(ingredient)

View File

@ -68,8 +68,11 @@ def export_recipe(request):
form = ExportForm(request.POST, space=request.space)
if form.is_valid():
try:
recipes = form.cleaned_data['recipes']
if form['all']:
recipes = Recipe.objects.filter(space=request.space, internal=True).all()
integration = get_integration(request, form.cleaned_data['type'])
return integration.do_export(form.cleaned_data['recipes'])
return integration.do_export(recipes)
except NotImplementedError:
messages.add_message(request, messages.ERROR, _('Exporting is not implemented for this provider'))