Skip to content

Commit

Permalink
Merge branch 'master' into remove-fb-from-footer
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmoo committed Jul 19, 2018
2 parents caca3d3 + e45a875 commit 254c67b
Show file tree
Hide file tree
Showing 8 changed files with 508 additions and 26 deletions.
11 changes: 0 additions & 11 deletions network-api/networkapi/wagtailpages/customblocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re

from wagtail.core import blocks
from wagtail.images.blocks import ImageChooserBlock

Expand Down Expand Up @@ -252,15 +250,6 @@ class Meta:


class PulseProjectQueryValue(blocks.StructValue):
@property
def query(self):
# Replace any combination of spaces and commas with a single +
# because despite instructions to use spaces, someone, at some
# point, will accidentally use a comma, and that should be fine.
search_terms = self['search_terms'].strip()
query = re.sub(r'[\s,]+', '+', search_terms)
return query

@property
def size(self):
max_number_of_results = self['max_number_of_results']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
data-help="{{ value.help }}"
data-issues="{{ value.issues }}"
data-max="{{ value.size }}"
data-query="{{ value.query }}"
data-reversed="{{ value.newest_first }}" />
data-query="{{ value.search_terms }}"
data-reversed="{{ value.newest_first }}"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="mb-4 hidden-sm-down">
<div class="pb-2 multipage-nav horizontal-nav" id="multipage-nav">
{% for entry in menu_pages %}
<a class="pb-2 multipage-link horizontal-link mr-4 {% if current.title == entry.page.title %}multipage-link-active{% endif %}" href="{% pageurl entry.page %}">{% if entry.depth == 2 %}→ {% endif %}{{ entry.menu_title }}
<a class="pb-2 multipage-link horizontal-link mr-4 {% if current.title == entry.page.title %}multipage-link-active{% endif %} {% if entry.restriction != None %}multipage-{{entry.restriction}}-restricted{% endif %} {% if not entry.page.live %}multipage-draft{% endif %}" href="{% pageurl entry.page %}">{% if entry.depth == 2 %}→ {% endif %}{{ entry.menu_title }}
</a>
{% endfor %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="multipage-nav side-nav" id="multipage-nav">
{% for entry in menu_pages %}
<div>
<a class="multipage-link {% if current.title == entry.page.title %}multipage-link-active{% endif %}" href="{% pageurl entry.page %}">{% if entry.depth == 2 %}→ {% endif %}{{ entry.menu_title }}
<a class="multipage-link {% if current.title == entry.page.title %}multipage-link-active{% endif %} {% if entry.restriction != None %}multipage-{{entry.restriction}}-restricted{% endif %} {% if not entry.page.live %}multipage-draft{% endif %}" href="{% pageurl entry.page %}">{% if entry.depth == 2 %}→ {% endif %}{{ entry.menu_title }}
</a>
</div>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="d-flex flex-row primary-menu" id="multipage-nav">
{% for entry in menu_pages %}
<div>
<a class="multipage-link {% if current.title == entry.page.title %}multipage-link-active{% endif %}" href="{% pageurl entry.page %}">{% if entry.depth == 2 %}→ {% endif %}{{ entry.menu_title }}
<a class="multipage-link {% if current.title == entry.page.title %}multipage-link-active{% endif %} {% if entry.restriction != None %}multipage-{{entry.restriction}}-restricted{% endif %} {% if not entry.page.live %}multipage-draft{% endif %}" href="{% pageurl entry.page %}">{% if entry.depth == 2 %}→ {% endif %}{{ entry.menu_title }}
</a>
</div>
{% endfor %}
Expand Down
11 changes: 9 additions & 2 deletions network-api/networkapi/wagtailpages/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,25 @@ def get_descendants(node, list, authenticated=False, depth=0, max_depth=2):
if header:
title = header
menu_title = title if depth > 0 else 'Overview'
restriction = node.get_view_restrictions().first()
try:
restriction_type = restriction.restriction_type
except AttributeError:
restriction_type = None

list.append({
'page': node,
'menu_title': menu_title,
'depth': depth,
'restriction': restriction_type,
})

nextset = node.get_children().in_menu()

# Do not show draft pages to users who are
# Do not show draft/private pages to users who are
# not logged into the CMS itself.
if authenticated is False:
nextset = nextset.live()
nextset = nextset.live().public()

for child in nextset:
get_descendants(child, list, authenticated, depth + 1)
Expand Down
Loading

0 comments on commit 254c67b

Please sign in to comment.