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 re
|
||||||
import csv
|
import csv
|
||||||
import itertools
|
import itertools
|
||||||
from requests import HTTPError
|
|
||||||
|
|
||||||
from fedireads import books_manager
|
from fedireads import books_manager
|
||||||
|
|
||||||
|
@ -42,13 +41,7 @@ class GoodreadsCsv:
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for line in itertools.islice(self.reader, MAX_ENTRIES):
|
for line in itertools.islice(self.reader, MAX_ENTRIES):
|
||||||
entry = GoodreadsItem(line)
|
yield GoodreadsItem(line)
|
||||||
try:
|
|
||||||
entry.resolve()
|
|
||||||
except HTTPError:
|
|
||||||
pass
|
|
||||||
yield entry
|
|
||||||
|
|
||||||
|
|
||||||
class GoodreadsItem:
|
class GoodreadsItem:
|
||||||
''' a processed line in a goodreads csv '''
|
''' a processed line in a goodreads csv '''
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from io import BytesIO, TextIOWrapper
|
from io import BytesIO, TextIOWrapper
|
||||||
import re
|
import re
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from requests import HTTPError
|
||||||
|
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
@ -424,6 +425,10 @@ def import_data(request):
|
||||||
for item in GoodreadsCsv(TextIOWrapper(
|
for item in GoodreadsCsv(TextIOWrapper(
|
||||||
request.FILES['csv_file'],
|
request.FILES['csv_file'],
|
||||||
encoding=request.encoding)):
|
encoding=request.encoding)):
|
||||||
|
try:
|
||||||
|
item.resolve()
|
||||||
|
except HttpError:
|
||||||
|
pass
|
||||||
if item.book:
|
if item.book:
|
||||||
results.append(item)
|
results.append(item)
|
||||||
if item.rating or item.review:
|
if item.rating or item.review:
|
||||||
|
|
Loading…
Reference in a new issue