Skip to content

Commit f144458

Browse files
Merge branch 'django:master' into master
2 parents a60ccb0 + bd07715 commit f144458

File tree

9 files changed

+82
-42
lines changed

9 files changed

+82
-42
lines changed

.github/workflows/test.yml

+7-24
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
docs:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
- name: Set up Python
1515
uses: actions/setup-python@v4
1616
with:
@@ -26,11 +26,11 @@ jobs:
2626
lint:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3030
- name: Set up Python
3131
uses: actions/setup-python@v4
3232
with:
33-
python-version: '3.11'
33+
python-version: '3.9'
3434
architecture: x64
3535
- name: Install tox
3636
run: |
@@ -39,36 +39,19 @@ jobs:
3939
- name: Run prospector linting
4040
run: tox -e prospector
4141

42-
test_python_36:
43-
runs-on: ubuntu-20.04
44-
name: Python 3.6
45-
steps:
46-
- uses: actions/checkout@v3
47-
- name: Set up Python
48-
uses: actions/setup-python@v4
49-
with:
50-
python-version: 3.6
51-
architecture: x64
52-
- name: Install tox
53-
run: |
54-
python -m pip install --upgrade pip
55-
python -m pip install --upgrade tox tox-py
56-
- name: Run tests
57-
run: tox --py 36
58-
5942
test:
6043
runs-on: ubuntu-latest
6144
strategy:
6245
matrix:
6346
python-version:
64-
- 3.7
65-
- 3.8
66-
- 3.9
47+
- '3.8'
48+
- '3.9'
6749
- '3.10'
6850
- '3.11'
51+
- '3.12'
6952
name: Python ${{ matrix.python-version }}
7053
steps:
71-
- uses: actions/checkout@v3
54+
- uses: actions/checkout@v4
7255
- name: Set up Python
7356
uses: actions/setup-python@v4
7457
with:

CONTRIBUTING.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ the ``-l`` option::
3737
$ tox -l
3838
docs
3939
...
40-
py36-master
40+
py311-master
4141

4242
You can run each environment with the ``-e`` option::
4343

44-
$ tox -e py36-1.11 # runs the tests only on Python 3.6 and Django 1.11.x
44+
$ tox -e py311-4.2 # runs the tests only on Python 3.11 and Django 4.2.x
4545

4646
Optionally you can also specify a country whose tests you want to run::
4747

4848
$ COUNTRY=us tox
4949

5050
And combine both options::
5151

52-
$ COUNTRY=us tox -e py36-1.11
52+
$ COUNTRY=us tox -e py311-4.2
5353

5454
__ https://github.com/django/django-localflavor/issues
5555
__ https://tox.readthedocs.io/en/latest/install.html

docs/authors.rst

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Authors
22
=======
33

44
* Aaron Boman
5+
* Abdellah El Youssfi Alaoui
56
* Adam Taylor
67
* Adnane Belmadiaf
78
* Adonys Alea Boffill
@@ -98,6 +99,7 @@ Authors
9899
* Nishit Shah
99100
* Olivier Sels
100101
* Olle Vidner
102+
* Paolo Melchiorre
101103
* Paul Cunnane
102104
* Paul Donohue
103105
* Paulo Poiati

docs/changelog.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ New flavors:
1111

1212
New fields for existing flavors:
1313

14-
- None
14+
- Added CIN Number field in Morocco flavor (`gh-705 <https://github.com/django/django-localflavor/pull/507>`_).
1515

1616
Modifications to existing flavors:
1717

@@ -20,7 +20,10 @@ Modifications to existing flavors:
2020

2121
Other changes:
2222

23-
- None
23+
- Dropped support for Python 3.6 and 3.7.
24+
- Dropped support for Django 4.0.
25+
- Added support for Python 3.12.
26+
- Added support for Django 5.0.
2427

2528

2629
4.0 (2023-04-22)

localflavor/ma/forms.py

+23
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,26 @@ class MARegionField(CharField):
7474
def __init__(self, **kwargs):
7575
kwargs.setdefault('label', _('Select Region'))
7676
super().__init__(**kwargs)
77+
78+
79+
class MACinNumberField(RegexField):
80+
"""
81+
CIN number: (Numéro de la Carte D'Identité Nationale) The CIN represents the ID of a Moroccan citizen.
82+
83+
- It is an 8-max-length string that starts with one or two Latin letters followed by digits,
84+
with the first digit not being zero.
85+
86+
- as implemented in the official government site "https://www.cnie.ma/"
87+
.. versionadded:: 4.1
88+
"""
89+
90+
default_error_messages = {
91+
'invalid': _('Enter a valid Moroccan CIN number.'),
92+
}
93+
cin_pattern = r'^[A-Za-z]{1,2}[1-9][0-9]{0,6}$'
94+
95+
def __init__(self, **kwargs):
96+
kwargs.setdefault('label', _('CIN Number'))
97+
kwargs['max_length'] = 8
98+
kwargs['min_length'] = 2
99+
super().__init__(self.cin_pattern, **kwargs)

setup.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,19 @@ def find_package_data(where='.', package='',
127127
'Environment :: Web Environment',
128128
'Framework :: Django',
129129
'Framework :: Django :: 3.2',
130-
'Framework :: Django :: 4.0',
131130
'Framework :: Django :: 4.1',
132131
'Framework :: Django :: 4.2',
132+
'Framework :: Django :: 5.0',
133133
'Intended Audience :: Developers',
134134
'License :: OSI Approved :: BSD License',
135135
'Operating System :: OS Independent',
136136
'Programming Language :: Python',
137137
'Programming Language :: Python :: 3',
138-
'Programming Language :: Python :: 3.6',
139-
'Programming Language :: Python :: 3.7',
140138
'Programming Language :: Python :: 3.8',
141139
'Programming Language :: Python :: 3.9',
142140
'Programming Language :: Python :: 3.10',
143141
'Programming Language :: Python :: 3.11',
142+
'Programming Language :: Python :: 3.12',
144143
'Topic :: Internet :: WWW/HTTP',
145144
],
146145
zip_safe=False,

tests/test_by/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_form_fields(self):
5353
def test_BYRegions_select(self):
5454
"""Test that BYRegionField has valid choices"""
5555
choices = self.form.fields.get('region').choices
56-
self.assertEqual(tuple(choices[1:]), forms.BY_REGIONS_CHOICES)
56+
self.assertEqual(tuple(choices)[1:], forms.BY_REGIONS_CHOICES)
5757

5858
def test_BYRegionSelect(self):
5959
self.maxDiff = None

tests/test_ma.py

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.test import SimpleTestCase
22

3-
from localflavor.ma.forms import MAPostalCodeField, MAProvinceField, MAProvinceSelect, MARegionField, MARegionSelect
3+
from localflavor.ma.forms import MAPostalCodeField, MAProvinceField, MAProvinceSelect, MARegionField, MARegionSelect, \
4+
MACinNumberField
45

56
PROVINCE_SELECT_OUTPUT = '''
67
<select name="province">
@@ -99,6 +100,7 @@
99100
</select>
100101
'''
101102

103+
102104
class MALocalFlavorTests(SimpleTestCase):
103105
def test_MAPostalCodeField(self):
104106
error_format = ['Enter a postal code in the format XXXXX.']
@@ -128,3 +130,32 @@ def test_MAProvinceSelect(self):
128130
def test_MARegionSelect(self):
129131
f = MARegionSelect()
130132
self.assertHTMLEqual(f.render('region', '04'), REGION_SELECT_OUTPUT)
133+
134+
def test_MACinNumberField(self):
135+
error_format = ['Enter a valid Moroccan CIN number.']
136+
valid = {
137+
'D1': 'D1',
138+
'DZ1': 'DZ1',
139+
'D23': 'D23',
140+
'DR23': 'DR23',
141+
'D345': 'D345',
142+
'DR345': 'DR345',
143+
'D3454': 'D3454',
144+
'DT3454': 'DT3454',
145+
'D34546': 'D34546',
146+
'DG34546': 'DG34546',
147+
'D345467': 'D345467',
148+
'DH345467': 'DH345467',
149+
'D3454673': 'D3454673',
150+
151+
}
152+
invalid = {
153+
'9': ['Ensure this value has at least 2 characters (it has 1).'] + error_format,
154+
'T': ['Ensure this value has at least 2 characters (it has 1).'] + error_format,
155+
'903': error_format,
156+
'D034': error_format,
157+
'DR034': error_format,
158+
'RER45': error_format,
159+
'T23456786': ['Ensure this value has at most 8 characters (it has 9).'] + error_format,
160+
}
161+
self.assertFieldOutput(MACinNumberField, valid, invalid)

tox.ini

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
args_are_paths = false
33
envlist =
44
docs,prospector
5-
{py36,py37,py38,py39,py310,pypy39}-django-3.2
6-
{py38,py39,py310,pypy39}-django-4.0
5+
{py38,py39,py310,pypy39}-django-3.2
76
{py38,py39,py310,py311,pypy39}-django-4.1
87
{py38,py39,py310,py311,pypy39}-django-4.2
9-
{py310,py311}-django-main
8+
{py310,py311,py312}-django-5.0
9+
{py310,py311,py312}-django-main
1010

1111
[testenv]
1212
basepython =
13-
py36: python3.6
14-
py37: python3.7
1513
py38: python3.8
1614
py39: python3.9
1715
py310: python3.10
1816
py311: python3.11
17+
py312: python3.12
1918
pypy39: pypy3.9
2019
usedevelop = true
2120
pip_pre = true
@@ -25,9 +24,9 @@ commands =
2524
invoke test {posargs}
2625
deps =
2726
django-3.2: Django>=3.2,<3.3
28-
django-4.0: Django>=4.0,<4.1
2927
django-4.1: Django>=4.1,<4.2
30-
django-4.2: Django>=4.2b1,<4.3
28+
django-4.2: Django>=4.2,<4.3
29+
django-5.0: Django>=5.0rc1,<5.1
3130
django-main: https://github.com/django/django/archive/main.tar.gz
3231
-r{toxinidir}/tests/requirements.txt
3332

@@ -44,5 +43,5 @@ deps =
4443
prospector==1.3.0
4544
pylint>=2.5.2,<2.6.0
4645
-r{toxinidir}/tests/requirements.txt
47-
basepython = python3.11
46+
basepython = python3.9
4847
commands = prospector --profile .prospector.yaml {toxinidir}

0 commit comments

Comments
 (0)