Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unlisted book state #1521

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion books/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
18 changes: 18 additions & 0 deletions books/migrations/0149_alter_book_book_state.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
18 changes: 18 additions & 0 deletions books/migrations/0150_book_amazon_iframe.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
5 changes: 4 additions & 1 deletion books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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')
mwvolo marked this conversation as resolved.
Show resolved Hide resolved
book_data = []
for book in books:
has_faculty_resources = BookFacultyResources.objects.filter(book_faculty_resource=book).exists()
Expand Down
2 changes: 1 addition & 1 deletion pages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions snippets/migrations/0030_alter_erratacontent_book_state.py
Original file line number Diff line number Diff line change
@@ -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),
),
]