Commit efa1ddd9 by Damien Moulard

display associated partner for main partner + pairs info under header

parent 24616d3f
...@@ -799,6 +799,20 @@ class CagetteMember(models.Model): ...@@ -799,6 +799,20 @@ class CagetteMember(models.Model):
res['error'] = str(e) res['error'] = str(e)
return res return res
def search_associated_people(self):
""" Search for an associated partner """
res = {}
c = [["parent_id", "=", self.id]]
f = ["id", "name", "barcode_base"]
res = self.o_api.search_read('res.partner', c, f)
try:
return res[0]
except:
return None
class CagetteMembers(models.Model): class CagetteMembers(models.Model):
"""Class to manage operations on all members or part of them.""" """Class to manage operations on all members or part of them."""
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
display: none; display: none;
} }
.pairs_info {
background-color: #00a573;
color: white;
padding: 1.5rem 1.2rem;
}
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
/* When the screen is less than 768 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */ /* When the screen is less than 768 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
.topnav a:not(:first-child) {display: none;} .topnav a:not(:first-child) {display: none;}
......
...@@ -41,13 +41,6 @@ ...@@ -41,13 +41,6 @@
flex-direction: column; flex-direction: column;
} }
.pairs_info {
background-color: #00a573;
color: white;
padding: 1.5rem 1.2rem;
margin: 2rem 0;
}
.member_phone_area { .member_phone_area {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
......
...@@ -183,7 +183,8 @@ body { ...@@ -183,7 +183,8 @@ body {
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
.member_shift_name_area, .member_shift_name_area,
.member_coop_number_area { .member_coop_number_area,
.member_associated_partner_area {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
......
...@@ -47,4 +47,8 @@ $(document).ready(function() { ...@@ -47,4 +47,8 @@ $(document).ready(function() {
$('#nav_calendar').on('click', () => { $('#nav_calendar').on('click', () => {
toggleHeader(); toggleHeader();
}); });
if (partner_data.is_associated_people !== "True") {
$(".pairs_info").hide();
}
}); });
...@@ -97,6 +97,18 @@ function init_home() { ...@@ -97,6 +97,18 @@ function init_home() {
}); });
$("#go_to_forms").prop("href", forms_link); $("#go_to_forms").prop("href", forms_link);
if (partner_data.is_in_association === false) {
$("#home .member_associated_partner_area").hide();
} else {
if (partner_data.is_associated_people === "True") {
$(".member_associated_partner").text(partner_data.parent_name);
} else if (partner_data.associated_partner_id !== "False") {
$(".member_associated_partner").text(partner_data.associated_partner_name);
}
}
// TODO vérif tile my info avec données binomes + rattrapage et délai
// Init my info tile // Init my info tile
init_my_info_data(); init_my_info_data();
......
...@@ -3,10 +3,14 @@ function init_my_info() { ...@@ -3,10 +3,14 @@ function init_my_info() {
$(".member_email").text(partner_data.email); $(".member_email").text(partner_data.email);
if (partner_data.is_associated_people === "False") { if (partner_data.is_in_association === false) {
$("#attached_info_area").hide(); $("#attached_info_area").hide();
} else { }
if (partner_data.is_associated_people === "True") {
$(".attached_partner_name").text(partner_data.parent_name); $(".attached_partner_name").text(partner_data.parent_name);
} else if (partner_data.associated_partner_id !== "False") {
$(".attached_partner_name").text(partner_data.associated_partner_name);
} }
if (partner_data.street !== "") { if (partner_data.street !== "") {
......
...@@ -15,7 +15,7 @@ const possible_cooperative_state = { ...@@ -15,7 +15,7 @@ const possible_cooperative_state = {
exempted: "Exempté.e", exempted: "Exempté.e",
alert: "En alerte", alert: "En alerte",
up_to_date: "À jour", up_to_date: "À jour",
unsubscribed: "Désinscrit.e", unsubscribed: "Désinscrit.e des créneaux",
delay: "En délai" delay: "En délai"
}; };
...@@ -147,15 +147,14 @@ function prepare_shift_line_template(date_begin) { ...@@ -147,15 +147,14 @@ function prepare_shift_line_template(date_begin) {
function init_my_info_data() { function init_my_info_data() {
$(".choose_makeups").off(); $(".choose_makeups").off();
$(".unsuscribed_form_link").off(); $(".unsuscribed_form_link").off();
console.log(partner_data);
$(".member_shift_name").text(partner_data.regular_shift_name); $(".member_shift_name").text(partner_data.regular_shift_name);
console.log(partner_data);
let pns = partner_data.name.split(" - "); let pns = partner_data.name.split(" - ");
let name = pns.length > 1 ? pns[1] : pns[0]; let name = pns.length > 1 ? pns[1] : pns[0];
$(".member_name").text(name);
// Status related // Status related
$(".member_name").text(name);
$(".member_status") $(".member_status")
.text(possible_cooperative_state[partner_data.cooperative_state]) .text(possible_cooperative_state[partner_data.cooperative_state])
.addClass("member_status_" + partner_data.cooperative_state); .addClass("member_status_" + partner_data.cooperative_state);
...@@ -219,6 +218,13 @@ $(document).ready(function() { ...@@ -219,6 +218,13 @@ $(document).ready(function() {
? partner_data.parent_id ? partner_data.parent_id
: partner_data.partner_id; : partner_data.partner_id;
partner_data.is_in_association =
partner_data.is_associated_people === "True" || partner_data.associated_partner_id !== "False";
// For associated people, their parent name is attached in their display name
let partner_name_split = partner_data.name.split(', ');
partner_data.name = partner_name_split[partner_name_split.length - 1];
base_location = (app_env === 'dev') ? '/members_space/' : '/'; base_location = (app_env === 'dev') ? '/members_space/' : '/';
update_dom(); update_dom();
......
...@@ -76,6 +76,7 @@ def index(request, exception=None): ...@@ -76,6 +76,7 @@ def index(request, exception=None):
partner_id = credentials['id'] partner_id = credentials['id']
cs = CagetteShift() cs = CagetteShift()
partnerData = cs.get_data_partner(partner_id) partnerData = cs.get_data_partner(partner_id)
if 'create_date' in partnerData: if 'create_date' in partnerData:
...@@ -89,12 +90,23 @@ def index(request, exception=None): ...@@ -89,12 +90,23 @@ def index(request, exception=None):
except: except:
pass pass
# look for parent for associated partner
if partnerData["parent_id"] is not False: if partnerData["parent_id"] is not False:
partnerData["parent_name"] = partnerData["parent_id"][1] partnerData["parent_name"] = partnerData["parent_id"][1]
partnerData["parent_id"] = partnerData["parent_id"][0] partnerData["parent_id"] = partnerData["parent_id"][0]
else: else:
partnerData["parent_name"] = False partnerData["parent_name"] = False
# look for associated partner for parents
cm = CagetteMember(partner_id)
associated_partner = cm.search_associated_people()
partnerData["associated_partner_id"] = False if associated_partner is None else associated_partner["id"]
partnerData["associated_partner_name"] = False if associated_partner is None else associated_partner["name"]
if (associated_partner is not None and partnerData["associated_partner_name"].find(str(associated_partner["barcode_base"])) == -1):
partnerData["associated_partner_name"] = str(associated_partner["barcode_base"]) + ' - ' + partnerData["associated_partner_name"]
partnerData['can_have_delay'] = cs.member_can_have_delay(int(partner_id)) partnerData['can_have_delay'] = cs.member_can_have_delay(int(partner_id))
context['partnerData'] = partnerData context['partnerData'] = partnerData
......
...@@ -24,6 +24,14 @@ ...@@ -24,6 +24,14 @@
<i class="fa fa-bars"></i> <i class="fa fa-bars"></i>
</a> </a>
</div> </div>
<div class="pairs_info">
<span>
<i class="fas fa-exclamation-circle"></i> Je suis en binôme.
Toutes les actions (changement de service, choix d'un rattrapage...)
ne sont faisables que sur l'espace membre du <b>binôme principal</b>.
Dans mon espace membre, les infos ne sont visibles qu'en lecture seule.
</span>
</div>
<script type="text/javascript" src="{% static 'js/members-space-header.js' %}"></script> <script type="text/javascript" src="{% static 'js/members-space-header.js' %}"></script>
{% endblock %} {% endblock %}
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
<span>Mon numéro de coop : </span> <span>Mon numéro de coop : </span>
<span class="member_coop_number member_info"></span> <span class="member_coop_number member_info"></span>
</div> </div>
<div class="member_associated_partner_area">
<span>Je suis en binôme avec : </span>
<span class="member_associated_partner member_info"></span>
</div>
</div> </div>
<div id="see_more_info"> <div id="see_more_info">
<a href="#" id="see_more_info_link">Voir plus ></a> <a href="#" id="see_more_info_link">Voir plus ></a>
......
...@@ -99,6 +99,8 @@ ...@@ -99,6 +99,8 @@
"is_associated_people" : "{{partnerData.is_associated_people}}", "is_associated_people" : "{{partnerData.is_associated_people}}",
"parent_id" : "{{partnerData.parent_id}}", "parent_id" : "{{partnerData.parent_id}}",
"parent_name" : "{{partnerData.parent_name}}", "parent_name" : "{{partnerData.parent_name}}",
"associated_partner_id" : "{{partnerData.associated_partner_id}}",
"associated_partner_name" : "{{partnerData.associated_partner_name}}",
"verif_token" : "{{partnerData.verif_token}}", "verif_token" : "{{partnerData.verif_token}}",
} }
</script> </script>
......
...@@ -86,16 +86,6 @@ ...@@ -86,16 +86,6 @@
<span class="attached_partner_name member_info"></span> <span class="attached_partner_name member_info"></span>
</div> </div>
</div> </div>
<div class="my_info_line pairs_info">
<span>
Attention : Toutes les actions (changement de service, choix d'un rattrapage...)
ne sont faisables que sur l'espace membre du <b>binôme principal</b>.
</span>
<br>
<span>
Dans mon espace membre, les infos ne sont visibles qu'en lecture seule.
</span>
</div>
</div> </div>
</div> </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