diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cab7906..8e1f5d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ name: Tests -on: [pull_request] +on: [push, pull_request] jobs: test: runs-on: ubuntu-latest @@ -7,12 +7,13 @@ jobs: # The CKAN version tag of the Solr and Postgres containers should match # the one of the container the tests run on. # You can switch this base image with a custom image tailored to your project - image: openknowledge/ckan-dev:2.9 + image: ckan/ckan-base:2.11-py3.10 + options: --user root services: solr: - image: ckan/ckan-solr-dev:2.9 + image: ckan/ckan-solr:2.11-solr9 postgres: - image: ckan/ckan-postgres-dev:2.9 + image: ckan/ckan-postgres-dev:2.11 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres @@ -29,7 +30,7 @@ jobs: CKAN_REDIS_URL: redis://redis:6379/1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install requirements # Install any extra requirements your extension has here (dev requirements, other extensions etc) run: | @@ -41,8 +42,8 @@ jobs: run: | # 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/' test.ini - - ckan -c test.ini db init + echo "Initialising DB" + ckan -c test.ini db init - name: Run tests - run: pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions - + run: | + pytest --ckan-ini=test.ini --cov=ckanext.dataset_subscriptions --disable-warnings ckanext/dataset_subscriptions \ No newline at end of file diff --git a/ckanext/dataset_subscriptions/actions/__init__.py b/ckanext/dataset_subscriptions/actions/__init__.py index 553adf1..66d7167 100644 --- a/ckanext/dataset_subscriptions/actions/__init__.py +++ b/ckanext/dataset_subscriptions/actions/__init__.py @@ -1,8 +1,8 @@ import ckan.plugins.toolkit as toolkit import ckan.logic as logic -from ckan.lib.email_notifications import send_notification +from ckanext.activity.email_notifications import send_notification import ckanext.dataset_subscriptions.helpers as helpers -import ckan.lib.email_notifications as email_notifications +import ckanext.activity.email_notifications as email_notifications import ckan.model as model import ckan.lib.base as base from ckan.common import config diff --git a/ckanext/dataset_subscriptions/assets/css/intlTelInput.css b/ckanext/dataset_subscriptions/assets/css/intlTelInput.css index f00a0ba..f39165e 100644 --- a/ckanext/dataset_subscriptions/assets/css/intlTelInput.css +++ b/ckanext/dataset_subscriptions/assets/css/intlTelInput.css @@ -77,7 +77,7 @@ .iti__flag-box, .iti__country-name { margin-right: 6px; } .iti--allow-dropdown input, .iti--allow-dropdown input[type=text], .iti--allow-dropdown input[type=tel], .iti--separate-dial-code input, .iti--separate-dial-code input[type=text], .iti--separate-dial-code input[type=tel] { - padding-right: 6px; + padding-right: 13px; padding-left: 52px; margin-left: 0; } .iti--allow-dropdown .iti__flag-container, .iti--separate-dial-code .iti__flag-container { diff --git a/ckanext/dataset_subscriptions/templates/user/edit_user_form.html b/ckanext/dataset_subscriptions/templates/user/edit_user_form.html index 7f8f9be..c635b94 100644 --- a/ckanext/dataset_subscriptions/templates/user/edit_user_form.html +++ b/ckanext/dataset_subscriptions/templates/user/edit_user_form.html @@ -1,73 +1,15 @@ -{% import 'macros/form.html' as form %} - -{% asset "ckanext-dataset-subscriptions/user-edit-js" %} -{% asset "ckanext-dataset-subscriptions/user-edit-css" %} - -
- -{% asset "ckanext-dataset-subscriptions/phone-number-js" %} +{% ckan_extends %} + +{% block extra_fields %} + {% asset "ckanext-dataset-subscriptions/user-edit-js" %} + {% asset "ckanext-dataset-subscriptions/user-edit-css" %} + + {{ form.input('phonenumber', label=_('Phone number'), id='field-phonenumber', type='tel', value=data.phonenumber, error=errors.phonenumber, placeholder=_('eg. +44 123123123'), classes=['control-medium'], is_required=false) }} + {% call form.checkbox('activity_streams_sms_notifications', label=_('Subscribe to notification SMS text messages'), id='field-activity-streams-sms-notifications', value=True, checked=data.activity_streams_sms_notifications) %} + {% set helper_text = _("You will receive SMS notifications from {site_title} when you have new activities on your dashboard."|string) %} + {{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }} + {% endcall %} + {% asset "ckanext-dataset-subscriptions/phone-number-js" %} + {{ super() }} +{% endblock %} diff --git a/ckanext/dataset_subscriptions/tests/conftest.py b/ckanext/dataset_subscriptions/tests/conftest.py new file mode 100644 index 0000000..e64b7e3 --- /dev/null +++ b/ckanext/dataset_subscriptions/tests/conftest.py @@ -0,0 +1,6 @@ +import pytest + +@pytest.fixture() +def clean_db(reset_db, migrate_db_for): + reset_db() + migrate_db_for("activity") \ No newline at end of file diff --git a/ckanext/dataset_subscriptions/tests/test_actions.py b/ckanext/dataset_subscriptions/tests/test_actions.py index ae235b5..419d2d5 100644 --- a/ckanext/dataset_subscriptions/tests/test_actions.py +++ b/ckanext/dataset_subscriptions/tests/test_actions.py @@ -1,8 +1,6 @@ from ckan.tests import factories as ckan_factories from ckanext.dataset_subscriptions.tests import factories - -import ckan.lib.email_notifications as email_notifications -import ckanext.dataset_subscriptions.actions as actions +import ckanext.activity.email_notifications as email_notifications import ckan.tests.helpers as helpers import pytest import datetime diff --git a/dev-requirements.txt b/dev-requirements.txt index eac82b4..6aac721 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1 +1,3 @@ pytest-ckan +pytest-factoryboy +pytest-cov \ No newline at end of file diff --git a/test.ini b/test.ini index 347b508..8bc9b47 100644 --- a/test.ini +++ b/test.ini @@ -8,7 +8,7 @@ use = config:../ckan/test-core.ini # Insert any custom config settings to be used when running your extension's # tests here. These will override the one defined in CKAN core's test-core.ini -ckan.plugins = dataset_subscriptions +ckan.plugins = dataset_subscriptions activity ckanext.dataset_subscriptions.twilio_account_sid = dummy_sid ckanext.dataset_subscriptions.twilio_auth_token = dummy_token