Skip to content

Commit

Permalink
Merge branch 'release/0.3.84'
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Aug 12, 2024
2 parents 117fdec + 46ec338 commit 17000e5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12']
python-version: ['3.12']
django-version: ['4.2', '5.0', 'dev']

exclude:
- python-version: '3.12'
django-version: '4.2'
- python-version: '3.11'
django-version: 'dev'
services:
mysql:
image: mysql:latest
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ exclude: tests/etc/user-*

repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.7
rev: 1.7.9
hooks:
- id: bandit
args:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.8.0
hooks:
- id: black
language_version: python3.11
language_version: python3.12

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
args:
Expand All @@ -28,7 +28,7 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: requirements-txt-fixer
files: requirements/.*\.txt$
Expand All @@ -42,7 +42,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint
rev: v1.34.0
rev: v1.35.1
hooks:
- id: yamllint
args:
Expand Down
28 changes: 20 additions & 8 deletions edc_adverse_event/templatetags/edc_adverse_event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ class DeathReportModel(DeathReportModelMixin, BaseUuidModel): ...
register = template.Library()


def wrapx(text, length):
def wrapx(text: str, length: int) -> str:
if length:
return "<BR>".join(wrap(text, length))
return text


def escape_braces(text: str) -> str:
return text.replace("{", "{{").replace("}", "}}")


def select_ae_template(relative_path):
"""Returns a template object."""
local_path = f"{get_adverse_event_app_label()}/bootstrap{get_bootstrap_version()}/"
Expand All @@ -78,10 +82,14 @@ def format_ae_description(context, ae_initial, wrap_length):
context["YES"] = YES
context["ae_initial"] = ae_initial
try:
context["sae_reason"] = format_html(wrapx(ae_initial.sae_reason.name, wrap_length))
context["sae_reason"] = format_html(
wrapx(escape_braces(ae_initial.sae_reason.name), wrap_length)
)
except AttributeError:
context["sae_reason"] = ""
context["ae_description"] = format_html(wrapx(ae_initial.ae_description, wrap_length))
context["ae_description"] = format_html(
wrapx(escape_braces(ae_initial.ae_description), wrap_length)
)
return context


Expand All @@ -96,13 +104,15 @@ def format_ae_followup_description(context, ae_followup, wrap_length):
context["ae_initial"] = ae_followup.ae_initial
try:
context["sae_reason"] = format_html(
wrapx(ae_followup.ae_initial.sae_reason.name, wrap_length)
wrapx(escape_braces(ae_followup.ae_initial.sae_reason.name), wrap_length)
)
except AttributeError:
context["sae_reason"] = ""
context["relevant_history"] = format_html(wrapx(ae_followup.relevant_history, wrap_length))
context["relevant_history"] = format_html(
wrapx(escape_braces(ae_followup.relevant_history), wrap_length)
)
context["ae_description"] = format_html(
wrapx(ae_followup.ae_initial.ae_description, wrap_length)
wrapx(escape_braces(ae_followup.ae_initial.ae_description), wrap_length)
)
return context

Expand All @@ -116,10 +126,12 @@ def format_ae_susar_description(context, ae_susar, wrap_length):
context["ae_susar"] = ae_susar
context["ae_initial"] = ae_susar.ae_initial
context["sae_reason"] = format_html(
"<BR>".join(wrap(ae_susar.ae_initial.sae_reason.name, wrap_length or 35))
"<BR>".join(
wrap(escape_braces(ae_susar.ae_initial.sae_reason.name), wrap_length or 35)
)
)
context["ae_description"] = format_html(
wrapx(ae_susar.ae_initial.ae_description, wrap_length)
wrapx(escape_braces(ae_susar.ae_initial.ae_description), wrap_length)
)
return context

Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ version_file="_version.py"

[tool.black]
line-length = 95
target-version = ["py311"]
target-version = ["py312"]
extend-exclude = '''^(.*\/)*\b(migrations)\b($|\/.*$)'''

[tool.isort]
profile = "black"
py_version = "311"
py_version = "312"
skip = [".tox", ".eggs", "migrations"]

[tool.coverage.run]
Expand All @@ -35,15 +35,13 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
envlist =
py{311}-dj{42,50},
py{312}-dj{50,dev},
py{312}-dj{42,50,dev},
lint
isolated_build = true
[gh-actions]
python =
3.11: py311
3.12: py312, lint
[gh-actions:env]
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ classifiers=
Intended Audience :: Developers
Intended Audience :: Science/Research
Operating System :: OS Independent
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
License :: OSI Approved :: GNU General Public License v3 (GPLv3)


[options]
python_requires = >=3.11
python_requires = >=3.12
zip_safe = False
include_package_data = True
packages = find:
Expand Down

0 comments on commit 17000e5

Please sign in to comment.