Skip to content
Open
Show file tree
Hide file tree
Changes from 169 commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
346afe3
feat: Update solr schema and solrconfig
kovalch Jul 1, 2025
76d6647
feat: Modify setup file
kovalch Jul 1, 2025
115c039
feat: Update requirements for the python3
kovalch Jul 1, 2025
d542528
fix: Use Python’s built-in collections
kovalch Jul 1, 2025
2bfdb36
fix: Update tests settings
kovalch Jul 1, 2025
a5d6f0f
fix: Remove double deffinition of collections
kovalch Jul 1, 2025
66a436b
fix: Update render
kovalch Jul 1, 2025
c3a6a82
fix: Revrite get_activities
kovalch Jul 1, 2025
60e1aa5
fix: In Python 3 the quote function lives in urllib.parse
kovalch Jul 1, 2025
82f8005
fix: Update the import for urlparse
kovalch Jul 1, 2025
9ddd2fc
feat: Make imports python3 compartible
kovalch Jul 1, 2025
a1d5d45
feat: Require black and isort
bellisk Jul 2, 2025
db4f7e6
style: Run black on codebase
bellisk Jul 2, 2025
6947daf
style: Run isort
bellisk Jul 2, 2025
54645a1
feat: Run 2to3 to convert to Python 3 code
bellisk Jul 2, 2025
2abd245
style: Run black again
bellisk Jul 2, 2025
c06037e
style: Remove 'noqa' markers and run black again
bellisk Jul 2, 2025
312653e
style: Mark overly-complex code as noqa: C901 for now
bellisk Jul 2, 2025
1b84acc
style: Check for and fix a couple more types of errors
bellisk Jul 2, 2025
c1db86c
style: Convert string formatting to use f-strings
bellisk Jul 2, 2025
a20d3ec
style: Convert string concatenation to use f-strings
bellisk Jul 2, 2025
4d3516a
style: Convert static list joins to use f-strings
bellisk Jul 2, 2025
235ff77
style: Convert string formatting to use f-strings
bellisk Jul 2, 2025
878cef3
style: Run black
bellisk Jul 2, 2025
6659e53
style: Fix overly long lines created by flynt
bellisk Jul 2, 2025
676befe
Merge pull request #350 from opendata-swiss/feat/update-to-python-3-c…
kovalch Jul 3, 2025
0652380
style: Fix some typos
bellisk Jul 3, 2025
9ee6eb3
tests: Fix ckan version and solr tag
bellisk Jul 3, 2025
61de2e1
tests: Fix ckan container tag
bellisk Jul 3, 2025
139b0db
tests: Install test requirements as root
bellisk Jul 3, 2025
8d08612
tests: Fix syntax
bellisk Jul 3, 2025
d73ee89
tests: Create ckan container with user=root
bellisk Jul 3, 2025
827b57d
tests: Use most recent versions of all ckanexts
bellisk Jul 3, 2025
82ad1e3
tests: Update db init and migration commands
bellisk Jul 3, 2025
9a9903f
tests: Add debug statement
bellisk Jul 3, 2025
d8808ed
feat: Update team's email address
bellisk Jul 3, 2025
d0a89a8
tests: Add debug statement
bellisk Jul 3, 2025
6dae045
tests: Update ckan commands to put config in the right place
bellisk Jul 3, 2025
83a5832
tests: Escape % in test.ini
bellisk Jul 3, 2025
3c034fe
fix: Remove IRouter, The IRoutes interface has been removed since it …
kovalch Jul 4, 2025
31aa0f8
fix: Remove perma route from update_config, we have perma_redirect
kovalch Jul 4, 2025
f16cac6
fix: 'ckan.plugins' has no attribute 'IRoutes' it was added to the m…
kovalch Jul 7, 2025
c5422b0
feat: Use IPackageController delete method compartible with Ckan2.11
kovalch Jul 7, 2025
3b386c6
update: iribaker
bellisk Jul 7, 2025
cca33cc
fix: Update init file
kovalch Jul 7, 2025
2880c97
feat: Remove unneeded configure() method
bellisk Jul 8, 2025
0f3c65e
Merge branch 'upgrade_to_python3_ckan2_11' of https://github.com/open…
kovalch Jul 8, 2025
1cd8dbf
feat: Migrate assets from fanstatic to webassets
kovalch Jul 8, 2025
54baebb
fix: migrate to webassets
kovalch Jul 8, 2025
c99823f
fix: Add correct folder
kovalch Jul 8, 2025
c6198b7
fix: Use webassets.yml
kovalch Jul 8, 2025
5e4bf61
tests: Update github actions for testing
bellisk Jul 10, 2025
c4a3f40
style: Blacken
bellisk Jul 10, 2025
edd23ec
style: Remove unneeded encoding statements
bellisk Jul 10, 2025
00f4cc1
fix: Remove redefinition of imported constant
bellisk Jul 10, 2025
49745ef
Revert "fix: Revrite get_activities"
bellisk Jul 10, 2025
682a792
feat: Update templates for ckanext-showcase v1.8.3
bellisk Jul 10, 2025
309e19b
feat: Get activity model from ckanext-activity
bellisk Jul 10, 2025
53ca390
feat: Blacken
bellisk Jul 10, 2025
a8257ae
feat: Override template from CKAN core
bellisk Jul 10, 2025
e913c9b
feat: Translate titles of entities to delete
bellisk Jul 10, 2025
fe88ba2
chore: Remove unneeded template
bellisk Jul 10, 2025
bdac548
feat: Update template for CKAN 2.11
bellisk Jul 10, 2025
78a4672
fix: Fix output name
kovalch Jul 10, 2025
abfb7c1
fix: Update location for css and js webassets
kovalch Jul 10, 2025
b1d2311
feat: Update group templates for CKAN 2.11
bellisk Jul 10, 2025
79d230a
feat: Update stats template for CKAN 2.11
bellisk Jul 10, 2025
66b1208
fix: Update assets name
kovalch Jul 10, 2025
4c647e1
fix: Use names defined in webassets.yaml
kovalch Jul 10, 2025
4b6dbd0
feat: Update group templates for CKAN 2.11
bellisk Jul 10, 2025
86f18e0
feat: Override CKAN templates
bellisk Jul 10, 2025
dcd57e1
feat: Translate display name with scheming, use 'category' everywhere
bellisk Jul 10, 2025
05c5e82
feat: Override CKAN 2.11 template
bellisk Jul 10, 2025
1c1af93
feat: Refer to draft datasets, not private ones
bellisk Jul 10, 2025
73ba111
feat: Update routes for CKAN 2.11
bellisk Jul 10, 2025
1ca3ffc
feat: Update group template for CKAN 2.11
bellisk Jul 10, 2025
14dce0c
feat: Update home templates for CKAN 2.11
bellisk Jul 10, 2025
d2eae57
feat: Update organization templates for CKAN 2.11
bellisk Jul 10, 2025
4c77667
feat: Override CKAN core template
bellisk Jul 10, 2025
7feb7a7
feat: Refer to adding distributions to dataset, not resources
bellisk Jul 10, 2025
94be2e1
feat: Update package templates for CKAN 2.11
bellisk Jul 10, 2025
b630cbb
fix: Fix webassets
bellisk Jul 10, 2025
6355494
fix: Make index.html extend from core CKAN index.html
bellisk Jul 10, 2025
19cc46e
feat: Remove calls to c object, update routes for CKAN 2.11
bellisk Jul 10, 2025
ef06a02
style: Run isort
bellisk Jul 10, 2025
4f9507e
feat: Update front page templates for CKAN 2.11
bellisk Jul 10, 2025
2ab9b2b
feat: Update group templates to use group obj, not dict
bellisk Jul 10, 2025
c5e8a36
feat: Update harvest route
bellisk Jul 10, 2025
0cbc7b3
feat: Update search form reset-search button
bellisk Jul 10, 2025
3aa9568
feat: Override CKAN core template
bellisk Jul 10, 2025
e28c449
feat: Pass the group_dict to the search form on group page
bellisk Jul 10, 2025
e78742b
feat: Update routes for CKAN 2.11
bellisk Jul 10, 2025
e301361
feat: Update routes for CKAN 2.11
bellisk Jul 11, 2025
7e3484b
chore: Temporarily remove link to harvest dashboard in header
bellisk Jul 11, 2025
d7bb4bf
tests: Temporarily require update branch of ckanext-subscribe
bellisk Jul 11, 2025
d9383d7
feat: Override template from CKAN core so we can translate it
bellisk Jul 11, 2025
966d700
feat: Translate display name and description in org info
bellisk Jul 11, 2025
85baae1
feat: Override CKAN 2.11 template
bellisk Jul 11, 2025
0801198
feat: Display our breadcrumb snippet on org edit page
bellisk Jul 11, 2025
5fac174
feat: Update templates for CKAN 2.11
bellisk Jul 11, 2025
8656ed2
fix: Fix mixed-up group/group_dict references
bellisk Jul 11, 2025
a3d71dc
feat: Create blueprint for permalink
bellisk Jul 11, 2025
0b68d3b
tests: Start updating tests for CKAN 2.11
bellisk Jul 11, 2025
6d5c712
tests: Update tests (still WIP)
bellisk Jul 11, 2025
b956e93
fix: Temporarily remove xml-upload-button as the route is not working
bellisk Jul 22, 2025
2131d4e
feat: Update interface method names
bellisk Jul 22, 2025
0a3e510
feat: Update functions that talk to toolkit.request
bellisk Jul 22, 2025
077f0b5
fix: Convert empty dates to None for saving in Solr
bellisk Jul 22, 2025
2d09cac
fix: Fix function call
bellisk Jul 22, 2025
c208398
fix: Return redirect in perma blueprint
bellisk Jul 22, 2025
da5db33
tests: Clean index before tests and use ogdch_pkg plugin
bellisk Jul 22, 2025
82680e0
tests: Use 'correct' egg name for ckanext-dcatapchharvest
bellisk Jul 22, 2025
82619bd
feat: Update routes from other ckanexts
bellisk Jul 22, 2025
aae755d
tests: Update test
bellisk Jul 22, 2025
5fa74fa
feat: Update package templates for CKAN 2.11
bellisk Jul 23, 2025
6ba02c4
feat: Replace built-in unicode validator with validator_safe
bellisk Jul 23, 2025
49d308c
feat: Update templates for CKAN 2.11
bellisk Jul 23, 2025
8f3862a
chore: Remove no-longer-needed overwritten template
bellisk Jul 23, 2025
b7bc7a1
feat: Extend template from the one in ckanext-showcase
bellisk Jul 23, 2025
8dae57f
feat: Update templates for CKAN 2.11
bellisk Jul 23, 2025
a0e553e
feat: Convert xml_upload controller to blueprint
bellisk Jul 23, 2025
5016f0d
fix: Get get_action from toolkit, not ckan.logic
bellisk Jul 23, 2025
21ead8e
feat: Update template
bellisk Jul 23, 2025
fb145d5
feat: Use unicode_safe validator from CKAN, not built-in
bellisk Jul 23, 2025
6f8c9e0
feat: Override CKAN core group index blueprint
bellisk Jul 23, 2025
7b6a9ba
feat: Disable pagination for organization index page
bellisk Jul 23, 2025
fb621f5
fix: Fix imports
bellisk Jul 23, 2025
898a4d8
style: Run black on copied code
bellisk Jul 23, 2025
5f6bddd
feat: Add url rule to org blueprint for index
bellisk Jul 23, 2025
a4026e4
fix: Remove unneeded overridden block
bellisk Jul 23, 2025
d67515c
feat: Remove unneeded code from copied CKAN view func
bellisk Jul 23, 2025
288a7db
feat: Transform org list for user controller into blueprint
bellisk Jul 23, 2025
e2ac8cb
tests: Install ckanext-subscribe main branch for tests
bellisk Jul 24, 2025
c605100
fix: Make button default style instead of primary
bellisk Jul 24, 2025
e9cb4b2
fix: Don't pass in url_defaults, set variables in view func
bellisk Jul 24, 2025
41f9901
feat: Extend HierarchyDisplay plugin in our own plugin
bellisk Jul 28, 2025
cbcec72
feat: Only call custom search logic on an organization page
bellisk Jul 28, 2025
2f373a5
chore: Clean up unused interface implementations
bellisk Jul 28, 2025
686b617
chore: Remove now-unneeded OgdchOrganizationController
bellisk Jul 28, 2025
a8be1ee
style: Remove unused local variable
bellisk Jul 28, 2025
07fe7a3
chore: Remove unneeded OgdchGroupController
bellisk Jul 28, 2025
c6dfb5a
tests: Update tests
bellisk Jul 28, 2025
74e088e
tests: Update test_logic.py
bellisk Jul 28, 2025
9195267
tests: Update tests
bellisk Jul 29, 2025
c7a6803
fix: Remove doubled check
bellisk Jul 29, 2025
a2a2fe4
chore: Remove no-longer-needed fix
bellisk Jul 29, 2025
2172b5e
tests: Return extra_datasets in fixture
bellisk Jul 29, 2025
2ec18c7
tests: Add test for search with single specified field
bellisk Jul 29, 2025
553868d
feat: Update Solr schema to index description field
bellisk Jul 29, 2025
15d80e3
tests: Update subscribtion tests
bellisk Jul 29, 2025
e0360ce
feat: Add migration for ogdch_subscribe plugin
bellisk Jul 29, 2025
d31d9fb
tests: Update subscribtion tests
bellisk Jul 29, 2025
3d46057
fix: Update check for organization controller
bellisk Jul 30, 2025
a6be57a
tests: Get first test for email contents working
bellisk Jul 30, 2025
356a858
tests: Remove test for variable that's never used
bellisk Jul 30, 2025
25b0fd2
tests: Update the rest of the subscription email tests
bellisk Jul 30, 2025
b369f49
fix: Fix comment for function
bellisk Jul 30, 2025
3dac9fa
tests: Update tests for validators
bellisk Jul 30, 2025
80ebeb5
tests: Require updated branch of ckanext-dcatapchharvest
bellisk Jul 30, 2025
9999cb4
tests: Exclude tests/ folder from coverage checks
bellisk Jul 30, 2025
600d9f3
tests: Update test.yml for Github tests
bellisk Jul 30, 2025
8b9f2c6
tests: Update mock import
bellisk Jul 30, 2025
1a89c90
tests: Use Python 3, CKAN 2.11 branch of ckanext-password-policy
bellisk Jul 30, 2025
1714697
tests: Enable more plugins in test.ini
bellisk Jul 30, 2025
b9012b4
tests: Update used plugins and order of enabling them
bellisk Jul 30, 2025
d40ad7a
tests: Pass CKAN_SITE_URL env var into the ckan container
bellisk Jul 30, 2025
f697926
tests: Expect the right number of emails
bellisk Jul 30, 2025
ff6b473
tests: Set config value smtp.mail_from to our expected value
bellisk Jul 30, 2025
f45e795
tests: Fix Solr volume paths
bellisk Jul 30, 2025
d3f9d19
feat: Update Solr config to match the one in use
bellisk Aug 4, 2025
6273f9b
style: Only ignore 'too complex' flake8 error
bellisk Aug 4, 2025
b2f470d
feat: Catch KeyError when there is no current request
bellisk Aug 4, 2025
77990ff
Merge pull request #351 from opendata-swiss/fix/fix-solr-config-and-i…
bellisk Aug 5, 2025
63e23e4
feat: Handles missing keys safely
kovalch Aug 5, 2025
5cfe10b
Merge pull request #352 from opendata-swiss/fix_missing_lang
kovalch Aug 5, 2025
0d81667
test: Update requirements of ckanext-dcat
bellisk Aug 6, 2025
c485210
feat: Catch RuntimeError when creating a user in tests
bellisk Aug 6, 2025
528b75f
feat: Allow higher versions of dev requirements
bellisk Aug 6, 2025
af434c8
feat: Increase supported versions of Python
bellisk Aug 6, 2025
e5468c9
tests: Remove unneeded migration command
bellisk Aug 6, 2025
4882d92
refactor: use new route instead of deprecated search-route
stefina Aug 6, 2025
32b96d5
feat: re-add harvest-dashboard to header-navigation
stefina Aug 6, 2025
c0069a9
Merge pull request #354 from opendata-swiss/feat/add-harvest-dashboard
stefina Aug 6, 2025
8807000
Merge pull request #353 from opendata-swiss/feat/small-updates-for-ck…
bellisk Aug 6, 2025
08dc450
fix: Use global CKAN template context to see the logged-in user
kovalch Aug 7, 2025
ba404b2
fix: Use c object to get dataset_type
kovalch Aug 7, 2025
01319f0
feat: Use current_user to check sysadmin or authentication (flask-login)
bellisk Aug 12, 2025
48f6ed6
feat: Update POST forms to include CSRF input
bellisk Aug 12, 2025
190d030
fix: Fix html
bellisk Aug 12, 2025
e5e048d
fix: Remove unused imports
bellisk Aug 12, 2025
227cac8
feat: Use current_user instead of g.user
bellisk Aug 12, 2025
7f07946
feat: Use g instead of c, same as in ckan core
bellisk Aug 12, 2025
94e00fa
feat: Remove reference to c, same as in ckan core
bellisk Aug 12, 2025
8698878
feat: Add TODOs regarding the c object in templates
bellisk Aug 13, 2025
3e4e111
Merge pull request #355 from opendata-swiss/use_c_user
bellisk Aug 13, 2025
e35b616
feat: Declare config options in yaml file
bellisk Aug 13, 2025
175218f
chore: Remove obsolete helper function
bellisk Aug 13, 2025
5f85f51
fix: Yamlify default values
bellisk Aug 13, 2025
5fd78bf
fix: Only load config_declarations once, for OgdchPlugin
bellisk Aug 13, 2025
d6824e2
docs: Add comment to explain that the 'groups' don't do anything mean…
bellisk Aug 13, 2025
4326cc4
tests: Use CKAN 2.11 Python 3 branch of ckanext-harvester_dashboard
bellisk Aug 13, 2025
de4e02d
Merge pull request #356 from opendata-swiss/feat/declare-config-options
bellisk Aug 13, 2025
bf9d49c
feat: Add ignore_missing to the validators
kovalch Aug 21, 2025
a3256c0
feat: Add ignore_missing to the validator of license
kovalch Aug 21, 2025
a558fac
feat: Add ignore_missing validator before field validator
kovalch Aug 21, 2025
1ff0534
Merge pull request #358 from opendata-swiss/add_ignore_missing
kovalch Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
omit =
*/site-packages/*
*/python?.?/*
ckan/*
ckan/*
*/tests/*
49 changes: 26 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
container:
image: python:2.7.18-buster
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install requirements
run: pip install flake8 pycodestyle
run: pip install flake8 pycodestyle black isort
- name: Check syntax
run: flake8 --statistics --show-source --exclude ckanext/switzerland/tests,setup.py ckanext
run: flake8 . --count --select=C901,E721,E901,E999,F401,F821,F822,F823,F841 --show-source --statistics --extend-exclude ckan
- name: Check codestyle
run: |
isort --diff --check ckanext/
black --diff --check ckanext/

test:
needs: lint
strategy:
matrix:
ckan-version: [2.8]
ckan-version: ["2.11"]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
Expand All @@ -41,41 +44,41 @@ jobs:
CKAN_REDIS_URL: redis://redis:6379/1
CKAN_SITE_URL: http://test.ckan.net
WORKDIR: /__w/ckanext-switzerland-ng/ckanext-switzerland-ng
SOLR_CONFIG_CKAN_DIR: /opt/solr/server/solr/ckan/conf
SOLR_CONFIG_DIR: /opt/solr/server/solr/configsets
SOLR_CONFIG_CKAN_DIR: /opt/solr/server/solr/configsets/ckan/conf

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create solr container
run: |
docker create --name test_solr --network ${{ job.container.network }} --network-alias solr \
/usr/bin/docker create --name test_solr --network ${{ job.container.network }} --network-alias solr \
--workdir $WORKDIR --publish 8983:8983 \
-e SOLR_HEAP=1024m -e GITHUB_ACTIONS=true -e CI=true \
-v "${{ github.workspace }}/solr/schema.xml":"$SOLR_CONFIG_CKAN_DIR/schema.xml" \
-v "${{ github.workspace }}/solr/english_stop.txt":"$SOLR_CONFIG_CKAN_DIR/english_stop.txt" \
-v "${{ github.workspace }}/solr/fr_elision.txt":"$SOLR_CONFIG_CKAN_DIR/fr_elision.txt" \
-v "${{ github.workspace }}/solr/french_stop.txt":"$SOLR_CONFIG_CKAN_DIR/french_stop.txt" \
-e "SOLR_HEAP=1024m" -e "SOLR_SCHEMA_FILE=$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-e GITHUB_ACTIONS=true -e CI=true -v "${{ github.workspace }}/solr/schema.xml":"$SOLR_CONFIG_CKAN_DIR/managed-schema" \
-v "${{ github.workspace }}/solr/german_dictionary.txt":"$SOLR_CONFIG_CKAN_DIR/german_dictionary.txt" \
-v "${{ github.workspace }}/solr/german_stop.txt":"$SOLR_CONFIG_CKAN_DIR/german_stop.txt" \
-v "${{ github.workspace }}/solr/italian_stop.txt":"$SOLR_CONFIG_CKAN_DIR/italian_stop.txt" \
-v "${{ github.workspace }}/solr/solrconfig.xml":"$SOLR_CONFIG_CKAN_DIR/solrconfig.xml" \
ckan/ckan-solr:${{ matrix.ckan-version }}
-v "${{ github.workspace }}/solr/lang/fr_elision.txt":"$SOLR_CONFIG_DIR/ckan/lang/fr_elision.txt" \
-v "${{ github.workspace }}/solr/lang/stopwords_de.txt":"$SOLR_CONFIG_DIR/ckan/lang/stopwords_de.txt" \
-v "${{ github.workspace }}/solr/lang/stopwords_en.txt":"$SOLR_CONFIG_DIR/ckan/lang/stopwords_en.txt" \
-v "${{ github.workspace }}/solr/lang/stopwords_fr.txt":"$SOLR_CONFIG_DIR/ckan/lang/stopwords_fr.txt" \
-v "${{ github.workspace }}/solr/lang/stopwords_it.txt":"$SOLR_CONFIG_DIR/ckan/lang/stopwords_it.txt" \
ckan/ckan-solr:${{ matrix.ckan-version }}-solr9
docker start test_solr
- name: Create ckan container
run: |
docker create --name test_ckan --network ${{ job.container.network }} --network-alias ckan \
-e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -e CKAN_SITE_URL=http://test.ckan.net \
/usr/bin/docker create --name test_ckan --network ${{ job.container.network }} --network-alias ckan \
-e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -e CKAN_SITE_URL=http://test.ckan.net --user root \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-v "/home/runner/work":"/__w" -v "/home/runner/work/_temp":"/__w/_temp" \
-v "/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" \
-v "/home/runner/work/_temp/_github_home":"/github/home" \
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
--entrypoint "tail" openknowledge/ckan-dev:${{ matrix.ckan-version }} "-f" "/dev/null"
--entrypoint "tail" ckan/ckan-dev:${{ matrix.ckan-version }} "-f" "/dev/null"
docker start test_ckan
- name: Install requirements and set up database
run: |
docker exec test_ckan $WORKDIR/bin/install_test_requirements.sh ${{ matrix.ckan-version }}
- name: Run tests
run: |
docker exec test_ckan nosetests --ckan --with-pylons=$WORKDIR/test.ini \
--with-coverage --cover-package=ckanext.switzerland --cover-inclusive --cover-erase --cover-tests \
$WORKDIR/ckanext/switzerland
docker exec test_ckan pytest --ckan-ini=$WORKDIR/test.ini --cov=ckanext.switzerland \
--cov-config=$WORKDIR/.coveragerc --disable-warnings $WORKDIR/ckanext/switzerland/tests
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile = black
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.rst
recursive-include ckanext/switzerland *.html *.json *.js *.less *.css
recursive-include ckanext/switzerland *.html *.json *.js *.less *.css *.yml
recursive-include ckanext/switzerland/migration *.ini *.py *.mako
43 changes: 15 additions & 28 deletions bin/install_test_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,33 @@ echo "Install ckanext dependencies"
pip install -e git+https://github.com/ckan/ckanext-scheming.git#egg=ckanext-scheming
pip install -e git+https://github.com/ckan/ckanext-fluent.git#egg=ckanext-fluent
pip install -e git+https://github.com/ckan/ckanext-hierarchy.git#egg=ckanext-hierarchy

# Last commit before support for Python 2 was dropped
pip install -e git+https://github.com/ckan/ckanext-harvest.git@v1.4.2#egg=ckanext-harvest
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/v1.4.2/requirements.txt

# Last commit before support for Python 2 was dropped
pip install -e git+https://github.com/ckan/ckanext-dcat.git@0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6#egg=ckanext-dcat
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/0c26bed5b7a3a7fca8e7b78e338aace096e0ebf6/requirements-py2.txt

# Last commit before support for Python 2 was dropped
pip install -e git+https://github.com/ckan/ckanext-showcase.git@v1.5.2#egg=ckanext-showcase

# Last commit before support for Python 2 was dropped
pip install -e git+https://github.com/ckan/ckanext-xloader.git@16b84175005435d579607638dfe2056dda61af70#egg=ckanext-xloader
pip install -r https://raw.githubusercontent.com/ckan/ckanext-xloader/16b84175005435d579607638dfe2056dda61af70/requirements.txt
pip install -e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest
pip install -r https://raw.githubusercontent.com/ckan/ckanext-harvest/master/requirements.txt
pip install -e git+https://github.com/ckan/ckanext-dcat.git#egg=ckanext-dcat
pip install -r https://raw.githubusercontent.com/ckan/ckanext-dcat/master/requirements-py2.txt
pip install -e git+https://github.com/ckan/ckanext-showcase.git#egg=ckanext-showcase
pip install -e git+https://github.com/ckan/ckanext-xloader.git#egg=ckanext-xloader
pip install -r https://raw.githubusercontent.com/ckan/ckanext-xloader/master/requirements.txt

# Our ckanexts
pip install -e git+https://github.com/opendata-swiss/ckanext-dcatapchharvest.git#egg=ckanext-dcatapchharvest
pip install -r https://raw.githubusercontent.com/opendata-swiss/ckanext-dcatapchharvest/master/requirements.txt
# TODO: require main branch of all of these once they are updated to Python 3 and CKAN 2.11
pip install -e git+https://github.com/opendata-swiss/ckanext-dcatapchharvest.git@feat/upgrade_to_py3#egg=ckanext-dcatapchharvest
pip install -r https://raw.githubusercontent.com/opendata-swiss/ckanext-dcatapchharvest/feat/upgrade_to_py3/requirements.txt
pip install -e git+https://github.com/opendata-swiss/ckanext-harvester_dashboard.git#egg=ckanext-harvester_dashboard
pip install -r https://raw.githubusercontent.com/opendata-swiss/ckanext-harvester_dashboard/master/requirements.txt
pip install -e git+https://github.com/bellisk/ckanext-subscribe.git#egg=ckanext-subscribe
pip install -r https://raw.githubusercontent.com/bellisk/ckanext-subscribe/master/requirements.txt
pip install -e git+https://github.com/opendata-swiss/ckanext-password-policy.git#egg=ckanext-password-policy
pip install -r https://raw.githubusercontent.com/opendata-swiss/ckanext-password-policy/master/requirements.txt
pip install -e git+https://github.com/opendata-swiss/ckanext-password-policy.git@feat/upgrade_to_py3#egg=ckanext-password-policy
pip install -r https://raw.githubusercontent.com/opendata-swiss/ckanext-password-policy/feat/upgrade_to_py3/requirements.txt

echo "Replace default path to CKAN core config file with the one on the container"
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' "$WORKDIR"/test.ini

echo "Replace default database url with the one for the postgres service"
sed -i -e 's/sqlalchemy.url = .*/sqlalchemy.url = postgresql:\/\/ckan_default:pass@postgres\/ckan_test/' "$WORKDIR"/test.ini

echo "Remove plugins from CKAN config"
paster --plugin=ckan config-tool "$WORKDIR"/test.ini "ckan.plugins = "

echo "Init db"
paster --plugin=ckan db init -c "$WORKDIR"/test.ini

echo "Init harvester db"
paster --plugin=ckanext-harvest harvester initdb -c "$WORKDIR"/test.ini
ckan -c "$WORKDIR"/test.ini db init

echo "Re-enable plugins in CKAN config"
paster --plugin=ckan config-tool "$WORKDIR"/test.ini "ckan.plugins = ogdch ogdch_pkg ogdch_res ogdch_group ogdch_org ogdch_showcase ogdch_subscribe ogdch_middleware ogdch_dcat scheming_datasets scheming_groups scheming_organizations fluent hierarchy_display harvester_dashboard"
echo "Apply pending migrations"
ckan -c "$WORKDIR"/test.ini db pending-migrations --apply
2 changes: 2 additions & 0 deletions ckanext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# this is a namespace package
try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
43 changes: 43 additions & 0 deletions ckanext/switzerland/assets/css/ogdch_stats_box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.homepage .module-stats {
/*margin-top: 1rem;*/
color: #444;
}
.homepage .module-stats .card {
padding: 1.5rem 1.75rem;
}
.homepage .module-stats .card ul {
margin: 0;
list-style: none;
padding: 0;
}
.homepage .module-stats .card ul::after {
display: block;
clear: both;
content: "";
}
.homepage .module-stats .card ul li {
float: left;
width: 25%;
font-weight: 300;
}
.homepage .module-stats .card ul li a {
display: block;
}
.homepage .module-stats .card ul li a strong {
font-size: 0.875rem;
line-height: 1.5;
font-weight: bold;
}
.homepage .module-stats .card ul li a:hover {
text-decoration: none;
}
.homepage .module-feeds .module-stats {
margin-top: 0;
}

@media (max-width: 767.98px) {
.homepage .module-stats {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
}
21 changes: 21 additions & 0 deletions ckanext/switzerland/assets/webassets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
switzerland-css:
output: switzerland/switzerland.css
contents:
- css/ogdch_file_upload.css
- css/ogdch_form_helper.css
- css/ogdch_organization_filter.css
- css/ogdch_stats_box.css
- vendor/bootstrap-datepicker/css/bootstrap-datepicker.css

switzerland-js:
output: switzerland/switzerland.js
contents:
- js/ogdch_file_upload.js
- js/ogdch_form_helper_contact_points.js
- js/ogdch_info_box.js
- js/ogdch_form_helper_relations.js
- js/ogdch_form_helper_qualified_relations.js
- js/ogdch_form_helper_temporals.js
- js/ogdch_datepicker.js
- js/ogdch_organization_filter.js
- vendor/bootstrap-datepicker/js/bootstrap-datepicker.js
114 changes: 114 additions & 0 deletions ckanext/switzerland/blueprints/organization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import logging
from typing import Any

import ckan.lib.base as base
import ckan.logic as logic
from ckan.common import _, current_user, request
from ckan.lib.helpers import Page
from ckan.lib.helpers import helper_functions as h
from ckan.plugins.toolkit import get_action, redirect_to, request
from ckan.types import Context
from ckan.views.group import _get_group_template
from flask import Blueprint

log = logging.getLogger(__name__)

ValidationError = logic.ValidationError
NotFound = logic.NotFound
NotAuthorized = logic.NotAuthorized
check_access = logic.check_access

org = Blueprint(
"ogdch_organization",
__name__,
url_prefix="/organization",
)


def xml_upload(name):
org = get_action("organization_show")({}, {"id": name})

if request.files.get("file_upload") != "":
data_dict = {
"data": dict(request.files),
"organization": org["id"],
}
get_action("ogdch_xml_upload")({}, data_dict)
else:
h.flash_error("Error uploading file: no data received.")

return redirect_to("organization.read", id=name)


def index() -> str:
"""Copied from ckan.views.group.index to remove pagination on the organization
index page, as it doesn't work well with the ckanext-hierarchy display.
"""
extra_vars: dict[str, Any] = {}
page = h.get_page_number(request.args) or 1
group_type = "organization"
is_organization = True

context: Context = {
"user": current_user.name,
"for_view": True,
"with_private": False,
}

try:
action_name = "organization_list" if is_organization else "group_list"
check_access(action_name, context)
except NotAuthorized:
base.abort(403, _("Not authorized to see this page"))

q = request.args.get("q", "")
sort_by = request.args.get("sort")

extra_vars["q"] = q
extra_vars["sort_by_selected"] = sort_by

# pass user info to context as needed to view private datasets of
# orgs correctly
if current_user.is_authenticated:
context["user_id"] = current_user.id
context["user_is_admin"] = current_user.sysadmin # type: ignore

try:
data_dict_global_results: dict[str, Any] = {
"all_fields": True,
"q": q,
"sort": sort_by,
"type": group_type or "group",
"include_dataset_count": True,
"include_member_count": True,
"include_extras": True,
}

action_name = "organization_list" if is_organization else "group_list"
global_results = get_action(action_name)(context, data_dict_global_results)
except ValidationError as e:
if e.error_dict and e.error_dict.get("message"):
msg: Any = e.error_dict["message"]
else:
msg = str(e)
h.flash_error(msg)
extra_vars["page"] = Page([], 0)
extra_vars["group_type"] = group_type
return base.render(
_get_group_template("index_template", group_type), extra_vars
)

extra_vars["page"] = Page(
collection=global_results,
page=page,
url=h.pager_url,
items_per_page=len(global_results),
)

extra_vars["page"].items = global_results
extra_vars["group_type"] = group_type
return base.render(_get_group_template("index_template", group_type), extra_vars)


org.add_url_rule("/xml_upload/<name>", view_func=xml_upload, methods=["POST"])
org.add_url_rule("/", view_func=index, strict_slashes=False)
29 changes: 29 additions & 0 deletions ckanext/switzerland/blueprints/perma.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging

import ckan.logic as logic
from ckan.plugins.toolkit import _, abort, get_action, redirect_to
from flask import Blueprint

log = logging.getLogger(__name__)

NotFound = logic.NotFound

perma = Blueprint("perma", __name__, url_prefix="/perma")


def read(id):
"""
This action redirects requests to /perma/{identifier} to
the corresponding /dataset/{slug} route
"""
try:
dataset = get_action("ogdch_dataset_by_identifier")(
{"for_view": True}, {"identifier": id}
)
# redirect to dataset detail page
return redirect_to("dataset.read", id=dataset["name"])
except NotFound:
abort(404, _("Dataset not found"))


perma.add_url_rule("/<id>", view_func=read)
Loading
Loading