Skip to content

Commit

Permalink
Merge pull request #764 from sgfost/education-partners
Browse files Browse the repository at this point in the history
add educational partner content
  • Loading branch information
alee authored Sep 24, 2024
2 parents 05b4cee + 15725fa commit eeeb7a6
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 42 deletions.
93 changes: 55 additions & 38 deletions django/home/jinja2/home/education.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,63 @@

{% block content %}
{{ breadcrumb(page.get_breadcrumbs()) }}
<div class='jumbotron'>
<h1>{{ page.heading }}</h1>
<div class='pt-4 lead'>
{{ markdown(page.summary) }}
</div>
</div>
<div class="card-page">
<section class="cards mb-5">
{% set display_tag = request.GET.get("tag") %}
{% if display_tag %}
<div class="tag-display mb-3">
<a href="{{ request.path }}"><span class="fas fa-times"></span></a>
<span>{{ display_tag }}</span>
<ul class="nav nav-tabs justify-content-center" id="education-tabs" role="tablist">
{% for key, name in categories %}
<li class="nav-item">
<a class="nav-link {% if loop.first %}active{% endif %}" id="{{ key }}-tab" data-bs-toggle="tab" href="#{{ key }}" role="tab">
{{ name }}
</a>
</li>
{% endfor %}
</ul>


<div class="tab-content">
{% for key, name in categories %}
<div class="tab-pane {% if loop.first %}show active{% endif %}" id="{{ key }}" role="tabpanel">
<div class='jumbotron'>
<h1>{{ name }}</h1>
<div class='pt-4 lead'>
{{ markdown(jumbotron[key]) }}
</div>
</div>
{% endif %}
{% for batched_cards in cards.all()|batch(3) %}
<div class="row">
{% for card in batched_cards %}
<div class="col-md-4 col-12 d-flex align-items-stretch" style="margin-bottom: 30px;">
<div class="tutorial-card w-100">
{{ image(card.thumbnail_image, "fill-426x240", class='card-image-top card-thumbnail') }}
<div class="card-body">
<h2 class="card-title">{{ card.title }}</h5>
<p class="card-text">{{ markdown(card.summary) }}</p>
<a href="{{ card.url }}" class="stretched-link"></a>
</div>
{% if card.tags.all() %}
<div class="tag-list p-3">
{% for tag in card.tags.all() %}
<a class="tag" href="{{ request.path }}?tag={{ tag.name }}">
{{ tag.name }}
</a>
{% endfor %}
<div class="card-page">
<section class="cards mb-5">
{% set display_tag = request.GET.get("tag") %}
{% if display_tag %}
<div class="tag-display mb-3">
<a href="{{ request.path }}"><span class="fas fa-times"></span></a>
<span>{{ display_tag }}</span>
</div>
{% endif %}
{% for batched_cards in cards.filter(category=key)|batch(3) %}
<div class="row">
{% for card in batched_cards %}
<div class="col-md-4 col-12 d-flex align-items-stretch" style="margin-bottom: 30px;">
<div class="tutorial-card w-100">
{{ image(card.thumbnail_image, "max-350x150", class='card-image-top card-thumbnail') }}
<div class="card-body">
<h2 class="card-title">{{ card.title }}</h5>
<p class="card-text">{{ markdown(card.summary) }}</p>
<a href="{{ card.url }}" class="stretched-link"></a>
</div>
{% if card.tags.all() %}
<div class="tag-list p-3">
{% for tag in card.tags.all() %}
<a class="tag" href="{{ request.path }}?tag={{ tag.name }}">
{{ tag.name }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
{% endfor %}
</section>
</div>
{% endfor %}
</section>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def create_or_update_education_page(self, index):
image_path=tut["thumbnail"],
title=tut["title"],
summary=tut["description"],
category=tut["category"],
tags=tut["tags"],
url=tut["slug"] if not tut["external"] else tut["link"],
sort_order=count,
Expand Down
26 changes: 26 additions & 0 deletions django/home/migrations/0019_tutorialcard_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.15 on 2024-09-23 21:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("home", "0018_alter_journaltag_tag_alter_tutorialtag_tag"),
]

operations = [
migrations.AddField(
model_name="tutorialcard",
name="category",
field=models.CharField(
choices=[
("in-house", "CoMSES"),
("partner", "Partners"),
("community", "Open Science Community"),
],
default="in-house",
max_length=32,
),
),
]
48 changes: 44 additions & 4 deletions django/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def add_callout(
self, image_path, title, caption, sort_order=None, user=None, url=""
):
if user is None:
user = User.objects.get(username="alee")
user = User.get_anonymous()
_image = get_canonical_image(title=title, path=image_path, user=user)
self.callouts.add(
CategoryIndexItem(
Expand Down Expand Up @@ -446,12 +446,20 @@ class EducationPage(NavigationMixin, Page):
)

def add_card(
self, image_path, title, summary, tags=None, sort_order=None, user=None, url=""
self,
image_path,
title,
summary,
category,
tags=None,
sort_order=None,
user=None,
url="",
):
if self.cards.filter(title=title):
return
if user is None:
user = User.objects.get(username="alee")
user = User.get_anonymous()
_image = (
get_canonical_image(title=title, path=image_path, user=user)
if image_path
Expand All @@ -461,6 +469,7 @@ def add_card(
title=title,
sort_order=sort_order,
summary=summary,
category=category,
thumbnail_image=_image,
url=url,
)
Expand All @@ -482,16 +491,47 @@ def get_context(self, request, *args, **kwargs):
cards = cards.filter(tags__name=tag)
context["cards"] = cards.filter(tags__name=tag)
context["cards"] = cards
context["categories"] = TutorialCard.EducationalContentCategory.choices
context["jumbotron"] = self.jumbotron_dict
return context

@property
def jumbotron_dict(self):
return TutorialCard.EducationalContentCategory.jumbotron_dict()


class TutorialTag(TaggedItemBase):
content_object = ParentalKey("TutorialCard", related_name="tagged_items")


class TutorialCard(Orderable, ClusterableModel):
"""Cards displayed in the Education Page"""
"""Content cards displayed in the Education Page"""

class EducationalContentCategory(models.TextChoices):
IN_HOUSE = ("in-house", _("CoMSES"))
PARTNER = ("partner", _("Partners"))
COMMUNITY = ("community", _("Open Science Community"))

@classmethod
def jumbotron_dict(cls):
return {
cls.IN_HOUSE: _(
"""CoMSES Net training modules provide guidance on good practices for computational modeling and sharing your work with [FAIR principles for research software (FAIR4RS)](https://doi.org/10.15497/RDA00068) and general [good enough practices for scientific computation](https://carpentries-lab.github.io/good-enough-practices/) in mind.\n\nOur [education forum](https://forum.comses.net/c/education) also hosts a [community curated list of additional educational resources](https://forum.comses.net/t/educational-resources/9159/2) and can be freely used to discuss, collaborate, and share additional educational resources.
"""
),
cls.PARTNER: _(
"""Educational resources produced by our partners and collaborators, [Community Surface Dynamics Modeling System (CSDMS)](https://csdms.colorado.edu/wiki/Main_Page) and [CUAHSI](https://www.cuahsi.org/)."""
),
cls.COMMUNITY: _(
"""Educational content from the broader open science community."""
),
}

category = models.CharField(
choices=EducationalContentCategory.choices,
default=EducationalContentCategory.IN_HOUSE,
max_length=32,
)
page = ParentalKey("home.EducationPage", related_name="cards")
url = models.CharField("Relative path, absolute path, or URL", max_length=200)
title = models.CharField(max_length=256)
Expand Down
Binary file not shown.
66 changes: 66 additions & 0 deletions django/home/static/education/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,89 @@
{
"external": false,
"slug": "responsible-practices",
"category": "in-house",
"title": "Responsible Practices for Scientific Software",
"description": "A collection of responsible practices for developing and publishing FAIR+ computational models in efforts to be more transparent, interoperable, and reusable in our work.",
"tags": ["FAIR4RS"]
},
{
"external": false,
"slug": "intro-to-git-github",
"category": "in-house",
"title": "Introduction to Git and GitHub",
"description": "Familiarize yourself with Git and GitHub by working through a interactive introductory course hosted on GitHub classrooms.",
"tags": ["git", "github"]
},
{
"external": true,
"link": "https://classroom.github.com/a/WuDb62qc",
"category": "in-house",
"slug": "intro-to-containerization",
"title": "Introduction to Containerization",
"description": "Join this GitHub classroom to learn about containerization, a way to bundle and archive your code in a reproducible manner.",
"tags": ["containerization", "docker"]
},
{
"external": true,
"link": "https://csdms.colorado.edu/wiki/ESPIn",
"category": "partner",
"slug": "espin",
"title": "Earth Surface Processes Institute (ESPIn)",
"description": "Join us for a week-long summer school on numerical modeling, collaborative scientific software development, and the use of open source community cyberinfrastructure.",
"tags": ["CSDMS", "summer school", "earth sciences"]
},
{
"external": true,
"link": "https://csdms.colorado.edu/wiki/Labs_portal",
"category": "partner",
"slug": "csdms-teaching-labs",
"title": "CSDMS Teaching Labs / Notebooks",
"description": "Supplement a course with these curated teaching notebooks covering current topics in earth surface processes research.",
"tags": ["CSDMS", "notebook", "earth sciences"]
},
{
"external": true,
"link": "https://csdms.colorado.edu/wiki/Roadshows",
"category": "partner",
"slug": "csdms-roadshow",
"title": "CSDMS Roadshow",
"description": "CSDMS research software engineers visit your group, lab, or department and present one to three days of interactive instruction on modern scientific software development.",
"tags": ["CSDMS", "research software engineering", "earth sciences"]
},
{
"external": true,
"link": "https://csdms.colorado.edu/wiki/JupyterHub",
"category": "partner",
"slug": "csdms-jupyterhub",
"title": "CSDMS EarthscapeHub",
"description": "Use a CSDMS JupyterHub equipped with software for numerical modeling for teaching university classes or interactive workshops at a conference.",
"tags": ["CSDMS", "notebook", "jupyter", "earth sciences"]
},
{
"external": true,
"link": "https://www.cuahsi.org/virtual-university",
"category": "partner",
"slug": "cuahsi-virtual-university",
"title": "CUAHSI Virtual University",
"description": "The CUAHSI Virtual University (CVU) is a unique multi-institution, one semester graduate course consisting of a diverse set of 4-week modules on specialized hydrology topics. The CVU aims to enhance the depth and breadth of graduate course offerings at universities across the nation and facilitate networking among the hydrologic community.",
"tags": ["CUAHSI", "course", "hydrology"]
},
{
"external": true,
"link": "https://openscience101.org",
"slug": "open-science-101",
"category": "community",
"title": "NASA TOPS Open Science 101",
"description": "A free, online course that will introduce researchers, early-career scientists, and the general public to the principles and practices of open science.",
"tags": ["NASA", "TOPS", "course", "open science"]
},
{
"external": true,
"link": "https://book.the-turing-way.org/",
"slug": "the-turing-way",
"category": "community",
"title": "The Turing Way",
"description": "A handbook to reproducible, ethical, and collaborative data science.",
"tags": ["book", "open science", "data science"]
}
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eeeb7a6

Please sign in to comment.