tweaked chef tap import
This commit is contained in:
@ -124,6 +124,7 @@ class ImportForm(ImportExportBase):
|
|||||||
|
|
||||||
class ExportForm(ImportExportBase):
|
class ExportForm(ImportExportBase):
|
||||||
recipes = forms.ModelMultipleChoiceField(widget=MultiSelectWidget, queryset=Recipe.objects.none())
|
recipes = forms.ModelMultipleChoiceField(widget=MultiSelectWidget, queryset=Recipe.objects.none())
|
||||||
|
all = forms.BooleanField()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
space = kwargs.pop('space')
|
space = kwargs.pop('space')
|
||||||
|
@ -13,9 +13,6 @@ class ChefTap(Integration):
|
|||||||
print("testing", zip_info_object.filename)
|
print("testing", zip_info_object.filename)
|
||||||
return re.match(r'^recipes/([A-Za-z\d\w\s-])+.txt$', 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):
|
def get_recipe_from_file(self, file):
|
||||||
source_url = ''
|
source_url = ''
|
||||||
|
|
||||||
@ -45,6 +42,7 @@ class ChefTap(Integration):
|
|||||||
|
|
||||||
if source_url != '':
|
if source_url != '':
|
||||||
step.instruction += '\n' + source_url
|
step.instruction += '\n' + source_url
|
||||||
|
step.save()
|
||||||
|
|
||||||
for ingredient in ingredients:
|
for ingredient in ingredients:
|
||||||
amount, unit, ingredient, note = parse(ingredient)
|
amount, unit, ingredient, note = parse(ingredient)
|
||||||
|
@ -68,8 +68,11 @@ def export_recipe(request):
|
|||||||
form = ExportForm(request.POST, space=request.space)
|
form = ExportForm(request.POST, space=request.space)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
try:
|
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'])
|
integration = get_integration(request, form.cleaned_data['type'])
|
||||||
return integration.do_export(form.cleaned_data['recipes'])
|
return integration.do_export(recipes)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
messages.add_message(request, messages.ERROR, _('Exporting is not implemented for this provider'))
|
messages.add_message(request, messages.ERROR, _('Exporting is not implemented for this provider'))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user