Skip to content

Commit

Permalink
Add method/field/role as tags on Project pages
Browse files Browse the repository at this point in the history
  • Loading branch information
haydngreatnews committed Jul 21, 2024
1 parent 4d98407 commit e33eaff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cdhweb/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ class ProjectFiltersForm(forms.Form):
empty_label="--Select--",
required=False,
blank=True,
label="Method/Approach"
label="Method/Approach",
)
field = forms.ModelChoiceField(
ProjectField.objects.all(),
empty_label="--Select--",
required=False,
blank=True,
label="Field of Study"
label="Field of Study",
)
role = forms.ModelChoiceField(
ProjectRole.objects.all(),
empty_label="--Select--",
required=False,
blank=True,
label="Role"
label="Role",
)
current = forms.BooleanField(required=False, initial=True)
cdh_built = forms.BooleanField(required=False, label="Built by CDH")
10 changes: 10 additions & 0 deletions cdhweb/projects/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import itertools

from django import forms
from django.db import models
from django.utils import timezone
Expand Down Expand Up @@ -279,6 +281,14 @@ def get_sitemap_urls(self, request):
urls[0]["priority"] = 0.6
return urls

def display_tags(self):
return sorted(
str(t)
for t in itertools.chain(
self.method.all(), self.field.all(), self.role.all()
)
)


class GrantType(models.Model):
"""Model to track kinds of grants"""
Expand Down
14 changes: 7 additions & 7 deletions templates/includes/project_hero.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% load wagtailcore_tags wagtailimages_tags l10n %}

<div class="project-hero content-width grid-standard">

<div class="project-hero__title">
<h1>{{ self.title}}</h1>
{% if page.cdh_built %}<div class="tag tag--dark">Built by CDH</div>{% endif %}
Expand All @@ -11,10 +11,10 @@ <h1>{{ self.title}}</h1>
{{ self.description | richtext }}
{% endif %}

{% if self.tags.all %}
{% if self.display_tags %}
<div class="tag-list">
{% for tag in self.tags.all %}
<div class="tag">{{ tag }}</div>
{% for tag in self.display_tags %}
<div class="tag">{{ tag }}</div>
{% endfor %}
</div>
{% endif %}
Expand All @@ -28,7 +28,7 @@ <h1>{{ self.title}}</h1>
</div>

{% if self.hero_image %}
{% comment %}
{% comment %}
All are cropped to a 16:9 ratio. This differs from design, as discussed.
If changing this by image rendition, update aspect-ratio in the CSS instead
of via inline style.
Expand All @@ -42,11 +42,11 @@ <h1>{{ self.title}}</h1>
<source srcset="{{ img_sm.url }}" media="(min-width: 500px)">
<source srcset="{{ img_xl.url }}" media="(min-width: 1200px)">
<img
src="{{ img_base.url }}"
src="{{ img_base.url }}"
alt="{{ self.alt_text|default:img_base.alt }}"
style="aspect-ratio: {{ img_base.width|unlocalize }} / {{ img_base.height|unlocalize }}"
/>
</picture>
{% endif %}

</div>

0 comments on commit e33eaff

Please sign in to comment.