Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
1424912e
Commit
1424912e
authored
Apr 22, 2021
by
François
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make phone pattern validation customable
parent
dd81025f
Pipeline
#871
passed with stage
in 21 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
7 deletions
+50
-7
models.py
members/models.py
+4
-4
urls.py
members/urls.py
+0
-1
views.py
members/views.py
+2
-0
common_functions.py
outils/common_functions.py
+33
-0
common_imports.py
outils/common_imports.py
+1
-0
config.md
outils/config.md
+8
-0
validation_form.html
templates/members/validation_form.html
+2
-2
No files found.
members/models.py
View file @
1424912e
...
...
@@ -317,7 +317,7 @@ class CagetteMember(models.Model):
if
'street2'
in
post_data
:
received_data
[
'street2'
]
=
post_data
[
'street2'
]
if
'phone'
in
post_data
:
received_data
[
'phone'
]
=
post_data
[
'phone'
]
received_data
[
'phone'
]
=
format_phone_number
(
post_data
[
'phone'
])
r
=
c_db
.
updateDoc
(
received_data
,
'odoo_id'
)
if
r
:
if
(
'odoo_id'
in
r
):
...
...
@@ -394,7 +394,7 @@ class CagetteMember(models.Model):
'street'
:
post_data
[
'address'
],
'zip'
:
post_data
[
'zip'
],
'city'
:
post_data
[
'city'
],
'phone'
:
post_data
[
'mobile'
]
,
# Because list view default show Phone and people mainly gives mobile
'phone'
:
format_phone_number
(
post_data
[
'mobile'
])
,
# Because list view default show Phone and people mainly gives mobile
'barcode_rule_id'
:
settings
.
COOP_BARCODE_RULE_ID
}
if
(
'_id'
in
post_data
):
...
...
@@ -407,10 +407,10 @@ class CagetteMember(models.Model):
f
[
'street2'
]
=
post_data
[
'street2'
]
if
(
'phone'
in
post_data
)
and
len
(
post_data
[
'phone'
])
>
0
:
if
len
(
f
[
'phone'
])
==
0
:
f
[
'phone'
]
=
post_data
[
'phone'
]
f
[
'phone'
]
=
format_phone_number
(
post_data
[
'phone'
])
else
:
f
[
'mobile'
]
=
f
[
'phone'
]
f
[
'phone'
]
=
post_data
[
'phone'
]
f
[
'phone'
]
=
format_phone_number
(
post_data
[
'phone'
])
# Create coop
if
not
(
'odoo_id'
in
post_data
):
...
...
members/urls.py
View file @
1424912e
...
...
@@ -48,5 +48,4 @@ urlpatterns = [
url
(
r'^add_pts_to_everybody/([0-9]+)/([a-zA-Z0-9_ ]+)$'
,
admin
.
add_pts_to_everybody
),
# conso / groupe recherche / socio
url
(
r'^panel_get_purchases$'
,
views
.
panel_get_purchases
),
]
members/views.py
View file @
1424912e
...
...
@@ -102,6 +102,7 @@ def prepa_odoo(request):
'office_place_string'
:
settings
.
OFFICE_NAME
,
'max_begin_hour'
:
settings
.
MAX_BEGIN_HOUR
,
'payment_meanings'
:
settings
.
SUBSCRIPTION_PAYMENT_MEANINGS
,
'input_phone_pattern'
:
getattr
(
settings
,
'INPUT_PHONE_PATTERN'
,
default_input_phone_pattern
),
'input_barcode'
:
getattr
(
settings
,
'SUBSCRIPTION_INPUT_BARCODE'
,
False
),
'ask_for_sex'
:
getattr
(
settings
,
'SUBSCRIPTION_ASK_FOR_SEX'
,
False
),
'ask_for_street2'
:
getattr
(
settings
,
'SUBSCRIPTION_ADD_STREET2'
,
False
),
...
...
@@ -135,6 +136,7 @@ def validation_inscription(request, email):
'office_place_string'
:
settings
.
OFFICE_NAME
,
'max_begin_hour'
:
settings
.
MAX_BEGIN_HOUR
,
'payment_meanings'
:
settings
.
SUBSCRIPTION_PAYMENT_MEANINGS
,
'input_phone_pattern'
:
getattr
(
settings
,
'INPUT_PHONE_PATTERN'
,
default_input_phone_pattern
),
'ask_for_sex'
:
getattr
(
settings
,
'SUBSCRIPTION_ASK_FOR_SEX'
,
False
),
'ask_for_street2'
:
getattr
(
settings
,
'SUBSCRIPTION_ADD_STREET2'
,
False
),
'ask_for_second_phone'
:
getattr
(
settings
,
'SUBSCRIPTION_ADD_SECOND_PHONE'
,
False
),
...
...
outils/common_functions.py
View file @
1424912e
# -*- coding: utf-8 -*-
"""commons apps functions ."""
from
django.conf
import
settings
default_input_phone_pattern
=
"^((
\
+33(-| )
\
d{1})|
\
d{2})(
\
.| )
\
d{2}(
\
.| )
\
d{2}(
\
.| )
\
d{2}(
\
.| )
\
d{2}$"
def
format_phone_number
(
phone_string
):
"""Format phone number for DB insertion (french format)"""
try
:
import
re
# keep only figures
figures
=
re
.
sub
(
r'[^0-9]'
,
''
,
phone_string
)
international_prefix
=
''
if
len
(
figures
)
>
10
:
international_prefix
=
figures
[:
len
(
figures
)
-
9
]
figures
=
figures
[
-
9
:]
# for the moment, international prefix is omitted, since only french format is processed
if
len
(
figures
)
==
9
:
figures
=
'0'
+
figures
if
len
(
figures
)
==
10
:
number_pairs
=
[
figures
[:
2
]]
for
i
in
range
(
1
,
5
):
idx
=
i
*
2
number_pairs
.
append
(
figures
[
idx
:
idx
+
2
])
phone_pairs_separator
=
getattr
(
settings
,
'PHONE_PAIRS_SEPARATOR'
,
' '
)
output_phone_number
=
phone_pairs_separator
.
join
(
number_pairs
)
else
:
output_phone_number
=
phone_string
except
:
output_phone_number
=
phone_string
return
output_phone_number
outils/common_imports.py
View file @
1424912e
...
...
@@ -79,3 +79,4 @@ LOGGING = {
}
"""
coop_logger
=
logging
.
getLogger
(
"coop.framework"
)
outils/config.md
View file @
1424912e
...
...
@@ -106,6 +106,14 @@
Maximum accepted checks numbers
-
INPUT_PHONE_PATTERN = "^(0
\d
{9})$"
Regexp pattern which is used to validate values input in phone fields
Default is "^((
\+
33(-| )
\d
{1})|
\d
{2})(
\.
| )
\d
{2}(
\.
| )
\d
{2}(
\.
| )
\d
{2}(
\.
| )
\d
{2}$"
-
PHONE_PAIRS_SEPARATOR = "."
Character which by used to separate every 2 phone figures (04.67.23.89.21 for example)
Default is " "
### Scales and labels files generation
-
DAV_PATH = '/data/dav/cagette'
...
...
templates/members/validation_form.html
View file @
1424912e
...
...
@@ -21,9 +21,9 @@
<input
name=
"city"
placeholder=
"Ville"
class=
"b_green"
autocomplete=
"address-level4"
/>
<input
name=
"country"
placeholder=
"Pays"
class=
"b_yellow"
autocomplete=
"address-level4"
/>
<span
class=
"phone-wrapper{% if ask_for_second_phone %}-2{% endif %}"
>
<input
type=
"tel"
name=
"mobile"
placeholder=
"Tél. mobile"
class=
"b_green"
pattern=
"
^(\+\d{1,3}(-| ))?\d{1,2}(\.| )\d{1,2}(\.| )\d{1,2}(\.| )\d{1,2}(\.| )\d{0,2}?$
"
autocomplete=
"address-level4"
/>
<input
type=
"tel"
name=
"mobile"
placeholder=
"Tél. mobile"
class=
"b_green"
pattern=
"
{{input_phone_pattern}}
"
autocomplete=
"address-level4"
/>
{% if ask_for_second_phone %}
<input
type=
"tel"
name=
"phone"
placeholder=
"Tél. fixe"
class=
"b_green"
pattern=
"
^(\+\d{1,3}(-| ))?\d{1,2}(\.| )\d{1,2}(\.| )\d{1,2}(\.| )\d{1,2}(\.| )\d{0,2}?$
"
autocomplete=
"address-level4"
/>
<input
type=
"tel"
name=
"phone"
placeholder=
"Tél. fixe"
class=
"b_green"
pattern=
"
{{input_phone_pattern}}
"
autocomplete=
"address-level4"
/>
{% endif %}
</span>
</p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment