Skip to content

Commit 70f00f3

Browse files
0 5 3 sam (#81)
* Added support for django 4.2 * more upgrades * update github python * linting * fix customfield for 4.2 changes * add extra html fallback test * lint * fix deps versions * Remove trace debug code --------- Co-authored-by: Tuo Liu <tuo.liu@aristotlemetadata.com>
1 parent 0fa2db7 commit 70f00f3

File tree

13 files changed

+685
-711
lines changed

13 files changed

+685
-711
lines changed

.github/workflows/black.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ jobs:
99
- uses: actions/checkout@v2
1010
- uses: actions/setup-python@v2
1111
with:
12-
python-version: 3.8
12+
python-version: 3.9
1313
- uses: psf/black@stable

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- uses: actions/checkout@v2
4444
- uses: actions/setup-python@v2
4545
with:
46-
python-version: 3.8
46+
python-version: 3.12
4747

4848
- name: Install test tools
4949
run: pip install tox coverage

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
## 0.5.1
44
- Added support for django 4.1
5+
## 0.5.3
6+
- Added support for django 4.2

dev/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-buster
1+
FROM python:3.12
22

33
# Install python package management tools
44
RUN pip install --upgrade setuptools pip poetry tox

dev/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
* Reformat the file using black command:
2929
3030
Run `black .` at the root directory of the project
31+
32+
* Testing against a specific database:
33+
34+
DATABASE_URL=postgres://postgres:changeme@postgres_db/postgres tox -e dj-51

dev/pg/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM postgres:10
1+
FROM postgres:13
22
COPY install-extensions.sql /docker-entrypoint-initdb.d

poetry.lock

Lines changed: 599 additions & 678 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-garnett"
3-
version = "0.5.2"
3+
version = "0.5.3"
44
description = "Simple translatable Django fields"
55
authors = ["Aristotle Metadata Enterprises"]
66
license = "BSD-3-Clause"
@@ -10,8 +10,8 @@ packages = [
1010
]
1111

1212
[tool.poetry.dependencies]
13-
python = "^3.7"
14-
django = ">3.1, <4.2"
13+
python = "^3.12"
14+
django = ">=4.1"
1515
langcodes = "~3.3.0"
1616
language-data = "~1.0.1"
1717

@@ -21,10 +21,10 @@ coverage = "~5.3.1"
2121
dj-database-url = "~0.5.0"
2222
psycopg2 = "~2.8.6"
2323
mock = "~4.0.3"
24-
djangorestframework = "~3.12.4"
25-
drf_yasg = "~1.20.0"
26-
django-reversion = ">=4.0.1"
27-
django-reversion-compare = ">=0.14.1"
24+
djangorestframework = "~3.15"
25+
drf_yasg = ">=1.20.0"
26+
django-reversion = ">=5.1.0"
27+
django-reversion-compare = ">=0.18.1"
2828
django-filter = ">=21.1"
2929

3030
[build-system]

runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.8.10
1+
python-3.10.12

tests/library_app/models.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,36 @@
1313

1414

1515
class CustomTestingField(models.TextField):
16-
def get_db_prep_save(self, value, connection):
16+
def get_db_prep_value(self, value, connection, prepared=False):
1717
"""
1818
Note: If there is data migration when migrating to TranslatedField, the manually added
1919
step_1_safe_encode_content() function in the migration file will base64 encode the value in the field
20-
before get_db_prep_save is called.
20+
before get_db_prep_value is called.
2121
2222
For example:
2323
old value = "this is a book"
2424
new value = '{"en": "dGhpcyBpcyBhIGJvb2s="}'
2525
26-
The new value is then parse to the get_db_prep_save() function.
27-
If custom get_db_prep_save() function is used you will need to make sure that the custom get_db_prep_save() function is
26+
The new value is then parse to the get_db_prep_value() function.
27+
If custom get_db_prep_value() function is used you will need to make sure that the custom get_db_prep_value() function is
2828
not modifying the input value.
2929
3030
Some examples,
31-
1. if the custom get_db_prep_save() function append a fix str to all input value:
31+
1. if the custom get_db_prep_value() function append a fix str to all input value:
3232
input value = '{"en": "dGhpcyBpcyBhIGJvb2s="}'
3333
return value = '{"en": "dGhpcyBpcyBhIGJvb2s="}1234567'
3434
this would raise "django.db.utils.DataError: invalid input syntax for type json" because the return value
35-
from the custom get_db_prep_save() function is not valid json
35+
from the custom get_db_prep_value() function is not valid json
3636
37-
2. if the custom get_db_prep_save() function bleach certain substring (e.g dGhpcy) on the input value:
37+
2. if the custom get_db_prep_value() function bleach certain substring (e.g dGhpcy) on the input value:
3838
input value = '{"en": "dGhpcyBpcyBhIGJvb2s="}'
3939
return value = '{"en": "BpcyBhIGJvb2s="}'
4040
this would modify the base64 value and decoding the modfied base64 value would return unexpected result
4141
"""
4242
if value is None:
43-
return super().get_db_prep_save(value, connection)
43+
return super().get_db_prep_value(value, connection, prepared)
4444
bleached_value = value.replace(BLEACH_STR, RANDOM_STR)
45-
return super().get_db_prep_save(bleached_value, connection)
45+
return super().get_db_prep_value(bleached_value, connection, prepared)
4646

4747

4848
def validate_length(value):

0 commit comments

Comments
 (0)