Commit f6c1a2be by Damien Moulard

display info for attached members

parent f8e05261
/* We override styles defined on the home page for the specific needs of the My Info page */ /* We override some styles defined on the home page for the specific needs of the My Info page */
#my_info { #my_info {
font-size: 2rem; font-size: 2rem;
} }
#my_info { #my_info_content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.my_info_line { .my_info_line {
display: flex; display: flex;
flex-wrap: wrap;
width: 100%; width: 100%;
padding: 1.5rem 0; padding: 1.5rem 0;
} }
...@@ -24,6 +25,8 @@ ...@@ -24,6 +25,8 @@
.my_info_line_right { .my_info_line_right {
width: 50%; width: 50%;
padding-left: 2rem; padding-left: 2rem;
max-width: 100%;
word-break: break-all;
} }
#my_info #member_status_action, #my_info #member_status_action,
...@@ -32,9 +35,16 @@ ...@@ -32,9 +35,16 @@
margin-bottom: 0; margin-bottom: 0;
} }
.member_email { #attached_info {
max-width: 100%; display: flex;
word-break: break-all; flex-direction: column;
}
.pairs_info {
background-color: #00a573;
color: white;
padding: 1.5rem 1.2rem;
margin: 2rem 0;
} }
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
...@@ -50,6 +60,16 @@ ...@@ -50,6 +60,16 @@
padding-left: 1rem; padding-left: 1rem;
} }
#attached_info .my_info_line_left {
width: 100%;
text-align: left;
padding: 0;
}
#attached_info .my_info_line_right {
width: 100%;
padding: 0;
}
#my_info .choose_makeups, #my_info .choose_makeups,
#my_info .unsuscribed_form_link { #my_info .unsuscribed_form_link {
white-space: normal; white-space: normal;
......
...@@ -93,7 +93,7 @@ function init_home() { ...@@ -93,7 +93,7 @@ function init_home() {
if (incoming_shifts !== null) { if (incoming_shifts !== null) {
init_my_shifts_tile(); init_my_shifts_tile();
} else { } else {
load_partner_shifts(partner_data.partner_id) load_partner_shifts(partner_data.concerned_partner_id)
.then(init_my_shifts_tile); .then(init_my_shifts_tile);
} }
} }
\ No newline at end of file
function init_my_info() { function init_my_info() {
init_my_info_data(); init_my_info_data();
console.log(partner_data);
$(".member_email").text(partner_data.email); $(".member_email").text(partner_data.email);
if (partner_data.is_associated_people === "False") {
$("#attached_info_area").hide();
} else {
$(".attached_partner_name").text(partner_data.parent_name);
}
if (partner_data.street !== "") { if (partner_data.street !== "") {
$(".member_address") $(".member_address")
.append(partner_data.street + "<br/>"); .append(partner_data.street + "<br/>");
......
...@@ -11,7 +11,7 @@ function load_partner_history(offset = 0) { ...@@ -11,7 +11,7 @@ function load_partner_history(offset = 0) {
type: 'GET', type: 'GET',
url: "/members_space/get_points_history", url: "/members_space/get_points_history",
data: { data: {
partner_id: partner_data.partner_id, partner_id: partner_data.concerned_partner_id,
verif_token: partner_data.verif_token, verif_token: partner_data.verif_token,
limit: history_items_limit, limit: history_items_limit,
offset: offset offset: offset
...@@ -173,7 +173,7 @@ function init_my_shifts() { ...@@ -173,7 +173,7 @@ function init_my_shifts() {
if (incoming_shifts !== null) { if (incoming_shifts !== null) {
init_incoming_shifts(); init_incoming_shifts();
} else { } else {
load_partner_shifts(partner_data.partner_id) load_partner_shifts(partner_data.concerned_partner_id)
.then(init_incoming_shifts); .then(init_incoming_shifts);
} }
......
function init_shifts_exchange() { function init_shifts_exchange() {
console.log('hello my services'); console.log('hello my services');
// TODO : block everything if is_associated_people
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ var date_options = {weekday: "long", year: "numeric", month: "long", day: "numer ...@@ -13,7 +13,7 @@ var date_options = {weekday: "long", year: "numeric", month: "long", day: "numer
/** /**
* Load the shifts the member is registered to * Load the shifts the member is registered to
* @param {int} partner_id * @param {int} partner_id either the members id, or its parent's if s.he's attached
*/ */
function load_partner_shifts(partner_id) { function load_partner_shifts(partner_id) {
return new Promise((resolve) => { return new Promise((resolve) => {
...@@ -167,7 +167,7 @@ function init_my_info_data() { ...@@ -167,7 +167,7 @@ function init_my_info_data() {
}); });
} }
if (partner_data.makeups_to_do > 0) { if (partner_data.makeups_to_do > 0 && partner_data.is_associated_people === "False") {
$(".choose_makeups").show(); $(".choose_makeups").show();
if ( if (
...@@ -189,13 +189,18 @@ function init_my_info_data() { ...@@ -189,13 +189,18 @@ function init_my_info_data() {
} }
} }
// TODO coop number for attached people ??
$(".member_coop_number").text(partner_data.barcode_base); $(".member_coop_number").text(partner_data.barcode_base);
} }
$(document).ready(function() { $(document).ready(function() {
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
// If partner is associated (attached), display the pair's main partner shift data
partner_data.concerned_partner_id =
(partner_data.is_associated_people === "True")
? partner_data.parent_id
: partner_data.partner_id;
base_location = (app_env === 'dev') ? '/members_space/' : '/'; base_location = (app_env === 'dev') ? '/members_space/' : '/';
update_dom(); update_dom();
......
...@@ -91,6 +91,13 @@ def index(request, exception=None): ...@@ -91,6 +91,13 @@ def index(request, exception=None):
context['partnerData'] = partnerData context['partnerData'] = partnerData
# TODO test with partner who's not attached
if partnerData["parent_id"] is not False:
partnerData["parent_name"] = partnerData["parent_id"][1]
partnerData["parent_id"] = partnerData["parent_id"][0]
else:
partnerData["parent_name"] = False
# Days to hide in the calendar # Days to hide in the calendar
days_to_hide = "0" days_to_hide = "0"
context['ADDITIONAL_INFO_SHIFT_PAGE'] = getattr(settings, 'ADDITIONAL_INFO_SHIFT_PAGE', '') context['ADDITIONAL_INFO_SHIFT_PAGE'] = getattr(settings, 'ADDITIONAL_INFO_SHIFT_PAGE', '')
...@@ -142,7 +149,6 @@ def get_points_history(request): ...@@ -142,7 +149,6 @@ def get_points_history(request):
res = {} res = {}
partner_id = int(request.GET.get('partner_id')) partner_id = int(request.GET.get('partner_id'))
if 'verif_token' in request.GET and Verification.verif_token(request.GET.get('verif_token'), partner_id) is True:
m = CagetteMembersSpace() m = CagetteMembersSpace()
limit = int(request.GET.get('limit')) limit = int(request.GET.get('limit'))
...@@ -150,7 +156,4 @@ def get_points_history(request): ...@@ -150,7 +156,4 @@ def get_points_history(request):
date_from = getattr(settings, 'START_DATE_FOR_POINTS_HISTORY', '2018-01-01') date_from = getattr(settings, 'START_DATE_FOR_POINTS_HISTORY', '2018-01-01')
res["data"] = m.get_points_history(partner_id, limit, offset, date_from) res["data"] = m.get_points_history(partner_id, limit, offset, date_from)
else:
return JsonResponse(res, status=403)
return JsonResponse(res) return JsonResponse(res)
\ No newline at end of file
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
"email" : "{{partnerData.email}}", "email" : "{{partnerData.email}}",
"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}}",
} }
</script> </script>
<script src="{% static "js/all_common.js" %}?v="></script> <script src="{% static "js/all_common.js" %}?v="></script>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</div> </div>
<div class="tiles_container"> <div class="tiles_container">
<div class="tile full_width_tile" id="my_info_area"> <div class="tile full_width_tile" id="my_info_area">
<div class="tile_content" id="my_info"> <div class="tile_content" id="my_info_content">
<div class="my_info_line"> <div class="my_info_line">
<div class="my_info_line_left"> <div class="my_info_line_left">
Statut Statut
...@@ -76,5 +76,30 @@ ...@@ -76,5 +76,30 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tile full_width_tile" id="attached_info_area">
<div class="tile_title">
Mon Binôme
</div>
<div class="tile_content" id="attached_info">
<div class="my_info_line attached_partne_name_line">
<div class="my_info_line_left">
Je suis en binôme avec :
</div>
<div class="my_info_line_right attached_partne_name_area">
<span class="attached_partner_name member_info"></span>
</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>
\ No newline at end of file
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