misc cleanup

This commit is contained in:
smilerz
2021-05-02 20:06:53 -05:00
parent e345d2eb39
commit 984d5aae11
5 changed files with 7 additions and 8 deletions

View File

@ -14,11 +14,10 @@ from recipe_scrapers._utils import get_minutes
def get_from_scraper(scrape, space):
# converting the scrape_me object to the existing json format based on ld+json
recipe_json = {}
try:
recipe_json['name'] = parse_name(scrape.title() or None)
except (TypeError, AttributeError, ElementNotFoundInHtml, NotImplementedError):
except Exception:
recipe_json['name'] = None
if not recipe_json['name']:
try:
@ -28,7 +27,7 @@ def get_from_scraper(scrape, space):
try:
description = scrape.schema.data.get("description") or ''
except (AttributeError, ElementNotFoundInHtml, NotImplementedError, SchemaOrgException):
except Exception:
description = ''
recipe_json['description'] = parse_description(description)

View File

@ -722,6 +722,7 @@
msg += err.bodyText
} else {
msg += ' ' + err.status + ' ' + err.statusText
this.preview = true
}
this.makeToast(gettext('Error'), msg, 'danger')
})

View File

@ -680,7 +680,6 @@ def recipe_from_source(request):
'images': images,
})
else:
return JsonResponse(
{

View File

@ -163,7 +163,7 @@ def import_url(request):
elif isinstance(ing['amount'], float) \
or isinstance(ing['amount'], int):
ingredient.amount = ing['amount']
ingredient.note = ing['note'] if 'note' in ing else ''
ingredient.note = ing['note'].strip() if 'note' in ing else ''
ingredient.save()
step.ingredients.add(ingredient)