From e7af18e04de51156c8d5e1314ddabab2c44ac9b9 Mon Sep 17 00:00:00 2001 From: ed woodward Date: Wed, 25 Oct 2023 12:59:12 -0500 Subject: [PATCH 1/3] Started adding unlisted book state --- books/constants.py | 4 +++- books/models.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) 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/models.py b/books/models.py index 8fcb9ddb7..2b35cddaf 100644 --- a/books/models.py +++ b/books/models.py @@ -994,7 +994,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() From 30625283729285624d2bc7a4f02c5873d7466faa Mon Sep 17 00:00:00 2001 From: ed woodward Date: Mon, 30 Oct 2023 13:21:24 -0500 Subject: [PATCH 2/3] Subjects page filtering unlisted books --- books/migrations/0149_alter_book_book_state.py | 18 ++++++++++++++++++ pages/models.py | 2 +- .../0030_alter_erratacontent_book_state.py | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 books/migrations/0149_alter_book_book_state.py create mode 100644 snippets/migrations/0030_alter_erratacontent_book_state.py 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/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), + ), + ] From b79ff72c90b6f99a867bd44ef1764ae129989bad Mon Sep 17 00:00:00 2001 From: ed woodward Date: Tue, 31 Oct 2023 11:32:22 -0500 Subject: [PATCH 3/3] Added amazon iframe field to book --- books/migrations/0150_book_amazon_iframe.py | 18 ++++++++++++++++++ books/models.py | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 books/migrations/0150_book_amazon_iframe.py 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 2b35cddaf..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'),