Merge branch 'main' into review-rate

This commit is contained in:
Mouse Reeve
2021-02-28 10:35:20 -08:00
104 changed files with 2651 additions and 693 deletions

View File

@ -97,8 +97,8 @@ class ImportItem(models.Model):
def get_book_from_title_author(self):
''' search by title and author '''
search_term = construct_search_term(
self.data['Title'],
self.data['Author']
self.title,
self.author
)
search_result = connector_manager.first_search_result(
search_term, min_confidence=0.999
@ -149,6 +149,14 @@ class ImportItem(models.Model):
dateutil.parser.parse(self.data['Date Added']))
return None
@property
def date_started(self):
''' when the book was started '''
if "Date Started" in self.data and self.data['Date Started']:
return timezone.make_aware(
dateutil.parser.parse(self.data['Date Started']))
return None
@property
def date_read(self):
''' the date a book was completed '''
@ -160,18 +168,24 @@ class ImportItem(models.Model):
@property
def reads(self):
''' formats a read through dataset for the book in this line '''
if (self.shelf == 'reading'
and self.date_added and not self.date_read):
return [ReadThrough(start_date=self.date_added)]
start_date = self.date_started
# Goodreads special case (no 'date started' field)
if ((self.shelf == 'reading' or (self.shelf == 'read' and self.date_read))
and self.date_added and not start_date):
start_date = self.date_added
if (start_date and start_date is not None and not self.date_read):
return [ReadThrough(start_date=start_date)]
if self.date_read:
return [ReadThrough(
start_date=self.date_added,
start_date=start_date,
finish_date=self.date_read,
)]
return []
def __repr__(self):
return "<GoodreadsItem {!r}>".format(self.data['Title'])
return "<{!r}Item {!r}>".format(self.data['import_source'], self.data['Title'])
def __str__(self):
return "{} by {}".format(self.data['Title'], self.data['Author'])

View File

@ -20,6 +20,8 @@ class SiteSettings(models.Model):
default='Contact an administrator to get an invite')
code_of_conduct = models.TextField(
default='Add a code of conduct here.')
privacy_policy = models.TextField(
default='Add a privacy policy here.')
allow_registration = models.BooleanField(default=True)
logo = models.ImageField(
upload_to='logos/', null=True, blank=True