diff --git a/books/constants.py b/books/constants.py index ffd97fe33..3df9e02b0 100644 --- a/books/constants.py +++ b/books/constants.py @@ -3,12 +3,14 @@ NEW_EDITION_AVAILABLE = 'new_edition_available' DEPRECATED = 'deprecated' RETIRED = 'retired' +UNLISTED = 'unlisted' BOOK_STATES = ( (LIVE, 'Live'), (COMING_SOON, 'Coming Soon'), (NEW_EDITION_AVAILABLE, 'New Edition Forthcoming (Show new edition correction schedule)'), (DEPRECATED, 'Deprecated (Disallow errata submissions and show deprecated schedule)'), - (RETIRED, 'Retired (Remove from website)') + (RETIRED, 'Retired (Remove from website)'), + (UNLISTED, 'Unlisted (Not included in books sent to site)') ) YELLOW = 'yellow' diff --git a/books/migrations/0149_alter_book_book_state.py b/books/migrations/0149_alter_book_book_state.py new file mode 100644 index 000000000..e589a3474 --- /dev/null +++ b/books/migrations/0149_alter_book_book_state.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-10-30 15:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('books', '0148_book_book_uuid_alter_book_cnx_id'), + ] + + operations = [ + migrations.AlterField( + model_name='book', + name='book_state', + field=models.CharField(choices=[('live', 'Live'), ('coming_soon', 'Coming Soon'), ('new_edition_available', 'New Edition Forthcoming (Show new edition correction schedule)'), ('deprecated', 'Deprecated (Disallow errata submissions and show deprecated schedule)'), ('retired', 'Retired (Remove from website)'), ('unlisted', 'Unlisted (Not included in books sent to site)')], default='live', help_text='The state of the book.', max_length=255), + ), + ] diff --git a/books/migrations/0150_book_amazon_iframe.py b/books/migrations/0150_book_amazon_iframe.py new file mode 100644 index 000000000..0bcb7cb24 --- /dev/null +++ b/books/migrations/0150_book_amazon_iframe.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-10-31 16:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('books', '0149_alter_book_book_state'), + ] + + operations = [ + migrations.AddField( + model_name='book', + name='amazon_iframe', + field=models.TextField(blank=True, help_text='Amazon iframe code block', null=True), + ), + ] diff --git a/books/models.py b/books/models.py index 8fcb9ddb7..47147c183 100644 --- a/books/models.py +++ b/books/models.py @@ -620,6 +620,7 @@ def get_community_resource_feature_link_url(self): bookshare_link = models.URLField(blank=True, help_text="Link to Bookshare resources") amazon_coming_soon = models.BooleanField(default=False, verbose_name="Individual Print Coming Soon") amazon_link = models.URLField(blank=True, verbose_name="Individual Print Link") + amazon_iframe = models.TextField(blank=True, null=True, help_text='Amazon iframe code block') kindle_link = models.URLField(blank=True, help_text="Link to Kindle version") chegg_link = models.URLField(blank=True, null=True, help_text="Link to Chegg e-reader") chegg_link_text = models.CharField(max_length=255, blank=True, null=True, help_text='Text for Chegg link.') @@ -713,6 +714,7 @@ def get_community_resource_feature_link_url(self): FieldPanel('bookshare_link'), FieldPanel('amazon_coming_soon'), FieldPanel('amazon_link'), + FieldPanel('amazon_iframe'), FieldPanel('kindle_link'), FieldPanel('chegg_link'), FieldPanel('chegg_link_text'), @@ -813,6 +815,7 @@ def get_community_resource_feature_link_url(self): APIField('bookshare_link'), APIField('amazon_coming_soon'), APIField('amazon_link'), + APIField('amazon_iframe'), APIField('kindle_link'), APIField('chegg_link'), APIField('chegg_link_text'), @@ -994,7 +997,7 @@ class BookIndex(Page): @property def books(self): - books = Book.objects.live().filter(locale=self.locale).order_by('title') + books = Book.objects.live().filter(locale=self.locale).filter(self.book_state is not 'unlisted').order_by('title') book_data = [] for book in books: has_faculty_resources = BookFacultyResources.objects.filter(book_faculty_resource=book).exists() diff --git a/pages/models.py b/pages/models.py index e4326698d..0d9f449ac 100644 --- a/pages/models.py +++ b/pages/models.py @@ -2739,7 +2739,7 @@ def subjects(self): for book in all_books: if book.subject_categories is not None \ and category.subject_category in book.subject_categories \ - and book.book_state != 'retired': + and book.book_state not in ['retired', 'unlisted']: book_data = [] book_data.append({ 'id': book.id, diff --git a/snippets/migrations/0030_alter_erratacontent_book_state.py b/snippets/migrations/0030_alter_erratacontent_book_state.py new file mode 100644 index 000000000..3ea19bb30 --- /dev/null +++ b/snippets/migrations/0030_alter_erratacontent_book_state.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-10-30 15:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('snippets', '0029_assignableavailable'), + ] + + operations = [ + migrations.AlterField( + model_name='erratacontent', + name='book_state', + field=models.CharField(choices=[('live', 'Live'), ('coming_soon', 'Coming Soon'), ('new_edition_available', 'New Edition Forthcoming (Show new edition correction schedule)'), ('deprecated', 'Deprecated (Disallow errata submissions and show deprecated schedule)'), ('retired', 'Retired (Remove from website)'), ('unlisted', 'Unlisted (Not included in books sent to site)')], default='live', help_text='The state of the book.', max_length=255), + ), + ]