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

Upgrade for CKAN 2.11 #13

Merged
merged 24 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
19 changes: 10 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: Tests
on: [pull_request]
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
container:
# 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
Expand All @@ -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: |
Expand All @@ -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
4 changes: 2 additions & 2 deletions ckanext/dataset_subscriptions/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ckanext/dataset_subscriptions/assets/css/intlTelInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
86 changes: 14 additions & 72 deletions ckanext/dataset_subscriptions/templates/user/edit_user_form.html
Original file line number Diff line number Diff line change
@@ -1,73 +1,15 @@
{% import 'macros/form.html' as form %}

{% asset "ckanext-dataset-subscriptions/user-edit-js" %}
{% asset "ckanext-dataset-subscriptions/user-edit-css" %}

<form id="user-edit-form" class="dataset-form" method="post" action="{{ action }}" onsubmit="process(event)" enctype="multipart/form-data">
{{ form.errors(error_summary) }}

<fieldset>
<legend>{{ _('Change details') }}</legend>
{{ form.input('name', label=_('Username'), id='field-username', value=data.name, error=errors.name, classes=['control-medium'], attrs={'readonly': '', 'class': 'form-control'}) }}

{{ form.input('fullname', label=_('Full name'), id='field-fullname', value=data.fullname, error=errors.fullname, placeholder=_('eg. Joe Bloggs'), classes=['control-medium']) }}

{{ form.input('email', label=_('Email'), id='field-email', type='email', value=data.email, error=errors.email, placeholder=_('eg. [email protected]'), classes=['control-medium'], is_required=true) }}

{{ form.markdown('about', label=_('About'), id='field-about', value=data.about, error=errors.about, placeholder=_('A little information about yourself')) }}

{% if show_email_notifications %}
{% call form.checkbox('activity_streams_email_notifications', label=_('Subscribe to notification emails'), id='field-activity-streams-email-notifications', value=True, checked=g.userobj.activity_streams_email_notifications) %}
{% set helper_text = _("You will receive notification emails from {site_title}, e.g. when you have new activities on your dashboard."|string) %}
{{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }}
{% endcall %}
{% endif %}
<div class="alert phonenumber alert-error" style="display: none"></div>
{{ 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 sms notification'), id='field-activity-streams-sms-notifications', value=True, checked=data.activity_streams_sms_notifications) %}
{% set helper_text = _("You will receive sms notification from {site_title}, e.g. when you have new activities on your dashboard."|string) %}
{{ form.info(helper_text.format(site_title=g.site_title), classes=['info-help-tight']) }}
{% endcall %}

{% set is_upload = data.image_url and not data.image_url.startswith('http') %}
{% set is_url = data.image_url and data.image_url.startswith('http') %}

{{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload, upload_label=_('Profile picture'), url_label=_('Profile picture URL') ) }}

</fieldset>

<fieldset>
<legend>{{ _('Change password') }}</legend>
{{ form.input('old_password',
type='password',
label=_('Sysadmin Password') if is_sysadmin else _('Old Password'),
id='field-password-old',
value=data.oldpassword,
error=errors.oldpassword,
classes=['control-medium'],
attrs={'autocomplete': 'off', 'class': 'form-control'}
) }}

{{ form.input('password1', type='password', label=_('Password'), id='field-password', value=data.password1, error=errors.password1, classes=['control-medium'], attrs={'autocomplete': 'off', 'class': 'form-control'} ) }}

{{ form.input('password2', type='password', label=_('Confirm Password'), id='field-password-confirm', value=data.password2, error=errors.password2, classes=['control-medium'], attrs={'autocomplete': 'off', 'class': 'form-control'}) }}
</fieldset>

<div class="form-actions">
{% block delete_button %}
{% if h.check_access('user_delete', {'id': data.id}) %}
<a class="btn btn-danger pull-left" href="{% url_for 'user_delete', id=data.id %}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to delete this User?') }}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{% block generate_button %}
{% if h.check_access('user_generate_apikey', {'id': data.id}) %}
<a class="btn btn-warning" href="{% url_for 'user.generate_apikey', id=data.id %}" data-module="confirm-action" data-module-content="{{ _('Are you sure you want to regenerate the API key?') }}">{% block generate_button_text %}{{ _('Regenerate API Key') }}{% endblock %}</a>
{% endif %}
{% endblock %}
{{ form.required_message() }}
<button class="btn btn-primary" type="submit" name="save">{{ _('Update Profile') }}</button>
</div>
</form>

{% 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" %}
<div class="alert phonenumber alert-error" style="display: none"></div>
{{ 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 %}

6 changes: 6 additions & 0 deletions ckanext/dataset_subscriptions/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest

@pytest.fixture()
def clean_db(reset_db, migrate_db_for):
reset_db()
migrate_db_for("activity")
4 changes: 1 addition & 3 deletions ckanext/dataset_subscriptions/tests/test_actions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pytest-ckan
pytest-factoryboy
pytest-cov
2 changes: 1 addition & 1 deletion test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down