forked from mirrors/bookwyrm
Move attempt to resolve books to view action.
This commit is contained in:
parent
f2f0c979f1
commit
5148820fa3
2 changed files with 6 additions and 8 deletions
|
@ -2,7 +2,6 @@
|
|||
import re
|
||||
import csv
|
||||
import itertools
|
||||
from requests import HTTPError
|
||||
|
||||
from fedireads import books_manager
|
||||
|
||||
|
@ -42,13 +41,7 @@ class GoodreadsCsv:
|
|||
|
||||
def __iter__(self):
|
||||
for line in itertools.islice(self.reader, MAX_ENTRIES):
|
||||
entry = GoodreadsItem(line)
|
||||
try:
|
||||
entry.resolve()
|
||||
except HTTPError:
|
||||
pass
|
||||
yield entry
|
||||
|
||||
yield GoodreadsItem(line)
|
||||
|
||||
class GoodreadsItem:
|
||||
''' a processed line in a goodreads csv '''
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from io import BytesIO, TextIOWrapper
|
||||
import re
|
||||
from PIL import Image
|
||||
from requests import HTTPError
|
||||
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
@ -424,6 +425,10 @@ def import_data(request):
|
|||
for item in GoodreadsCsv(TextIOWrapper(
|
||||
request.FILES['csv_file'],
|
||||
encoding=request.encoding)):
|
||||
try:
|
||||
item.resolve()
|
||||
except HttpError:
|
||||
pass
|
||||
if item.book:
|
||||
results.append(item)
|
||||
if item.rating or item.review:
|
||||
|
|
Loading…
Reference in a new issue