diff --git a/ckanext/knowledgehub/helpers.py b/ckanext/knowledgehub/helpers.py index d90f6889..9bb242f3 100644 --- a/ckanext/knowledgehub/helpers.py +++ b/ckanext/knowledgehub/helpers.py @@ -721,11 +721,27 @@ def get_dashboards(limit=5, order_by='created_by asc'): def remove_space_for_url(str): return str.replace(" ", "-") + def format_date(str): # split date & time - date = str.split('T') # date[0] is the date, date[1] is the time - time_basic = date[1].split('.') # time_basic[0] = hh/mm/ss - # remove seconds + date = str.split('T') # date[0] is the date, date[1] is the time + time_basic = date[1].split('.') # time_basic[0] = hh/mm/ss + # remove seconds time_basic[0] = time_basic[0][:-3] display_date = date[0] + ' at ' + time_basic[0] return display_date + + +def dashboard_research_questions(dashboard): + questions = [] + if dashboard.get('indicators'): + context = _get_context() + research_question_show = logic.get_action('research_question_show') + for indicator in dashboard['indicators']: + if indicator.get('research_question'): + question = research_question_show(context, { + 'id': indicator['research_question'] + }) + questions.append(question) + + return questions diff --git a/ckanext/knowledgehub/logic/action/create.py b/ckanext/knowledgehub/logic/action/create.py index 30e268d5..c3d3fda1 100644 --- a/ckanext/knowledgehub/logic/action/create.py +++ b/ckanext/knowledgehub/logic/action/create.py @@ -326,6 +326,9 @@ def dashboard_create(context, data_dict): dashboard = Dashboard() + import json + print json.dumps(data_dict, indent=2) + items = ['name', 'title', 'description', 'type'] for item in items: diff --git a/ckanext/knowledgehub/plugin.py b/ckanext/knowledgehub/plugin.py index 4221893a..7e7ddb0b 100644 --- a/ckanext/knowledgehub/plugin.py +++ b/ckanext/knowledgehub/plugin.py @@ -82,7 +82,8 @@ def get_helpers(self): 'get_single_rq': h.get_single_rq, 'get_rqs_dashboards': h.get_rqs_dashboards, 'remove_space_for_url': h.remove_space_for_url, - 'format_date': h.format_date + 'format_date': h.format_date, + 'dashboard_research_questions': h.dashboard_research_questions, } # IDatasetForm diff --git a/ckanext/knowledgehub/templates/dashboard/snippets/research_questions.html b/ckanext/knowledgehub/templates/dashboard/snippets/research_questions.html new file mode 100644 index 00000000..47b495e7 --- /dev/null +++ b/ckanext/knowledgehub/templates/dashboard/snippets/research_questions.html @@ -0,0 +1,11 @@ +
+ {% for question in questions%} + +
+ + {{ question.title | truncate(30) }} +
+
+ {% endfor %} +
\ No newline at end of file diff --git a/ckanext/knowledgehub/templates/dashboard/view.html b/ckanext/knowledgehub/templates/dashboard/view.html index cd28d8b0..84473e35 100644 --- a/ckanext/knowledgehub/templates/dashboard/view.html +++ b/ckanext/knowledgehub/templates/dashboard/view.html @@ -164,11 +164,21 @@ {% endif %} {% endfor %} -
- +
+
+ {% set research_questions = h.dashboard_research_questions(dashboard)%} + {% if research_questions %} + {% snippet 'dashboard/snippets/research_questions.html', questions=research_questions %} + {% endif%} +
+
+
+ +
+