Skip to content

Commit

Permalink
Merge branch 'hotfix/4.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Sep 10, 2024
2 parents cfc3afc + 42c260a commit c6c8423
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 57 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

4.0.1
-----
- bugfix: `Title` related positions should be optional when creating new titles
- Add support for Plausible analytics; configurable with ``PLAUSIBLE_ANALYTICS_SCRIPT``
and ``PLAUSIBLE_ANALYTICS_404s = True``
- Accessibility fixes

4.0.0
-----
- Major overhaul, redesigned and rebuilt by Springload
Expand Down
2 changes: 1 addition & 1 deletion cdhweb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "4.0.0"
__version__ = "4.0.1"


# context processor to add version to the template environment; can be
Expand Down
6 changes: 6 additions & 0 deletions cdhweb/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def template_settings(request):
"GTAGS_ANALYTICS_ID": getattr(
settings, "GTAGS_ANALYTICS_ID", not settings.DEBUG
),
"PLAUSIBLE_ANALYTICS_SCRIPT": getattr(
settings, "PLAUSIBLE_ANALYTICS_SCRIPT", not settings.DEBUG
),
"PLAUSIBLE_ANALYTICS_404s": getattr(
settings, "PLAUSIBLE_ANALYTICS_404s", not settings.DEBUG
),
# pass any feature flags that are configured
"FEATURE_FLAGS": feature_flags,
"FAVICON": favicon_path(),
Expand Down
12 changes: 7 additions & 5 deletions cdhweb/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Title(models.Model):

title = models.CharField(max_length=255, unique=True)
sort_order = models.PositiveIntegerField(default=0, blank=False, null=False)
positions = models.ManyToManyField("people.Person", through="Position")
positions = models.ManyToManyField("people.Person", through="Position", blank=True)

class Meta:
ordering = ["sort_order"]
Expand Down Expand Up @@ -647,8 +647,10 @@ class PeopleCategories(models.TextChoices):
"sits_with_executive_committee",
"Sits with Executive Committee",
)
PAST_EXECUTIVE_COMMITTEE = "past executive committee", "Past Executive Committee"

PAST_EXECUTIVE_COMMITTEE = (
"past executive committee",
"Past Executive Committee",
)

category = models.CharField(
choices=PeopleCategories.choices,
Expand All @@ -671,7 +673,7 @@ def get_context(self, request, *args, **kwargs):
self.PeopleCategories.PAST_AFFILIATES: self.get_past_affiliates,
self.PeopleCategories.EXECUTIVE_COMMITTEE: self.get_executive_committee,
self.PeopleCategories.SITS_WITH_EXECUTIVE_COMMITTEE: self.get_sits_with_executive_committee,
self.PeopleCategories.PAST_EXECUTIVE_COMMITTEE: self.get_past_executive_committee
self.PeopleCategories.PAST_EXECUTIVE_COMMITTEE: self.get_past_executive_committee,
}

people = category_mapping[self.category]()
Expand Down Expand Up @@ -791,7 +793,7 @@ def get_sits_with_executive_committee(self):
.distinct()
)
return people

def get_past_executive_committee(self):
people_queryset = (
Person.objects.executive_committee()
Expand Down
6 changes: 6 additions & 0 deletions cdhweb/settings/local_settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ NEVERCACHE_KEY = ""
# DATABASES["default"]["USER"] = ""
DATABASES["default"]["PASSWORD"] = ""

# INCLUDE_ANALYTICS = True

# Configure google id to enable analytics in production
# GTAGS_ANALYTICS_ID = ""

# Configure to enable Plausible analytics in production with desired options
# PLAUSIBLE_ANALYTICS_SCRIPT = "https://plausible.io/js/script.file-downloads.hash.outbound-links.js"
# PLAUSIBLE_ANALYTICS_404s = True

# configure ldap servers, search base, and filter
PUCAS_LDAP.update(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const DesktopMenuItem = ({
className={cx('main-nav-desktop__item', {
'main-nav-desktop__item--current-section': item.is_current,
})}
aria-current={item.is_current ? 'page' : undefined}
>
<span>{item.title}</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const MobileMenuItem = ({
/>
</button>
) : (
<a href={item.link_url} className="mobile-menu__nav-btn">
<a
href={item.link_url}
className="mobile-menu__nav-btn"
aria-current={item.is_current ? 'page' : undefined}
>
<span>{item.title}</span>
<Svg
sprite="two-tone"
Expand Down
2 changes: 1 addition & 1 deletion cdhweb/static_src/global/components/main-nav-desktop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
}

.main-nav-desktop__item--current-section {
border-color: var(--color-brand-40);
border-color: var(--color-brand-100);
}

.main-nav-desktop__dropdown-icon {
Expand Down
2 changes: 1 addition & 1 deletion cdhweb/static_src/global/mixins/three-dee-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}

& > * {
// Make content appear in front of 3d box's solid background
isolation: isolate;
z-index: 1;
}
}
67 changes: 26 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
{% endwith %}
{% endwith %}
{% endblock %}

{% block extra_js %}
{% if PLAUSIBLE_ANALYTICS_404s %}
<script>document.addEventListener('DOMContentLoaded', function () { plausible('404', { props: { path: document.location.pathname } }); });</script>
{% endif %}
{% endblock %}
1 change: 1 addition & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');
</script>
{% include "snippets/plausible_analytics.html" %}

{% block extra_css %}
{# Needed for specific cases #}
Expand Down
7 changes: 5 additions & 2 deletions templates/includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
class="main-nav-desktop__item
{% if request.path|starts_with:item.link_url %}
main-nav-desktop__item--current-section
{% endif %}
">
{% endif %}"
{% if request.path|starts_with:item.link_url and not item.l2_items.all %}
aria-current="page"
{% endif %}
>
<span>{{ item.title }}</span>
{# Reserve space for dropdown icon, to stop jank when the React version replaces this version. #}
{% if item.l2_items.all %}
Expand Down
2 changes: 1 addition & 1 deletion templates/includes/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{# always display current page, marked as active #}
{% if number == page_obj.number %}
<a title="page {{number}}" class="pagination__item pagination__item--current" href="?{% url_replace 'page' number %}">{{ number }}</a>
<a title="page {{number}}" class="pagination__item pagination__item--current" href="?{% url_replace 'page' number %}" aria-current="page">{{ number }}</a>

{# for current page 1 or 2, display first 5 #}
{% elif page_obj.number <= 2 and number <= 5 %}
Expand Down
5 changes: 1 addition & 4 deletions templates/snippets/analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@

gtag('config', '{{ GTAGS_ANALYTICS_ID }}');

</script>
{# plausible analytics #}
<script defer data-domain="cdh.princeton.edu" src="https://plausible.io/js/script.file-downloads.hash.outbound-links.js"></script>
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
</script>
8 changes: 8 additions & 0 deletions templates/snippets/plausible_analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if INCLUDE_ANALYTICS and PLAUSIBLE_ANALYTICS_SCRIPT %}
{# TODO: move plausible opts to config, then pass through #}
{# plausible analytics #}
<script defer data-domain="cdh.princeton.edu" src="{{ PLAUSIBLE_ANALYTICS_SCRIPT }} "></script>
{% if PLAUSIBLE_ANALYTICS_404s %}
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
{% endif %}
{% endif %}

0 comments on commit c6c8423

Please sign in to comment.