Skip to content

Commit

Permalink
Add optional long description for reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Zharktas committed Mar 5, 2024
1 parent 98ce3cf commit 4dd72c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ckanext/report/report_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

REPORT_KEYS_REQUIRED = set(('name', 'generate', 'template', 'option_defaults',
'option_combinations'))
REPORT_KEYS_OPTIONAL = set(('title', 'description', 'authorize'))
REPORT_KEYS_OPTIONAL = set(('title', 'description', 'long_description', 'authorize'))


class Report(object):
Expand Down Expand Up @@ -51,6 +51,8 @@ def __init__(self, report_info_dict, plugin):
self.title = re.sub('[_-]', ' ', self.name.capitalize())
elif key == 'description':
self.description = ''
elif key == 'long_description':
self.long_description = ''

def generate_key(self, option_dict, defaults_for_missing_keys=True):
'''Returns a key that will identify the report and options when saved
Expand Down Expand Up @@ -159,6 +161,7 @@ def as_dict(self):
return {'name': self.name,
'title': self.title,
'description': self.description,
'long_description': self.long_description,
'option_defaults': self.option_defaults,
'template': self.get_template()}

Expand Down
2 changes: 1 addition & 1 deletion ckanext/report/templates/report/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% set type = 'asset' if h.check_ckan_version(min_version="2.9.0", max_version="3.0.0") else 'resource' %}
{% include 'report/report_js_' ~ type ~ '.html' %}
<h1>{{ _(report.title) }}</h1>
<p>{{ _(report.description) }}</p>
<p>{{ _(report.long_description if report.long_description else report.description) }}</p>
<p>
{{ _('Generated') }}: {{ h.render_datetime(report_date, with_hours=True) }}
</p>
Expand Down

0 comments on commit 4dd72c8

Please sign in to comment.