Skip to content
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
14 changes: 7 additions & 7 deletions books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,22 +834,22 @@ def save(self, *args, **kwargs):
self.webview_link = '{}contents/{}'.format(settings.CNX_URL, self.cnx_id)

if self.partner_list_label:
Book.objects.all().update(partner_list_label=self.partner_list_label)
Book.objects.filter(locale=self.locale).update(partner_list_label=self.partner_list_label)

if self.partner_page_link_text:
Book.objects.all().update(partner_page_link_text=self.partner_page_link_text)
Book.objects.filter(locale=self.locale).update(partner_page_link_text=self.partner_page_link_text)

# sync customization form changes on all books
if self.customization_form_heading:
Book.objects.all().update(customization_form_heading=self.customization_form_heading)
Book.objects.filter(locale=self.locale).update(customization_form_heading=self.customization_form_heading)
if self.customization_form_subheading:
Book.objects.all().update(customization_form_subheading=self.customization_form_subheading)
Book.objects.filter(locale=self.locale).update(customization_form_subheading=self.customization_form_subheading)
if self.customization_form_disclaimer:
Book.objects.all().update(customization_form_disclaimer=self.customization_form_disclaimer)
Book.objects.filter(locale=self.locale).update(customization_form_disclaimer=self.customization_form_disclaimer)
if self.customization_form_next_steps:
Book.objects.all().update(customization_form_next_steps=self.customization_form_next_steps)
Book.objects.filter(locale=self.locale).update(customization_form_next_steps=self.customization_form_next_steps)
if self.support_statement:
Book.objects.all().update(support_statement=self.support_statement)
Book.objects.filter(locale=self.locale).update(support_statement=self.support_statement)

return super(Book, self).save(*args, **kwargs)

Expand Down
8 changes: 8 additions & 0 deletions books/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def setUpTestData(cls):

def test_can_create_book(self):
book_index = BookIndex.objects.all()[0]
root_page = Page.objects.get(title="Root")
book = Book(title="University Physics",
slug="university-physics",
cnx_id='031da8d3-b525-429c-80cf-6c8ed997733a',
Expand All @@ -50,12 +51,14 @@ def test_can_create_book(self):
cover=self.test_doc,
title_image=self.test_doc,
publish_date=datetime.date.today(),
locale=root_page.locale
)
book_index.add_child(instance=book)
self.assertEqual(book.salesforce_abbreviation, 'University Phys (Calc)')

def test_can_create_ap_book(self):
book_index = BookIndex.objects.all()[0]
root_page = Page.objects.get(title="Root")
book = Book(title="Prealgebra",
slug="prealgebra",
salesforce_abbreviation='Prealgebra',
Expand All @@ -65,13 +68,15 @@ def test_can_create_ap_book(self):
cover=self.test_doc,
title_image=self.test_doc,
publish_date=datetime.date.today(),
locale=root_page.locale
)
book_index.add_child(instance=book)
self.assertEqual(book.salesforce_abbreviation, 'Prealgebra')


def test_can_create_book_without_cnx_id(self):
book_index = BookIndex.objects.all()[0]
root_page = Page.objects.get(title="Root")
book = Book(title="Prealgebra",
slug="prealgebra",
salesforce_abbreviation='Prealgebra',
Expand All @@ -80,12 +85,14 @@ def test_can_create_book_without_cnx_id(self):
cover=self.test_doc,
title_image=self.test_doc,
publish_date=datetime.date.today(),
locale=root_page.locale
)
book_index.add_child(instance=book)
self.assertEqual(book.salesforce_abbreviation, 'Prealgebra')

def test_only_numbers_for_price(self):
book_index = BookIndex.objects.all()[0]
root_page = Page.objects.get(title="Root")
book = Book(title="Prealgebra",
slug="prealgebra",
salesforce_abbreviation='Prealgebra',
Expand All @@ -94,6 +101,7 @@ def test_only_numbers_for_price(self):
cover=self.test_doc,
title_image=self.test_doc,
publish_date=datetime.date.today(),
locale=root_page.locale
)
book_index.add_child(instance=book)
self.assertEqual(book.salesforce_abbreviation, 'Prealgebra')
Expand Down
1 change: 1 addition & 0 deletions errata/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def setUp(self):
cover=test_doc,
title_image=test_doc,
publish_date=datetime.date.today(),
locale=root_page.locale
)
book_index.add_child(instance=book)

Expand Down