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
c443f682
Commit
c443f682
authored
Mar 11, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: delete shift template registration
parent
b6673825
Pipeline
#1940
passed with stage
in 1 minute 29 seconds
Changes
8
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
13 deletions
+160
-13
admin.py
members/admin.py
+43
-0
models.py
members/models.py
+12
-3
manage_regular_shifts.css
members/static/css/admin/manage_regular_shifts.css
+17
-0
manage_regular_shifts.js
members/static/js/admin/manage_regular_shifts.js
+70
-9
urls.py
members/urls.py
+1
-0
manage_makeups.html
templates/members/admin/manage_makeups.html
+1
-0
manage_regular_shifts.html
templates/members/admin/manage_regular_shifts.html
+15
-1
manage_shift_registrations.html
templates/members/admin/manage_shift_registrations.html
+1
-0
No files found.
members/admin.py
View file @
c443f682
...
...
@@ -406,3 +406,45 @@ def delete_shift_registration(request):
res
[
"message"
]
=
"Unauthorized"
response
=
JsonResponse
(
res
,
status
=
403
)
return
response
def
delete_shift_template_registration
(
request
):
""" From BDM admin, delete a member shift template registration """
res
=
{}
is_connected_user
=
CagetteUser
.
are_credentials_ok
(
request
)
if
is_connected_user
is
True
:
try
:
data
=
json
.
loads
(
request
.
body
.
decode
())
partner_id
=
int
(
data
[
"partner_id"
])
shift_template_id
=
int
(
data
[
"shift_template_id"
])
makeups_to_do
=
int
(
data
[
"makeups_to_do"
])
permanent_unsuscribe
=
data
[
"permanent_unsuscribe"
]
cm
=
CagetteMember
(
partner_id
)
# Get partner nb of future makeup shifts
partner_makeups
=
cm
.
get_member_selected_makeups
()
target_makeup
=
makeups_to_do
+
len
(
partner_makeups
)
if
target_makeup
>
2
:
target_makeup
=
2
print
(
target_makeup
)
# Update partner makeups to do
res_update_makeups
=
cm
.
update_member_makeups
({
'target_makeups_nb'
:
target_makeup
})
print
(
res_update_makeups
)
except
Exception
as
e
:
print
(
str
(
e
))
# Récupérer nb rattrapages sélectionnés, incrémenter makeups_to_do
# Delete all shift.registration
# Delete all shift.template.registration (et .line ?)
# si permanent_unsuscribe, set special status gone
response
=
JsonResponse
(
res
,
safe
=
False
)
else
:
res
[
"message"
]
=
"Unauthorized"
response
=
JsonResponse
(
res
,
status
=
403
)
return
response
\ No newline at end of file
members/models.py
View file @
c443f682
...
...
@@ -779,14 +779,15 @@ class CagetteMember(models.Model):
res
=
api
.
search_read
(
'res.partner'
,
cond
,
fields
)
if
res
:
c
=
[[
'partner_id'
,
'='
,
int
(
res
[
0
][
'id'
])]]
for
partner
in
res
:
c
=
[[
'partner_id'
,
'='
,
int
(
partner
[
'id'
])],
[
'state'
,
'in'
,
(
'draft'
,
'open'
)]]
f
=
[
'shift_template_id'
]
shift_template_reg
=
api
.
search_read
(
'shift.template.registration'
,
c
,
f
)
if
shift_template_reg
:
res
[
0
][
'shift_template_name'
]
=
shift_template_reg
[
0
][
'shift_template_id'
][
1
]
partner
[
'shift_template_id'
]
=
shift_template_reg
[
0
][
'shift_template_id'
]
else
:
res
[
0
][
'shift_template_name
'
]
=
None
partner
[
'shift_template_id
'
]
=
None
return
res
else
:
...
...
@@ -880,6 +881,14 @@ class CagetteMember(models.Model):
return
res
def
get_member_selected_makeups
(
self
):
res
=
{}
c
=
[[
"partner_id"
,
"="
,
self
.
id
],
[
"is_makeup"
,
"="
,
True
],
[
"state"
,
"="
,
"open"
]]
f
=
[
'id'
]
res
=
self
.
o_api
.
search_read
(
"shift.registration"
,
c
,
f
)
return
res
class
CagetteMembers
(
models
.
Model
):
"""Class to manage operations on all members or part of them."""
...
...
members/static/css/admin/manage_regular_shifts.css
View file @
c443f682
...
...
@@ -73,3 +73,19 @@
.member_info
{
font-weight
:
bold
;
}
/* Actions */
#actions_on_member
{
margin
:
15px
;
}
#remove_shift_template_button
{
display
:
none
;
}
.checkbox_area
{
margin
:
10px
0
;
}
#permanent_unsuscribe
{
margin-right
:
5px
;
}
\ No newline at end of file
members/static/js/admin/manage_regular_shifts.js
View file @
c443f682
...
...
@@ -10,16 +10,76 @@ var selected_member = null,
};
/**
* Send request to remove partner from shift template
*/
function
remove_from_shift_template
()
{
let
permanent_unsuscribe
=
modal
.
find
(
"#permanent_unsuscribe"
).
prop
(
'checked'
);
// openModal();
closeModal
()
let
data
=
{
partner_id
:
selected_member
.
id
,
shift_template_id
:
selected_member
.
shift_template_id
[
0
],
permanent_unsuscribe
:
permanent_unsuscribe
,
makeups_to_do
:
selected_member
.
makeups_to_do
,
};
$
.
ajax
({
type
:
'POST'
,
url
:
'/members/delete_shift_template_registration'
,
data
:
JSON
.
stringify
(
data
),
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
data
)
{
closeModal
();
},
error
:
function
()
{
err
=
{
msg
:
"erreur serveur lors de la suppression du membre du créneau"
,
ctx
:
'members.admin.manage_regular_shifts.remove_from_shift_template'
};
report_JS_error
(
err
,
'members.admin'
);
closeModal
();
$
.
notify
(
"Erreur lors de la suppression du membre du créneau."
,
{
globalPosition
:
"top right"
,
className
:
"error"
});
}
});
}
/**
* When a member is selected, display the selected member relevant info
*/
function
display_member_info
()
{
$
(
'.member_name'
).
text
(
`
${
selected_member
.
barcode_base
}
-
${
selected_member
.
name
}
`
);
$
(
'.member_shift'
).
text
(
selected_member
.
shift_template_
name
);
$
(
'.member_shift'
).
text
(
selected_member
.
shift_template_
id
[
1
]
);
$
(
'.member_status'
).
text
(
possible_cooperative_state
[
selected_member
.
cooperative_state
]);
$
(
'.member_makeups'
).
text
(
selected_member
.
makeups_to_do
);
$
(
'#search_member_input'
).
val
();
$
(
'#partner_data_area'
).
css
(
'display'
,
'flex'
);
if
(
selected_member
.
shift_template_id
===
undefined
||
selected_member
.
shift_template_id
===
null
)
{
$
(
"#remove_shift_template_button"
).
hide
();
$
(
"#remove_shift_template_button"
).
off
();
}
else
{
$
(
"#remove_shift_template_button"
).
show
();
$
(
"#remove_shift_template_button"
).
off
();
$
(
"#remove_shift_template_button"
).
on
(
"click"
,
()
=>
{
let
modal_template
=
$
(
"#modal_remove_shift_template"
);
modal_template
.
find
(
".shift_template_name"
).
text
(
selected_member
.
shift_template_id
[
1
]);
openModal
(
modal_template
.
html
(),
remove_from_shift_template
,
"Valider"
,
false
);
});
}
}
/**
...
...
@@ -75,14 +135,6 @@ $(document).ready(function() {
if
(
coop_is_connected
())
{
$
.
ajaxSetup
({
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)
}
});
$
(
".page_content"
).
show
();
}
else
{
$
(
".page_content"
).
hide
();
}
$
(
'#back_to_admin_index'
).
on
(
'click'
,
function
()
{
let
base_location
=
window
.
location
.
href
.
split
(
"manage_regular_shifts"
)[
0
].
slice
(
0
,
-
1
);
window
.
location
.
assign
(
base_location
);
});
// Set action to search for the member
$
(
'#search_member_form'
).
submit
(
function
()
{
...
...
@@ -92,6 +144,7 @@ $(document).ready(function() {
url
:
`/members/search/
${
search_str
}
?search_type=shift_template_data`
,
dataType
:
'json'
,
success
:
function
(
data
)
{
$
(
'#partner_data_area'
).
hide
();
if
(
data
.
res
.
length
===
1
)
{
selected_member
=
data
.
res
[
0
];
display_member_info
();
...
...
@@ -114,4 +167,12 @@ $(document).ready(function() {
}
});
});
}
else
{
$
(
".page_content"
).
hide
();
}
$
(
'#back_to_admin_index'
).
on
(
'click'
,
function
()
{
let
base_location
=
window
.
location
.
href
.
split
(
"manage_regular_shifts"
)[
0
].
slice
(
0
,
-
1
);
window
.
location
.
assign
(
base_location
);
});
});
members/urls.py
View file @
c443f682
...
...
@@ -61,4 +61,5 @@ urlpatterns = [
url
(
r'^get_makeups_members$'
,
admin
.
get_makeups_members
),
url
(
r'^update_members_makeups$'
,
admin
.
update_members_makeups
),
url
(
r'^delete_shift_registration$'
,
admin
.
delete_shift_registration
),
url
(
r'^delete_shift_template_registration$'
,
admin
.
delete_shift_template_registration
),
]
templates/members/admin/manage_makeups.html
View file @
c443f682
...
...
@@ -11,6 +11,7 @@
{% block additionnal_scripts %}
<script
type=
"text/javascript"
src=
"{% static 'jquery-ui-1.12.1/jquery-ui.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/datatables.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/notify.min.js' %}?v="
></script>
{% endblock %}
{% block content %}
...
...
templates/members/admin/manage_regular_shifts.html
View file @
c443f682
...
...
@@ -11,6 +11,7 @@
{% block additionnal_scripts %}
<script
type=
"text/javascript"
src=
"{% static 'jquery-ui-1.12.1/jquery-ui.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/datatables.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/notify.min.js' %}?v="
></script>
{% endblock %}
{% block content %}
...
...
@@ -50,10 +51,23 @@
<p
class=
"shift_name_container"
>
Créneau :
<span
class=
"member_info member_shift"
></span></p>
<p
class=
"status_container"
>
Statut :
<span
class=
"member_info member_status"
></span></p>
<p
class=
"makeups_container"
>
Nb rattrapage(s) :
<span
class=
"member_info member_makeups"
></span></p>
<div
id=
"actions_on_member"
>
<button
class=
"btn--primary"
id=
"remove_shift_template_button"
>
Désinscrire du créneau
</button>
</div>
</div>
</div>
<div
id=
"templates"
style=
"display:none;"
></div>
<div
id=
"templates"
style=
"display:none;"
>
<div
id=
"modal_remove_shift_template"
>
<p>
Voulez vraiment désinscrire ce membre du créneau
<span
class=
"shift_template_name"
></span>
?
</p>
<div
class=
"checkbox_area"
>
<input
type=
"checkbox"
id=
"permanent_unsuscribe"
name=
"permanent_unsuscribe"
>
<label
for=
"permanent_unsuscribe"
>
Désinscription définitive
</label>
</div>
</div>
</div>
</div>
...
...
templates/members/admin/manage_shift_registrations.html
View file @
c443f682
...
...
@@ -11,6 +11,7 @@
{% block additionnal_scripts %}
<script
type=
"text/javascript"
src=
"{% static 'jquery-ui-1.12.1/jquery-ui.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/datatables.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/notify.min.js' %}?v="
></script>
{% endblock %}
{% block content %}
...
...
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