Skip to content

Commit

Permalink
Merge pull request #799 from uchicago-library/798-move-inactive-group…
Browse files Browse the repository at this point in the history
…s-to-a-separate-page

Move Inactive Groups to a Separate Page
  • Loading branch information
bbusenius authored Jan 15, 2025
2 parents 44f9918 + 6273e87 commit f4e51a4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion base/fixtures/test.json

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions group/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,11 @@ class GroupIndexPage(BasePage):
Receptacle page for holding groups.
"""

max_count = 1
subpage_types = ['group.GroupPage']
subpage_types = [
'group.GroupPage',
'group.GroupIndexPage',
'base.IntranetPlainPage',
]
intro = RichTextField()

content_panels = (
Expand All @@ -597,8 +600,8 @@ def get_context(self, request):

groups_active = [
{
'title': GroupIndexPage.objects.first().title,
'url': GroupIndexPage.objects.first().url,
'title': self.title,
'url': self.url,
'children': [],
}
]
Expand All @@ -609,10 +612,12 @@ def get_context(self, request):
# create it. Then continue on, one descendant at a time, either adding
# new levels or using the existing ones if they're already there
# from previous group pages.
for grouppage in GroupPage.objects.live().filter(is_active=True):
for grouppage in (
GroupPage.objects.live().child_of(self).filter(is_active=True)
):
ancestors = (
[GroupIndexPage.objects.first()]
+ list(GroupPage.objects.ancestor_of(grouppage))
[self]
+ list(GroupPage.objects.descendant_of(grouppage))
+ [grouppage]
)
currentlevel = groups_active
Expand Down Expand Up @@ -669,7 +674,10 @@ def get_html(currentlevel):
context['groups_inactive'] = list(
map(
lambda g: {'title': g.title, 'url': g.url},
GroupPage.objects.live().filter(is_active=False).order_by('title'),
GroupPage.objects.live()
.child_of(self)
.filter(is_active=False)
.order_by('title'),
)
)
return context
42 changes: 22 additions & 20 deletions group/templates/group/group_index_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@
{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}

{% block content %}
<div class="row-fluid">
<div class="col-xs-12 col-sm-12 col-md-12 swnews">
<article>
<h1>{{ self.title }}</h1>

{{ self.intro|richtext }}

<div class="grouplist">
{{ groups_active_html|richtext }}
</div>

<h2>Inactive Groups</h2>
<div class="inactive-groups">
<ul>
{% for group in groups_inactive %}
<li><a href="{{ group.url }}">{{ group.title }}</a></li>
{% endfor %}
</ul>
<div class="row-fluid">
<div class="col-xs-12 col-sm-12 col-md-12 swnews">
<article>
<h1>{{ self.title }}</h1>

{{ self.intro|richtext }}

<div class="grouplist">
{{ groups_active_html|richtext }}
</div>

{% if groups_inactive %}
<h2>Inactive Groups</h2>
<div class="inactive-groups">
<ul>
{% for group in groups_inactive %}
<li><a href="{{ group.url }}">{{ group.title }}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
</article>
</div>
</article>
</div>
</div>
{% endblock %}

0 comments on commit f4e51a4

Please sign in to comment.