Commit ee354959 by Etienne Freiss

tickect 1330

parent 9bc66657
......@@ -77,6 +77,13 @@ class CagetteMember(models.Model):
# f = { 'cooperative_state': "delay" }
# return self.o_api.update('res.partner', [self.id], f)
# # # BDM
def save_partner_info(self, partner_id, fieldsDatas):
print(fieldsDatas)
return self.o_api.update('res.partner', partner_id, fieldsDatas)
@staticmethod
def retrieve_data_according_keys(keys, full=False):
api = OdooAPI()
......@@ -1441,3 +1448,4 @@ class CagetteUser(models.Model):
pass
return answer
......@@ -49,6 +49,9 @@ urlpatterns = [
url(r'^easy_validate_shift_presence$', views.easy_validate_shift_presence),
# conso / groupe recherche / socio
url(r'^panel_get_purchases$', views.panel_get_purchases),
# BDM
url(r'^save_partner_info$', views.save_partner_info),
# BDM - members admin
url(r'^admin$', admin.admin),
url(r'^get_makeups_members$', admin.get_makeups_members),
......
......@@ -390,3 +390,23 @@ def panel_get_purchases(request):
message += ' ' + str(res['params'])
response = HttpResponse(message)
return response
# # # BDM # # #
def save_partner_info(request):
""" Endpoint the front-end will call for saving partner information """
res = {}
credentials = CagetteMember.get_credentials(request)
if ('success' in credentials):
data = {}
for post in request.POST:
if post != "idPartner" and data != "verif_token" :
data[post]= request.POST[post]
cm = CagetteMember(int(request.POST['idPartner']))
result = cm.save_partner_info(int(request.POST['idPartner']),data)
res['success']= result
return JsonResponse(res)
else:
res['error'] = "Forbidden"
return JsonResponse(res, safe=False)
......@@ -47,6 +47,17 @@
gap: 10px;
}
.edit-btn{
cursor: pointer;
}
#edit_address_form{
display: none ;
}
#edit_phone_form{
display: none ;
}
@media screen and (max-width: 992px) {
#my_info {
font-size: 1.7rem;
......@@ -83,4 +94,6 @@
#my_info .member_shift_name_area {
align-items: flex-start;
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ function init_my_info() {
$(".attached_partner_name").text(partner_data.associated_partner_name);
}
$(".member_address").empty();
if (partner_data.street !== "") {
$(".member_address")
.append(partner_data.street + "<br/>");
......@@ -26,7 +27,7 @@ function init_my_info() {
$(".member_address_line").hide();
}
$(".member_mobile").empty();
if (partner_data.mobile !== "" && partner_data.mobile !== "False" && partner_data.mobile !== false && partner_data.mobile !== null) {
$(".member_mobile")
.append(partner_data.mobile);
......@@ -34,6 +35,7 @@ function init_my_info() {
$(".member_mobile").hide();
}
$(".member_phone").empty();
if (partner_data.phone !== "" && partner_data.phone !== "False" && partner_data.phone !== false && partner_data.phone !== null) {
$(".member_phone")
.append(partner_data.phone);
......@@ -44,4 +46,84 @@ function init_my_info() {
if ($(".member_mobile").text() === "" && $(".member_phone").text() === "") {
$(".member_phone_line").hide();
}
$('#edit_address').off('click').on('click', (e) => {
$("#street_form").val(partner_data.street);
$("#street2_form").val(partner_data.street2);
$("#city_form").val(partner_data.city);
$('#edit_address_value').hide();
$('#edit_address_form').show();
});
$('#cancel_edit_address').on('click', (e) => {
$('#edit_address_form').hide();
$('#edit_address_value').show();
});
$('#save_edit_address').off('click').on('click', (e) => {
data= [];
data['street']= $("#street_form").val();
data['street2']= $("#street2_form").val();
data['city']= $("#city_form").val();
saveInfo(data, 'address')
});
$('#edit_phone').off('click').on('click', (e) => {
$("#phone_form").val(partner_data.phone);
$("#mobile_form").val(partner_data.mobile);
$('#edit_phone_value').hide();
$('#edit_phone_form').show();
});
$('#cancel_edit_phone').off('click').on('click', (e) => {
$('#edit_phone_form').hide();
$('#edit_phone_value').show();
});
$('#save_edit_phone').off('click').on('click', (e) => {
console.log('ici');
data =[];
data['phone']= $("#phone_form").val();
data['mobile']= $("#mobile_form").val();
saveInfo(data, 'phone')
});
}
function saveInfo(data, field){
tData = '&idPartner=' + partner_data.partner_id
+ '&shift_type=' + partner_data.shift_type
+ '&verif_token=' + partner_data.verif_token
for(d in data){
tData+="&"+d+"="+data[d];
}
tUrl = '/members/save_partner_info';
$.ajax({
type: 'POST',
url: tUrl,
dataType:"json",
data: tData,
timeout: 3000,
success: function(res) {
for(d in data){
partner_data[d]=data[d]
}
init_my_info();
if(field == 'address'){
$('#edit_address_form').hide();
$('#edit_address_value').show();
}
if(field == 'phone'){
$('#edit_phone_form').hide();
$('#edit_phone_value').show();
}
},
error: function(error) {
console.log(error)
}
});
}
\ No newline at end of file
......@@ -58,17 +58,32 @@
<div class="my_info_line_left">
Adresse
</div>
<div class="my_info_line_right member_address_area">
<span class="member_address member_info"></span>
<div class="my_info_line_right member_address_area" id="edit_address_value">
<span class="member_address member_info"></span><br>
<span id="edit_address"><i class="fas fa-edit tile_icon edit-btn" ></i></span>
</div>
<div class="my_info_line_right member_address_area1" id="edit_address_form">
<input type="text" name="street_form" id="street_form" placeholder="Rue">
<input type="text" name="street2_form" id="street2_form" placeholder="Complément">
<input type="text" name="city_form" id="city_form" placeholder="Ville"> <br>
<span id="cancel_edit_address"><i class="fas fa-times tile_icon edit-btn"></i></span>
<span id="save_edit_address"><i class="fas fa-check tile_icon edit-btn"></i></span>
</div>
</div>
<div class="my_info_line member_phone_line">
<div class="my_info_line_left">
Téléphone
</div>
<div class="my_info_line_right member_phone_area">
<div class="my_info_line_right member_phone_area" id="edit_phone_value">
<span class="member_phone member_info"></span>
<span class="member_mobile member_info"></span>
<span id="edit_phone"><i class="fas fa-edit tile_icon edit-btn" ></i></span>
</div>
<div class="my_info_line_right member_phone_area1" id="edit_phone_form">
<input type="text" name="phone" id="phone_form" placeholder="Tel fixe">
<input type="text" name="mobile" id="mobile_form" placeholder="Tel mobile"><br>
<span id="cancel_edit_phone"><i class="fas fa-times tile_icon edit-btn"></i></span>
<span id="save_edit_phone"><i class="fas fa-check tile_icon edit-btn"></i></span>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment