Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POR-230 use data layer count across story sections as metric #94

Open
wants to merge 1 commit into
base: prototype
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions portal/ocean_stories/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def parsed_map_state(self):
else:
s = json.loads(self.map_state)
return s
def data_layers(self):
return self.parsed_map_state['dataLayers'].keys()

def clean(self):
super(OceanStorySectionBase, self).clean()
Expand Down Expand Up @@ -109,7 +111,12 @@ def as_json(self):
o = {'sections': []}
return json.dumps(o);

def data_layers(self):
return set.union(*[set(s.data_layers()) for s in self.sections.all()])

def badge_metric(self):
return len(self.data_layers())

OceanStory.content_panels = DetailPageBase.content_panels + [
MultiFieldPanel([FieldPanel('hook'), FieldPanel('explore_title'), FieldPanel('explore_url')], "Map overlay"),
InlinePanel( OceanStory, 'sections', label="Sections" ),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "portal/components/card.html" %}

{% block media %}
<a class="badge" href="{{ item.url }}">{{ item.sections.all|length }}</a>
<a class="badge" href="{{ item.url }}">{{ item.badge_metric }}</a>
<a href="{{item.explore_url}}" title="{{item.explore_text}}"><span class="icon icon-marco"></span></a>
{% endblock %}