fic empty new edition

fix error when user click new edition without entering anything
pull/94/head
eric 2020-04-27 13:10:32 -04:00
parent 194950e2a5
commit 9a411f1906
3 changed files with 11 additions and 6 deletions

View File

@ -43,6 +43,8 @@ def scrape_sitemap(url, maxnum=None):
logger.error(e)
def add_by_webpage(url, work=None, user=None):
if not url:
return None
edition = None
scraper = get_scraper(url)
loader = BasePandataLoader(url)

View File

@ -360,6 +360,8 @@ ID_URLPATTERNS = {
def ids_from_urls(url):
ids = {}
if not url:
return ids
for ident, pattern in ID_URLPATTERNS.items():
id_match = pattern.search(url)
if id_match:

View File

@ -160,12 +160,13 @@ def new_edition(request, by=None):
else:
edition = get_edition_for_id(id_type, id_value, user=request.user)
return HttpResponseRedirect(
reverse('new_edition', kwargs={
'work_id': edition.work_id,
'edition_id': edition.id
})
)
if edition:
return HttpResponseRedirect(
reverse('new_edition', kwargs={
'work_id': edition.work_id,
'edition_id': edition.id
})
)
else:
form = IdentifierForm()
return render(request, 'new_edition.html', {'form': form, 'alert':alert})