ckanext-ontario_theme
Theme for Ontario ckan including:
- metadata schema
- forms
- templates and design
- validation for CSV resources
Requirements
Related projects, repositories, branches and CKAN plugins:
| Project |
Repository |
Branch |
Plugin |
| CKAN |
ckan/ckan |
ckan-2.9.x |
N/A |
| Scheming extension |
open-data/ckanext-scheming |
master |
scheming_datasets |
| Fluent extension |
open-data/ckanext-fluent |
master |
fluent |
| Validation extension |
fork of frictionlessdata/ckanext-validation |
develop |
validation |
Directory Structure
Four directories compose this repository:
- scripts: contains scripts to setup CKAN and required applications
- config: contains configuration files needed for installation and configuration of CKAN
- ckanext: Ontario Theme Extension files for CKAN
- bin: contains CI scripts that are no longer being used
Plugins in this Extension:
ontario_theme base and internal-facing Ontario data catalogue
ontario_theme_external customizations for external facing Ontario data catalogue (requires ontario_theme)
Installation
To install ckanext-ontario_theme for development, activate your CKAN virtualenv and do:
git clone https://github.com/ongov/ckanext-ontario_theme.git
cd ckanext-ontario_theme
python setup.py develop
pip install -r dev-requirements.txt
Update the development.ini (or production.ini) plugins:
# This relies on scheming and fluent, make sure these are already installed.
# Note: This extension needs to be before scheming and fluent in the *.ini
# config file to let the form overrides work.
# For external catalogue
ckan.plugins = [...] ontario_theme_external ontario_theme scheming_datasets scheming_organizations scheming_groups fluent [...]
Add licenses:
licenses_group_url = file:///<path to this extension>/ckanext/ontario_theme/schemas/licences.json
Setup for CKAN tracking (https://docs.ckan.org/en/2.9/maintaining/tracking.html). The config setting is in the plugin.py already.
Create a sysadmin user, login and set the HomePage layout under Admin -> Config to the third option. Our homepage uses this layout as its base.
ckanext-validation Integration
This code contains a redesign of the workflow for adding and editing resources where users are guided by a four-step wizard process.
Step 1:
CSV files selected for upload are checked for header and table property errors by the ckanext-validation extension. Only files that pass all checks are pushed to datastore.
Step 2:
Intermediate step: the user is notified that the validation was successful while XLoader asynchronously pushes the CSV file to the database.
Step 3:
Data Dictionary: the default CKAN data dictionary form is displayed to allow data type definitions. The validation plugin checks against the data types saved in the form.
Step 4:
Successful data type validation leads to the final page in the workflow where the user can review the metadata and data dictionary info and either link back to make changes or publish as is.
Development
Follow the CKAN style rules (http://docs.ckan.org/en/latest/contributing/css.html#formatting).
Installing dev-tools and pre-commit hooks for development
Activate your CKAN virtualenv and run:
pip install -r dev-requirements.txt
pre-commit install
We use the djLint pre-commit hook to lint our code.
Translations
Current Process:
- We currently do them manually
- We edit the .pot and .po files manually for new and modified strings
- The .mo file is generated at deployment on the server with python setup.py compile_catalog
Running the Tests
To run the tests, make sure your ckan install is setup for tests, do:
cd ckanext-ontario_theme
pytest --ckan-ini=test.ini ckanext/ontario_theme/tests/
To run the tests and produce a coverage report:
coverage run -m pytest --ckan-ini=test.ini ckanext/ontario_theme/tests/
coverage html