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
188f17cd
Commit
188f17cd
authored
Sep 29, 2021
by
François
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modifications pour requête membre service commité et validation clic
parent
d3bee25b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
10 deletions
+63
-10
models.py
members/models.py
+48
-5
members.js
members/static/js/members.js
+1
-2
urls.py
members/urls.py
+1
-1
views.py
members/views.py
+9
-2
index.html
templates/members/index.html
+4
-0
No files found.
members/models.py
View file @
188f17cd
...
...
@@ -671,7 +671,7 @@ class CagetteMember(models.Model):
return
m_list
@staticmethod
def
search
(
k_type
,
key
):
def
search
(
k_type
,
key
,
shift_id
=
None
):
"""Search member according 3 types of key."""
api
=
OdooAPI
()
if
k_type
==
'id'
:
...
...
@@ -683,11 +683,26 @@ class CagetteMember(models.Model):
else
:
cond
=
[[
'name'
,
'ilike'
,
str
(
key
)]]
# cond.append(['cooperative_state', '!=', 'unsubscribed'])
res
=
api
.
search_read
(
'res.partner'
,
cond
,
CagetteMember
.
m_default_fields
)
fields
=
CagetteMember
.
m_default_fields
if
not
shift_id
is
None
:
CagetteMember
.
m_default_fields
.
append
(
'tmpl_reg_line_ids'
)
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
members
=
[]
if
len
(
res
)
>
0
:
for
m
in
res
:
keep_it
=
False
if
not
shift_id
is
None
and
len
(
shift_id
)
>
0
:
# Only member registred to shift_id will be returned
cond
=
[[
'id'
,
'='
,
m
[
'tmpl_reg_line_ids'
][
0
]]]
fields
=
[
'shift_template_id'
]
shift_templ_res
=
api
.
search_read
(
'shift.template.registration.line'
,
cond
,
fields
)
if
(
len
(
shift_templ_res
)
>
0
and
int
(
shift_templ_res
[
0
][
'shift_template_id'
][
0
])
==
int
(
shift_id
)):
keep_it
=
True
else
:
keep_it
=
True
if
keep_it
is
True
:
try
:
img_code
=
base64
.
b64decode
(
m
[
'image_medium'
])
extension
=
imghdr
.
what
(
''
,
img_code
)
...
...
@@ -769,6 +784,7 @@ class CagetteMembers(models.Model):
api
=
OdooAPI
()
return
[]
@staticmethod
def
raw_search
(
needle
):
"""Search partner with missing elements"""
...
...
@@ -1220,17 +1236,42 @@ class CagetteServices(models.Model):
return
result
@staticmethod
def
get_committees_shift_id
():
shift_id
=
None
try
:
api
=
OdooAPI
()
res
=
api
.
search_read
(
'ir.config_parameter'
,
[[
'key'
,
'='
,
'lacagette_membership.committees_shift_id'
]],
[
'value'
])
if
len
(
res
)
>
0
:
try
:
shift_id
=
int
(
res
[
0
][
'value'
])
except
:
pass
except
:
pass
return
shift_id
@staticmethod
def
easy_validate_shift_presence
(
coop_id
):
"""Add a presence point if the request is valid."""
res
=
{}
try
:
committees_shift_id
=
CagetteServices
.
get_committees_shift_id
()
api
=
OdooAPI
()
# let verify coop_id is corresponding to a ftop subscriber
cond
=
[[
'id'
,
'='
,
coop_id
]]
fields
=
[
'
shift_type
'
]
fields
=
[
'
tmpl_reg_line_ids
'
]
coop
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
coop
:
if
coop
[
0
][
'shift_type'
]
==
'ftop'
:
if
len
(
coop
[
0
][
'tmpl_reg_line_ids'
])
>
0
:
cond
=
[[
'id'
,
'='
,
coop
[
0
][
'tmpl_reg_line_ids'
][
0
]]]
fields
=
[
'shift_template_id'
]
shift_templ_res
=
api
.
search_read
(
'shift.template.registration.line'
,
cond
,
fields
)
if
(
len
(
shift_templ_res
)
>
0
and
shift_templ_res
[
0
][
'shift_template_id'
][
0
]
==
committees_shift_id
):
evt_name
=
getattr
(
settings
,
'ENTRANCE_ADD_PT_EVENT_NAME'
,
'Validation service comité'
)
c
=
[[
'partner_id'
,
'='
,
coop_id
],
[
'name'
,
'='
,
evt_name
]]
f
=
[
'create_date'
]
...
...
@@ -1252,6 +1293,8 @@ class CagetteServices(models.Model):
else
:
res
[
'error'
]
=
"Unallowed coop"
else
:
res
[
'error'
]
=
"Unregistred coop"
else
:
res
[
'error'
]
=
"Invalid coop id"
except
Exception
as
e
:
coop_logger
.
error
(
"easy_validate_shift_presence :
%
s
%
s"
,
str
(
coop_id
),
str
(
e
))
...
...
members/static/js/members.js
View file @
188f17cd
...
...
@@ -786,11 +786,10 @@ $(document).ready(function() {
let
search_str
=
sm_search_member_input
.
val
();
$
.
ajax
({
url
:
'/members/search/'
+
search_str
,
url
:
'/members/search/'
+
search_str
+
'/'
+
window
.
committees_shift_id
,
dataType
:
'json'
,
success
:
function
(
data
)
{
members_search_results
=
[];
for
(
member
of
data
.
res
)
{
if
(
member
.
shift_type
==
'ftop'
)
{
members_search_results
.
push
(
member
);
...
...
members/urls.py
View file @
188f17cd
...
...
@@ -36,7 +36,7 @@ urlpatterns = [
url
(
r'^verify_final_state$'
,
views
.
verify_final_state
),
url
(
r'^update_couchdb_barcodes$'
,
views
.
update_couchdb_barcodes
),
# Borne accueil
url
(
r'^search/(
.+
)'
,
views
.
search
),
url
(
r'^search/(
[^\/.]+)/?([0-9]*
)'
,
views
.
search
),
url
(
r'^save_photo/([0-9]+)$'
,
views
.
save_photo
,
name
=
'save_photo'
),
url
(
r'^services_at_time/([0-9TZ\-\: \.]+)/([0-9\-]+)$'
,
views
.
services_at_time
),
url
(
r'^service_presence/$'
,
views
.
record_service_presence
),
...
...
members/views.py
View file @
188f17cd
...
...
@@ -41,6 +41,13 @@ def index(request):
context
[
'ftop_btn_display'
]
=
getattr
(
settings
,
'ENTRANCE_FTOP_BUTTON_DISPLAY'
,
True
)
context
[
'extra_btns_display'
]
=
getattr
(
settings
,
'ENTRANCE_EXTRA_BUTTONS_DISPLAY'
,
True
)
context
[
'easy_shift_validate'
]
=
getattr
(
settings
,
'ENTRANCE_EASY_SHIFT_VALIDATE'
,
False
)
if
context
[
'easy_shift_validate'
]
is
True
:
committees_shift_id
=
CagetteServices
.
get_committees_shift_id
()
if
committees_shift_id
is
None
:
return
HttpResponse
(
"Le créneau des comités n'est pas configuré dans Odoo !"
)
else
:
context
[
'committees_shift_id'
]
=
committees_shift_id
if
'no_picture_member_advice'
in
msettings
:
if
len
(
msettings
[
'no_picture_member_advice'
][
'value'
])
>
0
:
context
[
'no_picture_member_advice'
]
=
msettings
[
'no_picture_member_advice'
][
'value'
]
...
...
@@ -227,7 +234,7 @@ def update_couchdb_barcodes(request):
# Borne accueil
def
search
(
request
,
needle
):
def
search
(
request
,
needle
,
shift_id
):
"""Search member has been requested."""
try
:
key
=
int
(
needle
)
...
...
@@ -239,7 +246,7 @@ def search(request, needle):
key
=
needle
k_type
=
'name'
res
=
CagetteMember
.
search
(
k_type
,
key
)
res
=
CagetteMember
.
search
(
k_type
,
key
,
shift_id
)
return
JsonResponse
({
'res'
:
res
})
...
...
templates/members/index.html
View file @
188f17cd
...
...
@@ -18,11 +18,15 @@
history
.
pushState
(
null
,
null
,
location
.
pathname
)
};
window
.
late_mode
=
{
%
if
LATE_MODE
%
}
true
{
%
else
%
}
false
{
%
endif
%
};
{
%
if
committees_shift_id
%
}
window
.
committees_shift_id
=
{{
committees_shift_id
}};
{
%
endif
%
}
</script>
<script
src=
"{% static "
js
/
webcam
.
min
.
js
"
%}"
>
</script>
<script
src=
"{% static "
js
/
JsBarcode
.
all
.
min
.
js
"
%}"
>
</script>
<script
type=
"text/javascript"
src=
"{% static 'js/notify.min.js' %}?v="
></script>
<script
defer
src=
"{% static "
fontawesome
/
js
/
fontawesome-all
.
js
"
%}"
></script>
{% endblock %}
...
...
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