Skip to content

Commit

Permalink
Merge branch 'master' into links-title
Browse files Browse the repository at this point in the history
  • Loading branch information
RabiaSajjad committed Sep 10, 2024
2 parents 212e2fa + 0938473 commit 628108d
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 6 deletions.
9 changes: 4 additions & 5 deletions bin/pd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,15 @@ upload-qpnotes: $(workdir)/filtered/qpnotes.csv $(workdir)/filtered/qpnotes-nil.
@$(ckanapi) action resource_patch -c $(registry_ini) \
id=c55a2862-7ec4-462c-a844-22acab664812 upload@"$(workdir)/filtered/qpnotes.csv" \
> /dev/null
# @$(ckanapi) action resource_patch -c $(registry_ini) \
# id=TBD upload@"$(workdir)/filtered/qpnotes-nil.csv" \
# > /dev/null
@$(ckanapi) action resource_patch -c $(registry_ini) \
id=dba8cc4a-2a57-435c-a270-fa024474e609 upload@"$(workdir)/filtered/qpnotes-nil.csv" \
> /dev/null

.PHONY: rebuild-qpnotes
rebuild-qpnotes: $(workdir)/filtered/qpnotes.csv $(workdir)/filtered/qpnotes-nil.csv
@$(echo_date) Rebuilding Question Period Notes...
@$(oc_search) import_data_csv --csv "$(workdir)/filtered/qpnotes.csv" --search qpnotes --quiet

# @$(oc_search) import_data_csv --csv "$(workdir)/filtered/qpnotes-nil.csv" --search qpnotes --nothing_to_report
@$(oc_search) import_data_csv --csv "$(workdir)/filtered/qpnotes-nil.csv" --search qpnotes --nothing_to_report

$(workdir)/qpnotes.csv:
$(ckan_command) -c $(registry_ini) $(combine) qpnotes -d $(workdir)
Expand Down
1 change: 1 addition & 0 deletions changes/1507.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enabling upload of the QPNOTES-nil.csv file now that there is nothing-to-report data for QPNOTES PDs.
1 change: 1 addition & 0 deletions changes/1508.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The URL on resource pages shows English URL from cloudstorage for resources uploaded to the datastore. The immediate fix is to remove the URL since it is repetitive. This would not have any impact on UX because users can use the blue button to download resources.
1 change: 1 addition & 0 deletions changes/1509.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add published_resource_id for the QPNOTES-nil.csv resource file. Needed for PR 1507
1 change: 1 addition & 0 deletions changes/1511.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nap5: enforce validation on status, progress fields
4 changes: 4 additions & 0 deletions ckanext/canada/tables/nap5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,10 @@ resources:
errors := errors || choice_error(NEW.indicators,
array(SELECT unnest from unnest({indicators}) where left(unnest, length(NEW.milestones)) = NEW.milestones),
'indicators');
errors := errors || required_error(NEW.status, 'status');
errors := errors || choice_error(NEW.status, {status}, 'status');
errors := errors || required_error(NEW.progress_en, 'progress_en');
errors := errors || required_error(NEW.progress_fr, 'progress_fr');
IF errors = '{{}}' THEN
RETURN NEW;
END IF;
Expand Down
3 changes: 3 additions & 0 deletions ckanext/canada/tables/qpnotes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ resources:

- title: Proactive Publication - Question Period Notes Nothing to Report
resource_name: qpnotes-nil

published_resource_id: dba8cc4a-2a57-435c-a270-fa024474e609

create_form: true
edit_form: false #edit not possible for nil reports since only stored data is primary key
fields:
Expand Down
2 changes: 1 addition & 1 deletion ckanext/canada/templates/package/resource_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{% block resource_content %}
{% block resource_read_title %}{{ super() }}{% endblock %}
{% block resource_read_url %}
{{ super() }}
<p class="mrgn-bttm-lg">&nbsp;</p>
{% endblock %}
{% endblock %}

Expand Down
68 changes: 68 additions & 0 deletions ckanext/canada/tests/test_nap5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: UTF-8 -*-
from ckanext.canada.tests import CanadaTestBase
from ckanapi import LocalCKAN, ValidationError

import pytest
from ckanext.canada.tests.factories import CanadaOrganization as Organization

from ckanext.recombinant.tables import get_chromo


class TestNap5(CanadaTestBase):
@classmethod
def setup_method(self, method):
"""Method is called at class level before EACH test methods of the class are called.
Setup any state specific to the execution of the given class methods.
"""
super(TestNap5, self).setup_method(method)

org = Organization()
self.lc = LocalCKAN()

self.lc.action.recombinant_create(dataset_type='nap5', owner_org=org['name'])
rval = self.lc.action.recombinant_show(dataset_type='nap5', owner_org=org['name'])

self.resource_id = rval['resources'][0]['id']


def test_example(self):
record = get_chromo('nap5')['examples']['record']
self.lc.action.datastore_upsert(
resource_id=self.resource_id,
records=[record])


def test_blank(self):
with pytest.raises(ValidationError) as ve:
self.lc.action.datastore_upsert(
resource_id=self.resource_id,
records=[{}])
err = ve.value.error_dict
assert 'key' in err, err


def test_required(self):
record = dict(
get_chromo('nap5')['examples']['record'],
commitments='',
milestones='',
status='',
progress_en='',
progress_fr='',
)
with pytest.raises(ValidationError) as ve:
self.lc.action.datastore_upsert(
resource_id=self.resource_id,
records=[record])
err = ve.value.error_dict['records'][0]
expected = {
'commitments': ['This field must not be empty'],
'milestones': ['This field must not be empty'],
'status': ['This field must not be empty'],
'progress_en': ['This field must not be empty'],
'progress_fr': ['This field must not be empty'],
}
assert isinstance(err, dict), err
for k in set(err) | set(expected):
assert k in err
assert err[k] == expected[k]

0 comments on commit 628108d

Please sign in to comment.