-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b20ed58
commit 4ea8fe3
Showing
36 changed files
with
1,977 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
{% block branding_welcome %} | ||
Editor's Controls for {{site_name}} | ||
{% endblock %} | ||
{# -*- Django HTML -*- #} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/edrnsite.content/src/edrnsite/content/management/commands/edrn_new_explorers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# encoding: utf-8 | ||
|
||
'''😌 EDRN Site Content: remove old explorer, create new one.''' | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
from edrnsite.content.models import FlexPage | ||
from edrnsite.policy.management.commands.utils import set_site | ||
from edrnsite.streams.views import update_data_element_explorer_trees | ||
from wagtail.models import Page | ||
from wagtail.rich_text import RichText | ||
|
||
|
||
_help_html = '''<p>To use the data models:</p> | ||
<ul> | ||
<li>Click/tap on the triangle icon to the left of each section to expand and view its contents.</li> | ||
<li>Click/tap on the text within a section to access detailed information about the model, including its specific attributes and details.</li> | ||
</ul>''' | ||
|
||
_faq_html = '''<p>For questions about the data models, <a href="mailto:ic-portal@jpl.nasa.gov">email | ||
the Informatics Center</a>.''' | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Replace old CDE viewer page with new block-based explorer flex page' | ||
|
||
def _update_cde_explorer(self, home_page): | ||
# There should be just one current CDEExplorerPage | ||
count = Page.objects.filter(slug='edrn-data-model').count() | ||
if count > 1: | ||
raise ValueError("There's more than one edrn-data-model! Not sure what to do") | ||
elif count == 0: | ||
self.stdout.write('No edrn-data-model found, so using existing "cde" page as the parent') | ||
parent = FlexPage.objects.filter(slug='cde').first() | ||
assert parent is not None | ||
else: | ||
self.stdout.write('Found the one edrn-data-model, deleting it') | ||
page = Page.objects.filter(slug='edrn-data-model').first() | ||
parent = page.get_parent() | ||
page.delete() | ||
parent.refresh_from_db() | ||
|
||
self.stdout.write('Creating new EDRN Data Model page') | ||
page = FlexPage(title='EDRN Data Model', slug='edrn-data-model', show_in_menus=False) | ||
parent.add_child(instance=page) | ||
|
||
page.body.append(('rich_text', RichText(_help_html))) | ||
page.body.append(('data_explorer', { | ||
'title': 'Biomarker Data Models', | ||
'block_id': 'bio', 'spreadsheet_id': '1Kjkvi-bF5GNpAzvq4Kq6r4g1WpceIyP0Srs2OHJJtGs', | ||
})) | ||
page.body.append(('data_explorer', { | ||
'title': 'Cancer Biomarker Data Commons (LabCAS) Data Model', | ||
'block_id': 'lab', 'spreadsheet_id': '1btbwoROmVbZlzSLBn3DQ_6rakZ48j24p-NoOkI3OCFg' | ||
})) | ||
page.body.append(('rich_text', RichText(_faq_html))) | ||
page.save() | ||
update_data_element_explorer_trees() | ||
|
||
def handle(self, *args, **options): | ||
self.stdout.write('Updating CDE explorer') | ||
|
||
old = getattr(settings, 'WAGTAILREDIRECTS_AUTO_CREATE', True) | ||
try: | ||
settings.WAGTAILREDIRECTS_AUTO_CREATE = False | ||
settings.WAGTAILSEARCH_BACKENDS['default']['AUTO_UPDATE'] = False | ||
site, home_page = set_site() | ||
self._update_cde_explorer(home_page) | ||
|
||
finally: | ||
settings.WAGTAILREDIRECTS_AUTO_CREATE = old | ||
settings.WAGTAILSEARCH_BACKENDS['default']['AUTO_UPDATE'] = True | ||
self.stdout.write("Job's done!") |
160 changes: 160 additions & 0 deletions
160
src/edrnsite.content/src/edrnsite/content/migrations/0035_alter_flexpage_body.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# Generated by Django 4.2.17 on 2025-01-10 18:20 | ||
|
||
from django.db import migrations | ||
import edrnsite.streams.blocks | ||
import wagtail.blocks | ||
import wagtail.contrib.typed_table_block.blocks | ||
import wagtail.fields | ||
import wagtail.images.blocks | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("edrnsitecontent", "0034_biomarkersubmissionformpage"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="flexpage", | ||
name="body", | ||
field=wagtail.fields.StreamField( | ||
[ | ||
( | ||
"rich_text", | ||
wagtail.blocks.RichTextBlock( | ||
help_text="Richly formatted text", | ||
icon="doc-full", | ||
label="Rich Text", | ||
), | ||
), | ||
( | ||
"cards", | ||
wagtail.blocks.StructBlock( | ||
[ | ||
( | ||
"cards", | ||
wagtail.blocks.ListBlock( | ||
wagtail.blocks.StructBlock( | ||
[ | ||
( | ||
"title", | ||
wagtail.blocks.CharBlock( | ||
help_text="Title of this card, max 100 chars", | ||
max_length=100, | ||
), | ||
) | ||
] | ||
) | ||
), | ||
) | ||
] | ||
), | ||
), | ||
("table", edrnsite.streams.blocks.TableBlock()), | ||
( | ||
"data_explorer", | ||
wagtail.blocks.StructBlock( | ||
[ | ||
( | ||
"attribute_help_text", | ||
wagtail.blocks.CharBlock( | ||
default="Click/tap on an attribute box below to view details about each attribute", | ||
help_text="Helpful text to tell users that attribute buttons can be clicked", | ||
max_length=300, | ||
required=False, | ||
), | ||
) | ||
] | ||
), | ||
), | ||
( | ||
"block_quote", | ||
edrnsite.streams.blocks.BlockQuoteBlock( | ||
help_text="Block quote" | ||
), | ||
), | ||
( | ||
"typed_table", | ||
wagtail.contrib.typed_table_block.blocks.TypedTableBlock( | ||
[ | ||
( | ||
"text", | ||
wagtail.blocks.CharBlock( | ||
help_text="Plain text cell" | ||
), | ||
), | ||
( | ||
"rich_text", | ||
wagtail.blocks.RichTextBlock( | ||
help_text="Rich text cell" | ||
), | ||
), | ||
( | ||
"numeric", | ||
wagtail.blocks.FloatBlock(help_text="Numeric cell"), | ||
), | ||
( | ||
"integer", | ||
wagtail.blocks.IntegerBlock( | ||
help_text="Integer cell" | ||
), | ||
), | ||
( | ||
"page", | ||
wagtail.blocks.PageChooserBlock( | ||
help_text="Page within the site" | ||
), | ||
), | ||
] | ||
), | ||
), | ||
( | ||
"carousel", | ||
wagtail.blocks.StructBlock( | ||
[ | ||
( | ||
"media", | ||
wagtail.blocks.ListBlock( | ||
wagtail.blocks.StructBlock( | ||
[ | ||
( | ||
"image", | ||
wagtail.images.blocks.ImageChooserBlock(), | ||
), | ||
( | ||
"label", | ||
wagtail.blocks.CharBlock( | ||
help_text="Overlaid label, if any", | ||
max_length=120, | ||
required=False, | ||
), | ||
), | ||
( | ||
"caption", | ||
wagtail.blocks.CharBlock( | ||
help_text="Overlaid caption, if any", | ||
max_length=400, | ||
required=False, | ||
), | ||
), | ||
] | ||
) | ||
), | ||
) | ||
] | ||
), | ||
), | ||
( | ||
"raw_html", | ||
wagtail.blocks.RawHTMLBlock( | ||
help_text="Raw HTML (use with care)" | ||
), | ||
), | ||
], | ||
blank=True, | ||
null=True, | ||
use_json_field=True, | ||
), | ||
), | ||
] |
Oops, something went wrong.