Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nil report to briefing notes #1411

Merged
merged 12 commits into from
Dec 18, 2023
26 changes: 0 additions & 26 deletions bin/filter/filter_briefingt.py

This file was deleted.

14 changes: 10 additions & 4 deletions bin/pd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ targets := ati briefingt qpnotes consultations contracts contractsa dac experime

csv_files := \
ati.csv ati-nil.csv \
briefingt.csv \
briefingt.csv briefingt-nil.csv \
qpnotes.csv \
contractsa.csv \
contracts.csv contracts-nil.csv \
Expand Down Expand Up @@ -182,22 +182,28 @@ $(workdir)/filtered/ati-nil.csv: $(workdir)/ati-nil.csv
briefingt: upload-briefingt rebuild-briefingt

.PHONY: upload-briefingt
upload-briefingt: $(workdir)/filtered/briefingt.csv
upload-briefingt: $(workdir)/filtered/briefingt.csv $(workdir)/filtered/briefingt-nil.csv
@$(echo_date) Uploading Briefing Note Titles...
@$(ckanapi) action resource_patch -c $(registry_ini) \
id=299a2e26-5103-4a49-ac3a-53db9fcc06c7 upload@"$(workdir)/filtered/briefingt.csv" \
> /dev/null

.PHONY: rebuild-briefingt
rebuild-briefingt: $(workdir)/filtered/briefingt.csv
rebuild-briefingt: $(workdir)/filtered/briefingt.csv $(workdir)/filtered/briefingt-nil.csv
@$(echo_date) Rebuilding Briefing Note Titles...
@$(oc_search) import_data_csv --csv "$(workdir)/filtered/briefingt.csv" --search briefingt --quiet

$(workdir)/briefingt.csv:
$(paster) $(combine) briefingt -d $(workdir) -c $(registry_ini)

$(workdir)/briefingt-nil.csv:
$(paster) $(combine) briefingt-nil -d $(workdir) -c $(registry_ini)

$(workdir)/filtered/briefingt.csv: $(workdir)/briefingt.csv
$(fdir)/filter_briefingt.py < $< > $@
$(fdir)/filter_modified_created.py < $< > $@

$(workdir)/filtered/briefingt-nil.csv: $(workdir)/briefingt-nil.csv
$(fdir)/filter_modified_created.py < $< > $@

###
### Question Period Notes
Expand Down
1 change: 1 addition & 0 deletions bin/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'wrongdoing.csv': 'rows:wrongdoing',
'dac.csv': 'rows:dac',
'briefingt.csv': 'rows:briefingt',
'briefingt-nil.csv': 'rows:briefingt',
'qpnotes.csv': 'rows:qpnotes',
}

Expand Down
136 changes: 136 additions & 0 deletions ckanext/canada/tables/briefingt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,142 @@ resources:
tracking_number: 1089-4266
sort: tracking_number asc

- title: Proactive Publication - Briefing Note Titles and Numbers Nothing to Report
resource_name: briefingt-nil
create_form: true
edit_form: false #edit not possible for nil reports since only stored data is primary key
fields:

- datastore_id: year
datastore_type: year
label: Year
RabiaSajjad marked this conversation as resolved.
Show resolved Hide resolved
description:
en: This tab / field in the template is only populated if there are no briefing notes for the reporting period. This field should be populated with the year of the reporting period.
fr: Cet onglet/champ du modèle n’est rempli que s'il n'y a pas de notes de breffage pour la période d’établissement de rapports. Ce champ doit être rempli avec l’année de la période d’établissement de rapports.
obligation: Mandatory
excel_required: true
form_required: true
validation: This field must not be empty
excel_column_width: 10
extract_date_year: true
form_attrs:
size: 20

- datastore_id: month
datastore_type: text
label:
en: Month
fr: mois
description:
en: This tab / field in the template is only populated if there are no briefing notes for the reporting period. This field should be populated with the month of the reporting period.
fr: Cet onglet/champ du modèle n’est rempli que s'il n'y a pas de notes de breffage pour la période d’établissement de rapports. Ce champ doit être rempli avec le mois de la période d’établissement de rapports.
obligation: Mandatory
excel_required: true
form_required: true
validation: This field must not be empty
excel_full_text_choices: true
choices:
P01:
en: April
fr: avril
P02:
en: May
fr: mai
P03:
en: June
fr: juin
P04:
en: July
fr: juillet
P05:
en: August
fr: août
P06:
en: September
fr: septembre
P07:
en: October
fr: octobre
P08:
en: November
fr: novembre
P09:
en: December
fr: décembre
P10:
en: January
fr: janvier
P11:
en: February
fr: février
P12:
en: March
fr: mars

- datastore_id: record_created
label: Record Creation Time
import_template_include: false
visible_to_public: false
datastore_type: timestamp
preview_class: bg-info

- datastore_id: record_modified
label: Last Record Modification Time
import_template_include: false
visible_to_public: false
datastore_type: timestamp
preview_class: bg-info

- datastore_id: user_modified
label: User Last Modified Record
import_template_include: false
visible_to_public: false
datastore_type: text
preview_class: bg-info


solr_static_fields:
nothing_to_report_en: Nothing to report for this period
nothing_to_report_fr: Rien à signaler pour cette période
report_type_en: Nothing to report
report_type_fr: Rien à signaler

datastore_primary_key: [year, month]
datastore_indexes: ""

triggers:
- briefingt_nil_trigger: |
DECLARE
errors text[][] := '{{}}';
crval RECORD;
BEGIN
errors := errors || required_error(NEW.year, 'year');
errors := errors || required_error(NEW.month, 'month');
errors := errors || choice_error(NEW.month, {month}, 'month');
IF NEW.year > date_part('year', CURRENT_DATE) THEN
errors := errors || ARRAY[['year', {year_error}]];
END IF;
IF errors = '{{}}' THEN
RETURN NEW;
END IF;
RAISE EXCEPTION E'TAB-DELIMITED\t%', array_to_string(errors, E'\t');
END;
- update_record_modified_created_trigger

trigger_strings: # yaml | not supported
year_error: This must list the year you are reporting on (not the fiscal year).

examples:
record:
year: 2023
month: P01
filters:
year: 2023
filter_one:
year: 2023
month: P01
sort: year desc, month desc

excel_edge_style:
PatternFill:
fgColor: FF3d4647
Expand Down
33 changes: 33 additions & 0 deletions ckanext/canada/tests/test_briefingt.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,36 @@ def test_blank(self):
err = ve.value.error_dict
assert 'key' in err
assert 'tracking_number' in err['key'][0]

class TestBriefingTNil(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(TestBriefingTNil, self).setup_method(method)

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

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

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


def test_example(self):
record = get_chromo('briefingt-nil')['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
assert 'year, month' in err['key'][0]
Loading