Skip to content

Commit

Permalink
Merge branch 'canada-v2.9' into staging-v2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
JVickery-TBS committed Sep 15, 2023
2 parents 67c48ee + fd9a82c commit 180df10
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 9 deletions.
28 changes: 28 additions & 0 deletions ckanext/canada/assets/datatables/canada_datatables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*####################
## Datatables Views ##
######################*/
div#dtprv_processing.dataTables_processing{
z-index: 9999 !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
height: 100% !important;
margin: 0 !important;
/* see static/js/canada_datatables for dynamic styles */
}
div#dtprv_processing.dataTables_processing > div:last-child{
position: absolute !important;
left: 50% !important;
transform: translate(-50%, -50%) !important;
pointer-events: none !important;
/* see static/js/canada_datatables for dynamic styles */
}
div#dtprv_processing.dataTables_processing > div:last-child > div{
background-color: #335075 !important;
pointer-events: none !important;
}
/*#####################
## END ##
## Datatables Views ##
## END ##
#######################*/
31 changes: 31 additions & 0 deletions ckanext/canada/assets/datatables/canada_datatables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
window.addEventListener('load', function(){

$(document).on('preInit.dt', function(_event, _settings){

$('body.dt-view').css('visibility', 'visible');
$('#dtprv_processing').css({
'background-color': 'rgba(255, 255, 255, 1)',
'display': 'block',
'pointer-events': 'all',
});
$('#dtprv_processing > div').css('top', '15%');

});

$(document).on('init.dt', function(){

$('#dtprv_processing').css({
'background-color': 'rgba(255, 255, 255, 0.65)',
'pointer-events': 'none',
});
$('#dtprv_processing > div').css('top', '50%');

});

$(document).on('processing.dt', function(_event, _settings, _processing){

$('#dtprv_processing').css('display', _processing ? 'block' : 'none');

});

});
9 changes: 9 additions & 0 deletions ckanext/canada/assets/datatables/webassets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
css:
contents:
- canada_datatables.css
output: canada_datatables/%(version)s_canada_datatables.css

js:
contents:
- canada_datatables.js
output: canada_datatables/%(version)s_canada_datatables.js
1 change: 1 addition & 0 deletions ckanext/canada/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ def update_config(self, config):
p.toolkit.add_template_directory(config, 'templates/public')
p.toolkit.add_public_directory(config, 'public')
p.toolkit.add_resource('public/static/js', 'js')
p.toolkit.add_resource('assets/datatables', 'canada_datatables')
config['ckan.auth.public_user_details'] = False
config['recombinant.definitions'] = """
ckanext.canada:tables/ati.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% endif %}

<div class="accordion mrgn-tp-lg mrgn-bttm-lg">
{%- if (not data.related_type) or c.action=='new_resource' -%}
{%- if (not data.related_type) or c.action.endswith('new') -%}
<details class="acc-group" open="open">
<summary class="wb-toggle tgl-tab" data-toggle='{"parent": ".accordion", "group": ".acc-group"}'>
{{ _("Metadata Fields for Resources Only (Not for Related Items)") }}
Expand All @@ -36,7 +36,7 @@
</div>
</details>
{% endif %}
{%- if data.related_type or c.action=='new_resource' -%}
{%- if data.related_type or c.action.endswith('new') -%}
<details class="acc-group" {% if data.related_type %}open="open"{% endif %}>
<summary class="wb-toggle tgl-tab" data-toggle='{"parent": ".accordion", "group": ".acc-group"}'>
{{ _("Metadata Fields for Related Items Only") }}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/internal/user/edit_user_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="form-actions">
{% block delete_button %}
{% if h.check_access('user_delete', {'id': data.id}) %}
<a class="btn btn-danger pull-left" href="{{ h.url_for('user_delete', id=data.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{{ h.url_for('user.delete', id=data.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{% block generate_button %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "page.html" %}

{% block subtitle %}{{ _("Confirm Delete") }}{% endblock %}

{% block primary_content_inner %}
<div class="col-md-12">
{% block form %}
<p>{{ _('Are you sure you want to delete this DataStore table and Data Dictionary?') }}</p>
<p class="form-actions">
<form action="{{ h.url_for('canada.delete_datastore_table', id=package_id, resource_id=resource_id) }}" method="post">
<input type="hidden" name="resource_id" value="{{ resource_id }}" />
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
</form>
</p>
{% endblock %}
</div>
{% endblock %}
15 changes: 15 additions & 0 deletions ckanext/canada/templates/public/datatables/datatables_view.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{% ckan_extends %}

{% block page %}
{{ super() }}
<div id="dtprv_processing" class="dataTables_processing card">
<div>
<div></div><div></div><div></div><div></div>
</div>
</div>
{% endblock %}

{%- block datatable_column_label -%}
{%- set label = 'label_' + h.lang() -%}
{%- set description = 'notes_' + h.lang() -%}
Expand Down Expand Up @@ -61,4 +70,10 @@
{%- endblock -%}
{% block google_analytics_footer %}{%- endblock -%}
{{ super() }}
{% asset 'canada_datatables/js' %}
{% endblock %}

{%- block styles %}
{{ super() }}
{% asset 'canada_datatables/css' %}
{%- endblock -%}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
{% block primary_content_inner %}
<div class="col-md-12">
{% block form %}
<p>{{ _('Are you sure you want to delete member - {name}?').format(name=c.user_dict.name) }}</p>
<p>{{ _('Are you sure you want to delete member - {name}?').format(name=user_dict.name) }}</p>
<p class="form-actions">
<form action="{{ h.url_for('organization.member_delete', id=c.group_id) }}" method="post">
<input type="hidden" name="user" value="{{ c.user_id }}" />
<form action="{{ h.url_for('organization.member_delete', id=c.group_id, user=user_id) }}" method="post">
<input type="hidden" name="user" value="{{ user_id }}" />
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
{% endif %}
{% if can_edit and not is_activity_archive %}
<li>{% link_for _('Edit resource'), named_route=pkg.type ~ '_resource.edit', id=pkg.name, resource_id=res.id, class_='dropdown-item', icon='pencil' %}</li>
{% block resource_item_explore_inner scoped %}{% endblock %}
{% block resource_item_explore_inner scoped %}{{ super() }}{% endblock %}
<li>{% link_for _('Views'), named_route=pkg.type ~ '_resource.views', id=pkg.name, resource_id=res.id, class_='dropdown-item', icon='chart-bar' %}
{% endif %}
{% endblock %}
Expand Down
18 changes: 18 additions & 0 deletions ckanext/canada/templates/public/user/confirm_delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "page.html" %}

{% block subtitle %}{{ _("Confirm Delete") }}{% endblock %}

{% block primary_content_inner %}
<div class="col-md-12">
{% block form %}
<p>{{ _('Are you sure you want to delete user - {name}?').format(name=user_dict.name) }}</p>
<p class="form-actions">
<form action="{{ h.url_for('user.delete', id=user_dict.id) }}" method="post">
<input type="hidden" name="id" value="{{ user_dict.id }}" />
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
</form>
</p>
{% endblock %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion ckanext/canada/templates/public/user/edit_user_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<div class="form-actions">
{% block delete_button %}
{% if h.check_access('user_delete', {'id': data.id}) %}
<a class="btn btn-danger pull-left" href="{{ h.url_for('user_delete', id=data.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
<a class="btn btn-danger pull-left" href="{{ h.url_for('user.delete', id=data.id) }}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{% block generate_button %}
Expand Down
19 changes: 18 additions & 1 deletion ckanext/canada/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ def ckanadmin_publish_datasets():

@canada_views.route('/dataset/<id>/delete-datastore-table/<resource_id>', methods=['GET', 'POST'])
def delete_datastore_table(id, resource_id):
if u'cancel' in request.form:
return h.redirect_to(u'xloader.resource_data', id=id, resource_id=resource_id)

if request.method == 'POST':
lc = LocalCKAN(username=g.user)

Expand All @@ -610,12 +613,26 @@ def delete_datastore_table(id, resource_id):
)
except NotAuthorized:
return abort(403, _(u'Unauthorized to delete resource %s') % resource_id)
# FIXME else: render confirmation page for non-JS users

h.flash_notice(_(u'DataStore table and Data Dictionary deleted for resource %s') % resource_id)

return h.redirect_to(
'xloader.resource_data',
id=id,
resource_id=resource_id
)
else:
# TODO: Remove
# ckan 2.9: Adding variables that were removed from c object for
# compatibility with templates in existing extensions
g.resource_id = resource_id
g.package_id = id

extra_vars = {
u"resource_id": resource_id,
u"package_id": id
}
return render(u'canada/confirm_datastore_delete.html', extra_vars)


@canada_views.route('/help', methods=['GET'])
Expand Down

0 comments on commit 180df10

Please sign in to comment.