From 4be5ba262b1995f59527f8066a7c3b131e08b7c0 Mon Sep 17 00:00:00 2001 From: Shrikrishna Singh <krishnasingh.ss30@gmail.com> Date: Mon, 20 Jun 2022 14:28:49 +0530 Subject: [PATCH] use_json_field argument added to StreamField --- hypha/apply/determinations/models.py | 6 +++++- hypha/apply/funds/models/forms.py | 2 +- hypha/apply/funds/models/submissions.py | 2 +- hypha/apply/projects/models/project.py | 2 +- hypha/apply/review/models.py | 2 +- hypha/public/funds/models.py | 4 ++-- hypha/public/home/models.py | 2 +- hypha/public/navigation/models.py | 3 ++- hypha/public/news/models.py | 5 ++++- hypha/public/people/models.py | 2 +- hypha/public/projects/models.py | 2 +- hypha/public/standardpages/models.py | 2 +- hypha/public/utils/models.py | 3 ++- 13 files changed, 23 insertions(+), 14 deletions(-) diff --git a/hypha/apply/determinations/models.py b/hypha/apply/determinations/models.py index 7d2187224..2747c0e3c 100644 --- a/hypha/apply/determinations/models.py +++ b/hypha/apply/determinations/models.py @@ -47,7 +47,11 @@ class DeterminationFormFieldsMixin(models.Model): class Meta: abstract = True - form_fields = StreamField(DeterminationCustomFormFieldsBlock(), default=[]) + form_fields = StreamField( + DeterminationCustomFormFieldsBlock(), + default=[], + use_json_field=True, + ) @property def determination_field(self): diff --git a/hypha/apply/funds/models/forms.py b/hypha/apply/funds/models/forms.py index 45cd6566d..36758f67b 100644 --- a/hypha/apply/funds/models/forms.py +++ b/hypha/apply/funds/models/forms.py @@ -10,7 +10,7 @@ from ..edit_handlers import FilteredFieldPanel class ApplicationForm(models.Model): name = models.CharField(max_length=255) - form_fields = StreamField(ApplicationCustomFormFieldsBlock()) + form_fields = StreamField(ApplicationCustomFormFieldsBlock(), use_json_field=True) panels = [ FieldPanel('name'), diff --git a/hypha/apply/funds/models/submissions.py b/hypha/apply/funds/models/submissions.py index 4a5165099..5d59a028b 100644 --- a/hypha/apply/funds/models/submissions.py +++ b/hypha/apply/funds/models/submissions.py @@ -430,7 +430,7 @@ class ApplicationSubmission( metaclass=ApplicationSubmissionMetaclass, ): form_data = models.JSONField(encoder=StreamFieldDataEncoder) - form_fields = StreamField(ApplicationCustomFormFieldsBlock()) + form_fields = StreamField(ApplicationCustomFormFieldsBlock(), use_json_field=True) summary = models.TextField(default='', null=True, blank=True) page = models.ForeignKey('wagtailcore.Page', on_delete=models.PROTECT) round = models.ForeignKey('wagtailcore.Page', on_delete=models.PROTECT, related_name='submissions', null=True) diff --git a/hypha/apply/projects/models/project.py b/hypha/apply/projects/models/project.py index 10e5159f2..27eb21f46 100644 --- a/hypha/apply/projects/models/project.py +++ b/hypha/apply/projects/models/project.py @@ -143,7 +143,7 @@ class Project(BaseStreamForm, AccessFormData, models.Model): status = models.TextField(choices=PROJECT_STATUS_CHOICES, default=COMMITTED) form_data = models.JSONField(encoder=StreamFieldDataEncoder, default=dict) - form_fields = StreamField(FormFieldsBlock(), null=True) + form_fields = StreamField(FormFieldsBlock(), null=True, use_json_field=True) # tracks read/write state of the Project is_locked = models.BooleanField(default=False) diff --git a/hypha/apply/review/models.py b/hypha/apply/review/models.py index 3a1c1fc20..983f3dd0e 100644 --- a/hypha/apply/review/models.py +++ b/hypha/apply/review/models.py @@ -40,7 +40,7 @@ class ReviewFormFieldsMixin(models.Model): class Meta: abstract = True - form_fields = StreamField(ReviewCustomFormFieldsBlock()) + form_fields = StreamField(ReviewCustomFormFieldsBlock(), use_json_field=True) @property def score_fields(self): diff --git a/hypha/public/funds/models.py b/hypha/public/funds/models.py index 32ed492f0..6f15dc03a 100644 --- a/hypha/public/funds/models.py +++ b/hypha/public/funds/models.py @@ -44,7 +44,7 @@ class BaseApplicationPage(BasePage): on_delete=models.SET_NULL, related_name='application_public', ) - body = StreamField(FundBlock()) + body = StreamField(FundBlock(), use_json_field=True) search_fields = BasePage.search_fields + [ index.SearchField('introduction'), @@ -150,7 +150,7 @@ class LabPage(BasePage): ) lab_link = models.CharField(blank=True, max_length=255, verbose_name=_('External link'), validators=[MailToAndURLValidator()]) link_text = models.CharField(max_length=255, help_text=_('Text to display on the button for external links'), blank=True) - body = StreamField(LabBlock()) + body = StreamField(LabBlock(), use_json_field=True) search_fields = BasePage.search_fields + [ index.SearchField('introduction'), diff --git a/hypha/public/home/models.py b/hypha/public/home/models.py index cb1400819..6d22debd8 100644 --- a/hypha/public/home/models.py +++ b/hypha/public/home/models.py @@ -78,7 +78,7 @@ class HomePage(BasePage): our_work_title = models.CharField(max_length=255) our_work = StreamField([ ('work', OurWorkBlock()), - ]) + ], use_json_field=True) our_work_link = models.ForeignKey('wagtailcore.Page', related_name='+', on_delete=models.PROTECT) our_work_link_text = models.CharField(max_length=255) diff --git a/hypha/public/navigation/models.py b/hypha/public/navigation/models.py index 71afbf943..f58d95c85 100644 --- a/hypha/public/navigation/models.py +++ b/hypha/public/navigation/models.py @@ -19,7 +19,8 @@ class NavigationSettings(BaseSetting, ClusterableModel): primary_navigation = StreamField( [('link', LinkBlock()), ], blank=True, - help_text=_('Main site navigation') + help_text=_('Main site navigation'), + use_json_field=True, ) panels = [ diff --git a/hypha/public/news/models.py b/hypha/public/news/models.py index 6d3eca87b..95914d063 100644 --- a/hypha/public/news/models.py +++ b/hypha/public/news/models.py @@ -98,7 +98,10 @@ class NewsPage(BasePage): help_text=_('Use this field to override the date that the news item appears to have been published.') ) introduction = models.TextField(blank=True) - body = StreamField(NewsStoryBlock(block_counts={'awesome_table_widget': {'max_num': 1}})) + body = StreamField( + NewsStoryBlock(block_counts={'awesome_table_widget': {'max_num': 1}}), + use_json_field=True + ) search_fields = BasePage.search_fields + [ index.SearchField('introduction'), diff --git a/hypha/public/people/models.py b/hypha/public/people/models.py index 763543683..377e07a87 100644 --- a/hypha/public/people/models.py +++ b/hypha/public/people/models.py @@ -164,7 +164,7 @@ class PersonPage(FundingMixin, BasePage): job_title = models.CharField(max_length=255, blank=True) introduction = models.TextField(blank=True) website = models.URLField(blank=True, max_length=255) - biography = StreamField(StoryBlock(), blank=True) + biography = StreamField(StoryBlock(), blank=True, use_json_field=True) email = models.EmailField(blank=True) objects = PageManager.from_queryset(PersonQuerySet)() diff --git a/hypha/public/projects/models.py b/hypha/public/projects/models.py index b37c9400a..bf05672d3 100644 --- a/hypha/public/projects/models.py +++ b/hypha/public/projects/models.py @@ -112,7 +112,7 @@ class ProjectPage(FundingMixin, BasePage): on_delete=models.SET_NULL ) status = models.CharField(choices=STATUSES, max_length=25, default=STATUSES[0][0]) - body = StreamField(StoryBlock()) + body = StreamField(StoryBlock(), use_json_field=True) categories = models.TextField(default='{}', blank=True) diff --git a/hypha/public/standardpages/models.py b/hypha/public/standardpages/models.py index b37ce19d1..d6ee0df12 100644 --- a/hypha/public/standardpages/models.py +++ b/hypha/public/standardpages/models.py @@ -18,7 +18,7 @@ class InformationPageRelatedPage(RelatedPage): class InformationPage(BasePage): introduction = models.TextField(blank=True) - body = StreamField(StoryBlock()) + body = StreamField(StoryBlock(), use_json_field=True) search_fields = BasePage.search_fields + [ index.SearchField('introduction'), diff --git a/hypha/public/utils/models.py b/hypha/public/utils/models.py index 4b056c9c4..530eea808 100644 --- a/hypha/public/utils/models.py +++ b/hypha/public/utils/models.py @@ -160,7 +160,8 @@ class CallToActionSnippet(models.Model): ], icon='link'), ), ], max_num=1, required=True), - blank=True + blank=True, + use_json_field=True ) panels = [ -- GitLab