Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
855c823
tests: fix github test runner
alycejenni Aug 15, 2024
1d1ae01
merge: #52 from ginger/docker-compose-cmd
alycejenni Aug 15, 2024
db35011
merge: PR #53 from dev
alycejenni Aug 20, 2024
15f7038
bump: version 2.4.0 → 2.4.1
github-actions[bot] Aug 20, 2024
96d8ee4
ci: update workflow files
alycejenni Oct 29, 2024
b8f2a76
ci: add pull request validation workflow
alycejenni Oct 29, 2024
c5fba8c
ci: update tool config
alycejenni Oct 29, 2024
6e48eea
chore: update tool details in contributing guide
alycejenni Oct 29, 2024
f8e62a2
chore: add pull request template
alycejenni Oct 29, 2024
4c5d371
build: remove version from docker compose file
alycejenni Oct 29, 2024
e838e5a
ci: only apply auto-fixes in pre-commit
alycejenni Oct 30, 2024
4abe80b
ci: add docformatter args and dependency
alycejenni Oct 30, 2024
cb07fb4
style: automatic reformat
alycejenni Oct 30, 2024
7d7d4fd
docs: standardise returns field
alycejenni Oct 31, 2024
a7b934a
merge: #54 from ginger/standardise
alycejenni Oct 31, 2024
b0b5d9b
ci: add merge to valid commit types
alycejenni Nov 4, 2024
44658e9
merge: #56 from ginger/merge-commit-type
alycejenni Nov 4, 2024
5b8c5d9
ci: fix python setup action version
alycejenni Nov 4, 2024
f29d8cd
merge: #57 from ginger/python-setup-version
alycejenni Nov 4, 2024
a1d2883
merge: #55 from dev
alycejenni Nov 4, 2024
178cda4
bump: version 2.4.1 → 2.4.2
github-actions[bot] Nov 4, 2024
f5a4e0a
docs: fix tests badge
alycejenni Nov 4, 2024
d9e65bc
docs: use variable logo based on colour scheme
alycejenni Nov 4, 2024
cb7cce3
merge: #58 from ginger/readme
alycejenni Nov 4, 2024
b247324
merge: #59 from patch
alycejenni Nov 4, 2024
4ead67b
bump: version 2.4.2 → 2.4.3
github-actions[bot] Nov 4, 2024
048fde6
ci: update pre-commit repo versions
alycejenni Jun 5, 2025
52f87ed
build: update ckantools
alycejenni Jun 5, 2025
95a4f50
build: remove pylint, add ruff lint ignore rules
alycejenni Jun 5, 2025
4a7d7ec
build: add ruff lint select rules
alycejenni Jun 5, 2025
1102b4f
ci: set ruff target py version, add more ignores
alycejenni Jun 6, 2025
febbeaa
merge: #61 from ginger/standardisation
alycejenni Jun 6, 2025
443c48f
merge: PR #62 from dev
alycejenni Jun 9, 2025
8b359f7
bump: version 2.4.3 → 2.4.4
github-actions[bot] Jun 9, 2025
835a0a7
merge: commit '8b359f79322856087b42d13f6ff37d39abbd28a3' into HEAD
peterVorman Aug 13, 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
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [ ] I have read the [section on commits and pull requests](https://github.com/NaturalHistoryMuseum/ckanext-contact/blob/main/CONTRIBUTING.md#commits-and-pull-requests) in `CONTRIBUTING.md`


Describe your changes, tagging relevant issues where possible.
8 changes: 4 additions & 4 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:

jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
name: Bump version and create changelog
runs-on: ubuntu-latest
name: "Bump version and create changelog"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
steps:
- name: Check out
uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Validate pull requests

on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
validate-commits:
name: Validate commit messages
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Check commit message format
uses: webiny/action-conventional-commits@v1.3.0
with:
allowed-commit-types: 'bump,feat,fix,refactor,perf,docs,style,test,tests,build,ci,chore,new,patch,revert,ui,merge'
pre-commit:
name: Run pre-commit checks
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
9 changes: 4 additions & 5 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ permissions:

jobs:
deploy:
name: Deploy package to PyPI
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
uses: actions/setup-python@v5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:

jobs:
sync-branches:
name: Sync dev and patch branches to latest commit
runs-on: ubuntu-latest
name: "Sync dev and patch branches to latest commit"
steps:
- name: Check out
uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ name: Tests
on:
push:
workflow_dispatch:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
test:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v3

uses: actions/checkout@v4
- name: Build images
run: docker-compose build

run: docker compose build
- name: Run tests
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: docker-compose run -e COVERALLS_REPO_TOKEN ckan bash /opt/scripts/run-tests.sh -c ckanext.contact
run: docker compose run -e COVERALLS_REPO_TOKEN ckan bash /opt/scripts/run-tests.sh -c ckanext.contact
25 changes: 13 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
exclude: /(vendor|dist)/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: detect-private-key
- id: end-of-file-fixer
- id: name-tests-test
args: ["--pytest-test-first"]
args: ['--pytest-test-first']
exclude: ^tests/helpers/
- id: trailing-whitespace
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.37.0
rev: v4.8.2
hooks:
- id: commitizen
additional_dependencies: ["cz-nhm"]
- repo: https://github.com/psf/black
rev: 22.10.0
additional_dependencies: ['cz-nhm']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.12
hooks:
- id: black
- id: ruff
args: [ '--fix', '--select', 'I', '--select', 'F401', '--fix-only' ]
- id: ruff-format
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.0
rev: v1.7.7
hooks:
- id: docformatter
# these can't be pulled directly from the config atm, not sure why
args: ["-i", "--wrap-summaries=88", "--wrap-descriptions=88",
"--pre-summary-newline", "--make-summary-multi-line"]
args: [ '-i', '--config', './pyproject.toml' ]
additional_dependencies: ['tomli']
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [ javascript, vue, less, sass, scss, css ]
Expand Down
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Changelog

## v2.4.4 (2025-06-09)

### Build System(s)

- add ruff lint select rules Ignore does not work without select.
- remove pylint, add ruff lint ignore rules
- update ckantools

### CI System(s)

- set ruff target py version, add more ignores - avoid using fixes that don't work for python 3.8 (our current version) - ignore recommended ruff formatter conflicts - ignore more docstring rules
- update pre-commit repo versions

## v2.4.3 (2024-11-04)

### Docs

- use variable logo based on colour scheme
- fix tests badge tests workflow file was renamed

## v2.4.2 (2024-11-04)

### Docs

- standardise returns field

### Style

- automatic reformat auto reformat with ruff/docformatter/prettier after config changes

### Build System(s)

- remove version from docker compose file version specifier is deprecated

### CI System(s)

- fix python setup action version
- add merge to valid commit types
- add docformatter args and dependency docformatter currently can't read from pyproject.toml without tomli
- only apply auto-fixes in pre-commit F401 returns linting errors as well as auto-fixes, so this disables the errors and just applies the fixes
- update tool config update pre-commit repo versions and switch black to ruff
- add pull request validation workflow new workflow to check commit format and code style against pre-commit config
- update workflow files standardise format, change name of tests file

### Chores/Misc

- add pull request template
- update tool details in contributing guide

## v2.4.1 (2024-08-20)

## v2.4.0 (2024-01-15)

### Feature
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ keywords:
- ckanext
- contact
license: GPL-3.0-or-later
version: 2.4.0
version: 2.4.4
19 changes: 11 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This extension and [several others](https://github.com/search?q=topic:ckan+org:N

The current core team consists of:
- Josh ([@jrdh](https://github.com/jrdh)) - Technical Lead
- Ginger ([@alycejenni](https://github.com/alycejenni)) - Software Engineer
- Ginger ([@alycejenni](https://github.com/alycejenni)) - Senior Software Engineer


## Questions
Expand Down Expand Up @@ -81,7 +81,10 @@ The process is generally as follows:
3. Make your changes, and commit often; each commit should only contain one change. See below for specifics on how to word your commits.
4. Push your changes back to your fork.
5. [Open a pull request](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#making-a-pull-request) in this repository, with the base branch set to **dev** and the compare branch set to your new branch. Provide a summary of your changes in the description.
6. If the automatic tests fail (these may take a while), please go back to your code and try to make them pass. You may have to update the tests themselves. You don't have to close the pull request while you're doing this; it'll update as you add further commits.
6. There are several automated checks that will run when you open the pull request. Try to make all of them pass. If you do not at least _attempt_ to make them pass, we will not merge your pull request.
1. Tests. Update them so that they pass, if necessary. New tests are always welcome in any pull request, but if you have added a new feature that has decreased the coverage, new tests are required.
2. Commit format validation. If you have not followed the conventional commits format for one or more of your commits, this will fail.
3. Code format validation. If you have not formatted your code correctly (using Ruff, docformatter, and/or Prettier), this will fail.
7. Wait for feedback from one of the core maintainers. If it's been a week or so and we haven't responded, we may not have seen it. You can find other places to contact us in [SUPPORT.md](./.github/SUPPORT.md).

### Commits
Expand Down Expand Up @@ -142,9 +145,9 @@ cz c

##### pre-commit

pre-commit is a tool that runs a variety of checks and modifications before a commit is made. You can check the [.pre-commit-config.yaml](./.pre-commit-config.yaml) file to see eaxtly what it's currently configured to do for this repository, but of particular note:
pre-commit is a tool that runs a variety of checks and modifications before a commit is made. You can check the [.pre-commit-config.yaml](./.pre-commit-config.yaml) file to see exactly what it's currently configured to do for this repository, but of particular note:

- reformats Python code with [Black](https://github.com/psf/black)
- reformats Python code with [Ruff](https://docs.astral.sh/ruff)
- reformats JavaScript and stylesheets with [Prettier](https://prettier.io)
- reformats docstrings with [docformatter](https://github.com/PyCQA/docformatter)
- checks your commit message is correcly formatted
Expand All @@ -161,15 +164,15 @@ pre-commit run

Don't forget to stage any modifications that it makes! Once it runs without failing, then you can make your commit.

Something to remember is that empty docstrings will cause conflicts between Black and docformatter and the checks will fail repeatedly - so don't leave your docstrings empty!
Something to remember is that empty docstrings will cause conflicts between Ruff and docformatter and the checks will fail repeatedly - so don't leave your docstrings empty!

### Code changes and style guide

We generally use external style guides and tools to help us maintain standardised code. Black and Prettier will be run with pre-commit.
We generally use external style guides and tools to help us maintain standardised code. Ruff and Prettier will be run with pre-commit.

#### Python

We follow the [Black style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html), with the notable exception that we use single quotes.
We use [Ruff](https://docs.astral.sh/ruff) to format our code, using defaults for everything except quote style (we use single quotes).

We also _mostly_ use [CKAN's style](http://docs.ckan.org/en/latest/contributing/python.html), with the following exceptions:
- prefer `f''` strings over `.format()`
Expand All @@ -178,7 +181,7 @@ We also _mostly_ use [CKAN's style](http://docs.ckan.org/en/latest/contributing/

#### JavaScript and stylesheets (CSS, LESS, etc)

We use [Prettier](https://prettier.io) to format these files.
We use [Prettier](https://prettier.io) to format these files. As with Ruff, we use defaults for everything except quote style (we use single quotes).

#### Accessibility

Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<!--header-start-->
<img src="https://data.nhm.ac.uk/images/nhm_logo.svg" align="left" width="150px" height="100px" hspace="40"/>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://data.nhm.ac.uk/images/nhm_logo.svg">
<source media="(prefers-color-scheme: light)" srcset="https://data.nhm.ac.uk/images/nhm_logo_black.svg">
<img alt="The Natural History Museum logo." src="https://data.nhm.ac.uk/images/nhm_logo_black.svg" align="left" width="150px" height="100px" hspace="40">
</picture>

# ckanext-contact

[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-contact/main.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-contact/actions/workflows/main.yml)
[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-contact/tests.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-contact/actions/workflows/tests.yml)
[![Coveralls](https://img.shields.io/coveralls/github/NaturalHistoryMuseum/ckanext-contact/main?style=flat-square)](https://coveralls.io/github/NaturalHistoryMuseum/ckanext-contact)
[![CKAN](https://img.shields.io/badge/ckan-2.9.7-orange.svg?style=flat-square)](https://github.com/ckan/ckan)
[![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/)
Expand Down Expand Up @@ -129,15 +133,15 @@ To run the tests against ckan 2.9.x on Python3:

1. Build the required images:
```shell
docker-compose build
docker compose build
```

2. Then run the tests.
The root of the repository is mounted into the ckan container as a volume by the Docker compose
configuration, so you should only need to rebuild the ckan image if you change the extension's
dependencies.
```shell
docker-compose run ckan
docker compose run ckan
```

<!--testing-end-->
6 changes: 3 additions & 3 deletions ckanext/contact/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import functools
from logging import getLogger

from ckanext.contact.auth import send_contact
from ckanext.contact import routes

from ckan.plugins import SingletonPlugin, implements, interfaces, toolkit

from ckanext.contact import routes
from ckanext.contact.auth import send_contact

log = getLogger(__name__)


Expand Down
18 changes: 10 additions & 8 deletions ckanext/contact/routes/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
# Created by the Natural History Museum in London, UK
import logging
import socket
from datetime import datetime, timezone

from ckan import logic
from ckan.common import asbool
from ckan.lib import mailer
from ckan.lib.navl.dictization_functions import unflatten
from ckan.plugins import PluginImplementations, toolkit
from pyisemail import is_email

from ckanext.contact import recaptcha
from ckanext.contact.interfaces import IContact
from datetime import datetime, timezone
from pyisemail import is_email

log = logging.getLogger(__name__)

Expand All @@ -23,8 +25,8 @@ def validate(data_dict):
Validates the given data and recaptcha if necessary.

:param data_dict: the request params as a dict
:return: a 3-tuple of errors, error summaries and a recaptcha error, in the event where no
issues occur the return is ({}, {}, None)
:returns: a 3-tuple of errors, error summaries and a recaptcha error, in the event
where no issues occur the return is ({}, {}, None)
"""
errors = {}
error_summary = {}
Expand Down Expand Up @@ -76,10 +78,10 @@ def build_subject(

:param subject: a user defined subject line
:param default: the default str to use if the user didn't provide a subject or
ckanext.contact.subject isn't specified
ckanext.contact.subject isn't specified
:param timestamp_default: the default bool to use if add_timestamp_to_subject isn't
specified
:return: the subject line
specified
:returns: the subject line
"""
if not subject:
subject = toolkit.config.get('ckanext.contact.subject', toolkit._(default))
Expand All @@ -101,7 +103,7 @@ def submit():
Take the data in the request params and send an email using them. If the data is
invalid or a recaptcha is setup and it fails, don't send the email.

:return: a dict of details
:returns: a dict of details
"""
# this variable holds the status of sending the email
email_success = True
Expand Down
Loading
Loading