Skip to content
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
8 changes: 8 additions & 0 deletions ckanext/open_alberta/fanstatic/js/admin.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ $(function() {
urlfld.val('').parent().parent().hide();
}
});

var cb = $('#field-ckan-abgov-display-notice');
// A standard checkbox doesn't bind it's value to the checked state
cb.change(function() {
var me = $(this);
me.val(me.is(':checked')? 'True': 'False');
})
.prop('checked', cb.val()=='True');
});
15 changes: 13 additions & 2 deletions ckanext/open_alberta/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def before_map(self, m):

import ckan.controllers.admin as admin
import ckan.controllers.home as home
from ckan.lib.app_globals import app_globals

_orig_get_config_form_items = admin.AdminController._get_config_form_items
_orig_home_index = home.HomeController.index
Expand All @@ -134,14 +135,21 @@ def __patched__get_config_form_items(self):
'control': 'input',
'label': _('Home Page URL'),
'placeholder': _('Redirect URL')})
ret.append({'name': 'ckan.abgov_display_notice',
'control': 'checkbox',
'value': toolkit.asbool(app_globals.abgov_display_notice),
'label': _('Display site notice')})
ret.append({'name': 'ckan.abgov_notice',
'control': 'markdown',
'label': _('Site notice'),
'placeholder': _('Markdown syntax. Raw HTML is also suppported.')})
return ret

def _index_or_redirect(self):
""" Overide CKAN home controller to allow for home page redirect.
The redirect happens when home page layout number is set to 301.
The url is saved by CKAN admin Config Options page (customized above).
"""
from ckan.lib.app_globals import app_globals
from pylons.controllers.util import redirect
if app_globals.homepage_style == '301':
redirect(app_globals.abgov_301_url, code=301)
Expand Down Expand Up @@ -200,9 +208,12 @@ def update_config(self, config_):
toolkit.add_resource('fanstatic', 'open_alberta')

def update_config_schema(self, schema):
from ckan.logic.validators import boolean_validator
schema.update({
'menu_items': [],
'ckan.abgov_301_url': []
'ckan.abgov_301_url': [],
'ckan.abgov_display_notice': [boolean_validator],
'ckan.abgov_notice': []
})
return schema

Expand Down
8 changes: 5 additions & 3 deletions ckanext/open_alberta/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

{% block header_wrapper %}
{% block header_account %}
<div class="system-notice">
<i class="fa fa-info-circle"></i>Internal Data Discovery Portal Project Status: Content entered will now be retained. Testing and development of IDDP is ongoing at this time and your feedback is encouraged. Please click <a href="https://exts2.aep.alberta.ca/IRMS/Pages/IRMS-Informatics.aspx">here</a> to learn more.
</div>
{% if g.abgov_display_notice == 'True' %}
<div class="system-notice">
{{ h.render_markdown(g.abgov_notice, allow_html=True) }}
</div>
{% endif %}
<header class="account-masthead">
<div class="container-fluid">
{% block header_account_container_content %}
Expand Down