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

Add support for django 5 #9

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/workflows/code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
django-version: ["~=4.0.0", "~=4.1.0", "~=4.2.0"]
python-version: ["3.10", "3.11", "3.12"]
django-version: ["~=5.0.0", "~=5.1.0"]
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: djsc_sandbox
POSTGRES_DB: sandbox
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
Expand All @@ -48,7 +48,7 @@ jobs:
python -m poetry run pip install "Django${{ matrix.django-version }}"
- name: Run Tests
run: |
python -m poetry run coverage run djsc_sandbox/manage.py test tests
python -m poetry run coverage run sandbox/manage.py test tests
python -m poetry run coverage lcov -o ./coverage/lcov.info
- name: Upload coverage to Coveralls in parallel
uses: coverallsapp/github-action@master
Expand All @@ -64,4 +64,4 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
parallel-finished: true
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ coverage.xml
*.mo
*.pot
# Must include sandbox translations for tests
!djsc_sandbox/myapp/locale/**
!sandbox/myapp/locale/**

# Django stuff:
*.log
Expand Down Expand Up @@ -110,4 +110,4 @@ venv.bak/

# local only by design
poetry.lock
setup.py
setup.py
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

.PHONY: test
test:
poetry run djsc_sandbox/manage.py test tests
poetry run sandbox/manage.py test tests

.PHONY: coverage
coverage:
poetry run coverage run djsc_sandbox/manage.py test tests
poetry run coverage run sandbox/manage.py test tests

.PHONY: coverage-html
coverage-html:
poetry run coverage run djsc_sandbox/manage.py test tests && poetry run coverage html
poetry run coverage run sandbox/manage.py test tests && poetry run coverage html

.PHONY: reqs
reqs:
poetry export --without-hashes --dev --format requirements.txt > requirements.txt
poetry export --without-hashes --dev --format requirements.txt > requirements.txt
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ Contributing

- PRs are welcome!
- To run the test suite run ``make`` or ``make coverage``. The tests for this
project live inside a small django project called ``djsc_sandbox``.
project live inside a small django project called ``sandbox``.


Credits
-------

Inspired by (and conceptually forked from)
`django-js-reverse <https://github.com/ierror/django-js-reverse>`_
`django-js-reverse <https://github.com/ierror/django-js-reverse>`_
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
value: pair[0],
label: pair[1]
};
}
};
return choices && choices.map(mapper);
},
display: function(name, choice) {
Expand Down
43 changes: 0 additions & 43 deletions djsc_sandbox/myapp/choices.py

This file was deleted.

19 changes: 0 additions & 19 deletions djsc_sandbox/myapp/models.py

This file was deleted.

15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-js-choices"
version = "0.5.1"
version = "0.6.0"
description = "Javascript model field choices handling for Django."
license = "MIT"
authors = ["Lorenzo Peña <[email protected]>"]
Expand All @@ -10,21 +10,20 @@ keywords = ["django", "choices", "javascript"]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: Django",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
]

[tool.poetry.dependencies]
python = "^3.8.1"
django = ">=4.0,<5.0"
python = "^3.10"
django = ">=5.0,<6.0"
rjsmin = "^1.1.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
black = "^23.3.0"
coverage = {extras = ["toml"], version = "^6.3"}
django-multiselectfield = "^0.1.12"
dukpy = "^0.3.0"
dukpy = "^0.4.0"
flake8 = "^6.0.0"
flake8-bugbear = "^23.3.23"
flake8-comprehensions = "^3.12.0"
Expand Down
File renamed without changes.
File renamed without changes.
82 changes: 82 additions & 0 deletions sandbox/myapp/choices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from django_js_choices.core import register_choice

YEAR_IN_SCHOOL_CHOICES = [
("FR", _("Freshman")),
("SO", _("Sophomore")),
("JR", _("Junior")),
("SR", _("Senior")),
("GR", _("Graduate")),
]

MEDIA_CHOICES = [
(
"Audio",
(
("vinyl", _("Vinyl")),
("cd", _("CD")),
),
),
(
"Video",
(
("vhs", _("VHS Tape")),
("dvd", _("DVD")),
),
),
("unknown", _("Unknown")),
]

MEDAL_TYPES = [
("Gold", _("Gold")),
("Silver", _("Silver")),
("Bronze", _("Bronze")),
]

YES_NO_ANSWER = [
(None, _("(Unknown)")),
(0, _("No")),
(1, _("Yes")),
]

FRUITS_CUSTOM_CHOICES = [
("banana", _("Banana")),
("apple", _("Apple")),
("orange", _("Orange")),
]

register_choice("fruits", FRUITS_CUSTOM_CHOICES)

YEAR_IN_SCHOOL_CHOICES_2 = {
"FR": _("Freshman"),
"SO": _("Sophomore"),
"JR": _("Junior"),
"SR": _("Senior"),
"GR": _("Graduate"),
}

MEDIA_CHOICES_2 = {
"Audio": {
"vinyl": _("Vinyl"),
"cd": _("CD"),
},
"Video": {
"vhs": _("VHS Tape"),
"dvd": _("DVD"),
},
"unknown": _("Unknown"),
}


class MedalTypes2(models.TextChoices):
GOLD = "Gold"
SILVER = "Silver"
BRONZE = "Bronze"


class YesNoAnswer2(models.IntegerChoices):
NO = 0, _("No")
YES = 1, _("Yes")
__empty__ = _("(Unknown)")
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,58 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: djsc_sandbox/myapp/choices.py:4
#: sandbox/myapp/choices.py:4
msgid "Freshman"
msgstr "Estudiante de primer año"

#: djsc_sandbox/myapp/choices.py:5
#: sandbox/myapp/choices.py:5
msgid "Sophomore"
msgstr "Estudiante de segundo año"

#: djsc_sandbox/myapp/choices.py:6
#: sandbox/myapp/choices.py:6
msgid "Junior"
msgstr "Estudiante de tercer año"

#: djsc_sandbox/myapp/choices.py:7
#: sandbox/myapp/choices.py:7
msgid "Senior"
msgstr "Estudiante de último año"

#: djsc_sandbox/myapp/choices.py:8
#: sandbox/myapp/choices.py:8
msgid "Graduate"
msgstr "Graduado"

#: djsc_sandbox/myapp/choices.py:15
#: sandbox/myapp/choices.py:15
msgid "Vinyl"
msgstr "Vinil"

#: djsc_sandbox/myapp/choices.py:16
#: sandbox/myapp/choices.py:16
msgid "CD"
msgstr "CD"

#: djsc_sandbox/myapp/choices.py:22
#: sandbox/myapp/choices.py:22
msgid "VHS Tape"
msgstr "Cinta VHS"

#: djsc_sandbox/myapp/choices.py:23
#: sandbox/myapp/choices.py:23
msgid "DVD"
msgstr "DVD"

#: djsc_sandbox/myapp/choices.py:26
#: sandbox/myapp/choices.py:26
msgid "Unknown"
msgstr "Desconocido"

#: djsc_sandbox/myapp/choices.py:30
#: sandbox/myapp/choices.py:30
msgid "Gold"
msgstr "Oro"

#: djsc_sandbox/myapp/choices.py:31
#: sandbox/myapp/choices.py:31
msgid "Silver"
msgstr "Plata"

#: djsc_sandbox/myapp/choices.py:32
#: sandbox/myapp/choices.py:32
msgid "Bronze"
msgstr "Bronce"

#: djsc_sandbox/tests/test_core.py:16
#: sandbox/tests/test_core.py:16
msgid "b"
msgstr "b"
msgstr "b"
Loading
Loading