ongov / ckanext-ontario_theme

Theme for Ontario's CKAN based data catalogues.
https://data.ontario.ca
GNU Affero General Public License v3.0
7 stars 12 forks source link

============= ckanext-ontario_theme

Theme for Ontario ckan including:


Directory Structure

Four directories compose this repository


Requirements

.. list-table:: Related projects, repositories, branches and CKAN plugins :header-rows: 1

(The harvest extension might not run without adding the following command "sudo mkdir -p /var/log/ckan/std")


Plugins in this Extension


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

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 [...]

# For internal catalogue
ckan.plugins = [...] ontario_data_catalogue_harvester ontario_theme harvest scheming_datasets scheming_organizations scheming_groups fluent [...]

# For both, 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 it's base.


Harvesters

ontario_data_catalogue_harvester - only for use on the internal catalogue. add the plugin in the ini file and restart the server. visit /harvest and add a harvester for the url https://data.ontario.ca


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.

To format staged code manually, run the following in your CKAN virtualenv: :: pre-commit run --hook-stage manual format

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Adding ODC recommended settings to your vscode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For our CSS formatting, we are using the vscode CSS formatter.

  1. Create file settings.json in the .vscode folder
  2. Copy contents of settings.json.default into the settings.json file. Save.

We have recommendations for vscode extensions in the extensions.json file of the .vscode folder. On start up, a pop up will appear asking if you would like to install the extensions. The extensions are to make development easier within this repo, they are: ::

  1. Better Jinja, syntax highlighting for Jinja2
  2. Flake8, Python linter
  3. GitLens
  4. Diff, diff comparison
  5. NGINX Configuration Language Support

Translations

Current Process:

Initial Creation:

Additional Info:


Running the Tests

To run the tests, make sure your ckan install is setup for tests <https://docs.ckan.org/en/latest/contributing/test.html>_, do::

cd ckanext-ontario_theme # go to extension directory
pytest --ckan-ini=test.ini ckanext/ontario_theme/tests/

To run the tests and produce a coverage report, first make sure you have coverage installed in your virtualenv (pip install coverage) then run::

coverage run -m pytest --ckan-ini=test.ini ckanext/ontario_theme/tests/

You can then run::

coverage html

or::

coverage report

You can then find the coverage reports in a generated htmlcov folder.

Our custom config settings are in ./test.ini.

Running a single test:

Single Test class::

coverage run -m pytest --ckan-ini=test.ini ckanext/ontario_theme/tests/test_create_dataset.py::test_package_create_with_invalid_update_frequency 

Single Test module::

coverage run -m pytest --ckan-ini=test.ini ckanext/ontario_theme/tests/test_create_dataset.py