diff --git a/pages/migrations/0053_subject_page_description.py b/pages/migrations/0053_subject_page_description.py new file mode 100644 index 000000000..9a6b493fc --- /dev/null +++ b/pages/migrations/0053_subject_page_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.9 on 2022-02-17 19:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pages', '0052_subject_subjectorderable'), + ] + + operations = [ + migrations.AddField( + model_name='subject', + name='page_description', + field=models.TextField(default=''), + ), + ] diff --git a/pages/migrations/0057_merge_20220223_1247.py b/pages/migrations/0057_merge_20220223_1247.py new file mode 100644 index 000000000..c28067501 --- /dev/null +++ b/pages/migrations/0057_merge_20220223_1247.py @@ -0,0 +1,14 @@ +# Generated by Django 3.2.9 on 2022-02-23 18:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('pages', '0053_subject_page_description'), + ('pages', '0056_merge_20220208_1013'), + ] + + operations = [ + ] diff --git a/pages/models.py b/pages/models.py index 680fe0066..2ecf05d3f 100644 --- a/pages/models.py +++ b/pages/models.py @@ -2858,6 +2858,7 @@ class SubjectOrderable(Orderable, SubjectBooks): class Subject(Page): + page_description = models.TextField(default='') tutor_ad = StreamField([ ('content', TutorAdBlock()), ]) @@ -2959,6 +2960,7 @@ def subjects(self): 'last_updated_pdf': book.last_updated_pdf, }) books[book.title] = book_data + book_list['category_description'] = category.description book_list['books'] = books categories[category.subject_category] = book_list subject_categories['categories'] = categories @@ -2967,6 +2969,7 @@ def subjects(self): return subject_list api_fields = [ + APIField('page_description'), APIField('tutor_ad'), APIField('blog_header'), APIField('webinar_header'), @@ -2984,6 +2987,7 @@ def subjects(self): content_panels = Page.content_panels + [ MultiFieldPanel([InlinePanel("subject", label="Subject", min_num=1, max_num=1)], heading="Subject(s)"), + FieldPanel('page_description'), StreamFieldPanel('tutor_ad'), StreamFieldPanel('blog_header'), StreamFieldPanel('webinar_header'), diff --git a/pages/tests.py b/pages/tests.py index 28495900c..5347bdb2d 100644 --- a/pages/tests.py +++ b/pages/tests.py @@ -217,6 +217,7 @@ def test_can_create_subject_page(self): ) homepage.add_child(instance=subjects_page) subject_page = Subject(title="Business", + page_description="Business page", os_textbook_heading="OpenStax Business Textbooks", philanthropic_support="Please support us", ) diff --git a/snippets/migrations/0017_subjectcategory_description.py b/snippets/migrations/0017_subjectcategory_description.py new file mode 100644 index 000000000..4a4f098cf --- /dev/null +++ b/snippets/migrations/0017_subjectcategory_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.9 on 2022-02-16 16:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('snippets', '0016_subject_icon'), + ] + + operations = [ + migrations.AddField( + model_name='subjectcategory', + name='description', + field=models.TextField(default=''), + ), + ] diff --git a/snippets/models.py b/snippets/models.py index 879686e7a..ea7d474f0 100644 --- a/snippets/models.py +++ b/snippets/models.py @@ -202,6 +202,7 @@ def __str__(self): class SubjectCategory(TranslatableMixin, models.Model): subject = models.ForeignKey(Subject, on_delete=models.SET_NULL, null=True, related_name='+') subject_category = models.CharField(max_length=255, null=True, blank=True, help_text="category for selected subject.") + description = models.TextField(default='') @property def subject_name(self): @@ -210,9 +211,10 @@ def subject_name(self): panels = [ SnippetChooserPanel('subject'), FieldPanel('subject_category'), + FieldPanel('description'), ] - api_fields = ('subject_name', 'subject_category') + api_fields = ('subject_name', 'subject_category', 'description') def __str__(self): return self.subject_category diff --git a/snippets/serializers.py b/snippets/serializers.py index 021566f22..e43c3fa96 100644 --- a/snippets/serializers.py +++ b/snippets/serializers.py @@ -36,4 +36,5 @@ class SubjectCategorySerializer(serializers.ModelSerializer): class Meta: model = SubjectCategory fields = ('subject_name', - 'subject_category') + 'subject_category', + 'description')