Commit d6cd5767 by François

Résolution conflit config cagette

parents 04f47d01 ca9333d4
Pipeline #1290 failed with stage
in 1 minute 21 seconds
...@@ -118,4 +118,18 @@ votre nom ou numéro ci-dessous ...@@ -118,4 +118,18 @@ votre nom ou numéro ci-dessous
UNSUBSCRIBED_MSG = 'Vous êtes désincrit·e, merci de remplir <a href="https://docs.google.com/forms/d/e/1FAIpQLSfPiC2PkSem9x_B5M7LKpoFNLDIz0k0V5I2W3Mra9AnqnQunw/viewform">ce formulaire</a> pour vous réinscrire sur un créneau.<br />Vous pouvez également contacter le Bureau des Membres en remplissant <a href="https://docs.google.com/forms/d/e/1FAIpQLSeZP0m5-EXPVJxEKJk6EjwSyZJtnbiGdYDuAeFI3ENsHAOikg/viewform">ce formulaire</a>' UNSUBSCRIBED_MSG = 'Vous êtes désincrit·e, merci de remplir <a href="https://docs.google.com/forms/d/e/1FAIpQLSfPiC2PkSem9x_B5M7LKpoFNLDIz0k0V5I2W3Mra9AnqnQunw/viewform">ce formulaire</a> pour vous réinscrire sur un créneau.<br />Vous pouvez également contacter le Bureau des Membres en remplissant <a href="https://docs.google.com/forms/d/e/1FAIpQLSeZP0m5-EXPVJxEKJk6EjwSyZJtnbiGdYDuAeFI3ENsHAOikg/viewform">ce formulaire</a>'
CONFIRME_PRESENT_BTN = 'Clique ici pour valider ta présence' CONFIRME_PRESENT_BTN = 'Clique ici pour valider ta présence'
RECEPTION_PB = "Ici, vous pouvez signaler toute anomalie lors d'une réception, les produits non commandés, cassés ou pourris. \
Merci d'indiquer un maximum d'informations, le nom du produit et son code barre. \
Dans le cas de produits déteriorés, merci d'envoyer une photo avec votre téléphone à [Adresse_email]"
# display or not column "Autres" in reception process
DISPLAY_COL_AUTRES = False
# Should block service exchange if old service is happening in less than 24h
BLOCK_SERVICE_EXCHANGE_24H_BEFORE = True
# URL to the metabase dashboard for orders helper
ORDERS_HELPER_METABASE_URL = "url_meta_base" ORDERS_HELPER_METABASE_URL = "url_meta_base"
# New members space
START_DATE_FOR_POINTS_HISTORY = "2018-01-01"
function init_my_shifts() {
console.log('hello my services');
/**
* if no incoming_services || no history {
* if no incoming : load incoming
* if no history : load hitstory
* } else {
* do the stuff
* }
*/
}
\ No newline at end of file
...@@ -2,4 +2,4 @@ from django.apps import AppConfig ...@@ -2,4 +2,4 @@ from django.apps import AppConfig
class MembersSpaceConfig(AppConfig): class MembersSpaceConfig(AppConfig):
name = 'members-space' name = 'members_space'
...@@ -10,3 +10,18 @@ class CagetteMembersSpace(models.Model): ...@@ -10,3 +10,18 @@ class CagetteMembersSpace(models.Model):
def __init__(self): def __init__(self):
"""Init with odoo id.""" """Init with odoo id."""
self.o_api = OdooAPI() self.o_api = OdooAPI()
def get_points_history(self, partner_id, limit, date_from):
""" Get partner points history with related shift registration if needed """
cond = [
['partner_id', '=', partner_id],
['type', '=', 'ftop'],
['create_date', '>', date_from]
]
f = ['create_date', 'create_uid', 'shift_id', 'name', 'point_qty']
# TODO get related data in service registration
return self.o_api.search_read('shift.counter.event', cond, f, limit=limit, offset=0,
order='create_date DESC')
\ No newline at end of file
#my_shifts {
font-size: 1.8rem;
}
#incoming_services {
height: 100%;
flex-direction: column;
}
.history_table {
width: 100%;
}
.history_table_header {
display: flex;
border-bottom: 1px solid #333;
}
.history_table_line {
display: flex;
}
.table_header_el {
flex: 1 0 20%;
padding: 1rem 0.5rem;
font-weight: bold;
}
.table_line_el {
flex: 1 0 20%;
padding: 1rem 0.5rem;
border-bottom: 1px solid #e7e9ed;
}
\ No newline at end of file
...@@ -24,6 +24,11 @@ body { ...@@ -24,6 +24,11 @@ body {
box-shadow: 2px 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1); box-shadow: 2px 2px 3px rgba(10,10,10,.1),0 0 0 1px rgba(10,10,10,.1);
} }
.full_width_tile {
flex: 1 0 90%;
min-height: 100px;
}
.tile_title { .tile_title {
display: flex; display: flex;
justify-content: center; justify-content: center;
...@@ -41,11 +46,11 @@ body { ...@@ -41,11 +46,11 @@ body {
display: flex; display: flex;
} }
#tile_services_exchange .tile_content { #home_tile_services_exchange .tile_content {
justify-content: center; justify-content: center;
} }
#tile_my_services .tile_content { #home_tile_my_services .tile_content {
height: 100%; height: 100%;
flex-direction: column; flex-direction: column;
} }
......
function init_my_shifts_tile() { function init_my_shifts_tile() {
if (incoming_shifts.length === 0) { if (incoming_shifts.length === 0) {
$("#tile_my_services #home_incoming_services").text("Aucun service à venir...") $("#home_tile_my_services #home_incoming_services").text("Aucun service à venir...")
} else { } else {
$("#tile_my_services #home_incoming_services").empty(); $("#home_tile_my_services #home_incoming_services").empty();
let shift_line_template = $("#shift_line_template");
let cpt = 0; let cpt = 0;
for (shift of incoming_shifts) { for (shift of incoming_shifts) {
if (cpt === 3) { if (cpt === 3) {
break; break;
} else { } else {
let datetime_shift_start = new Date(shift.date_begin); let shift_line_template = prepare_shift_line_template(shift.date_begin);
$("#home_tile_my_services #home_incoming_services").append(shift_line_template.html());
let f_date_shift_start = datetime_shift_start.toLocaleDateString("fr-fr", date_options);
f_date_shift_start = f_date_shift_start.charAt(0).toUpperCase() + f_date_shift_start.slice(1);
shift_line_template.find(".shift_line_date").text(f_date_shift_start);
shift_line_template.find(".shift_line_time").text(datetime_shift_start.toLocaleTimeString("fr-fr"));
$("#tile_my_services #home_incoming_services").append(shift_line_template.html());
cpt++; cpt++;
} }
......
/**
* Load the partner points history
*/
function load_partner_history() {
return new Promise((resolve) => {
$.ajax({
type: 'GET',
url: "/members_space/get_points_history",
data: {
partner_id: partner_data.partner_id,
verif_token: partner_data.verif_token,
limit: 10
},
dataType:"json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
partner_history = data.data;
resolve();
},
error: function(data) {
err = {msg: "erreur serveur lors de la récupération des services", ctx: 'load_partner_shifts'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'members_space.index');
closeModal();
// TODO Notify
alert('Erreur lors de la récupération de vos services.');
}
});
});
}
function init_history() {
if (incoming_shifts.length === 0) {
$("#history").empty().text("Aucun historique... pour l'instant !")
} else {
for (history_item of partner_history) {
// Prepare history lines
let history_line_template = $("#history_line_template");
// Date
let datetime_item_start = new Date(history_item.create_date);
let f_date_item_start = datetime_item_start.toLocaleDateString("fr-fr", date_options);
f_date_item_start = f_date_item_start.charAt(0).toUpperCase() + f_date_item_start.slice(1);
history_line_template.find(".table_line_date").text(f_date_item_start);
history_line_template.find(".table_line_desc").text(history_item.name);
history_line_template.find(".table_line_pts").text(history_item.point_qty);
$(".history_table_content").append(history_line_template.html());
}
}
}
function init_incoming_shifts() {
if (incoming_shifts.length === 0) {
$("#incoming_services").text("Aucun service à venir...")
} else {
$("#incoming_services").empty();
for (shift of incoming_shifts) {
let shift_line_template = prepare_shift_line_template(shift.date_begin);
$("#incoming_services").append(shift_line_template.html());
}
}
}
function init_my_shifts() {
if (incoming_shifts !== null) {
init_incoming_shifts();
} else {
load_partner_shifts(partner_data.partner_id)
.then(init_incoming_shifts);
}
if (partner_history !== null) {
init_history();
} else {
load_partner_history()
.then(init_history);
}
/**
* if no incoming_services || no history {
* if no incoming : load incoming
* if no history : load hitstory
* } else {
* do the stuff
* }
*/
}
\ No newline at end of file
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
var base_location = null, var base_location = null,
current_location = null, current_location = null,
incoming_shifts = null; incoming_shifts = null,
partner_history = null;
var date_options = {weekday: "long", year: "numeric", month: "long", day: "numeric"}; var date_options = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
...@@ -15,7 +16,7 @@ var date_options = {weekday: "long", year: "numeric", month: "long", day: "numer ...@@ -15,7 +16,7 @@ var date_options = {weekday: "long", year: "numeric", month: "long", day: "numer
* @param {int} partner_id * @param {int} partner_id
*/ */
function load_partner_shifts(partner_id) { function load_partner_shifts(partner_id) {
return new Promise((resolve, reject) => { return new Promise((resolve) => {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: "/shifts/get_list_shift_partner/" + partner_id, url: "/shifts/get_list_shift_partner/" + partner_id,
...@@ -34,7 +35,7 @@ function load_partner_shifts(partner_id) { ...@@ -34,7 +35,7 @@ function load_partner_shifts(partner_id) {
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'members-space.index'); report_JS_error(err, 'members_space.index');
closeModal(); closeModal();
// TODO Notify // TODO Notify
...@@ -67,22 +68,22 @@ function update_dom() { ...@@ -67,22 +68,22 @@ function update_dom() {
if (window.location.pathname === base_location || window.location.pathname === base_location + "home") { if (window.location.pathname === base_location || window.location.pathname === base_location + "home") {
current_location = "home"; current_location = "home";
$( "#main_content" ).load( "/members-space/homepage", update_content ); $( "#main_content" ).load( "/members_space/homepage", update_content );
$("#nav_home").addClass("active"); $("#nav_home").addClass("active");
} else if (window.location.pathname === base_location + "mes-infos") { } else if (window.location.pathname === base_location + "mes-infos") {
current_location = "my_info"; current_location = "my_info";
$( "#main_content" ).load( "/members-space/my_info", update_content ); $( "#main_content" ).load( "/members_space/my_info", update_content );
$("#nav_my_info").addClass("active"); $("#nav_my_info").addClass("active");
} else if (window.location.pathname === base_location + "mes-services") { } else if (window.location.pathname === base_location + "mes-services") {
current_location = "my_shifts"; current_location = "my_shifts";
$( "#main_content" ).load( "/members-space/my_shifts", update_content ); $( "#main_content" ).load( "/members_space/my_shifts", update_content );
$("#nav_my_shifts").addClass("active"); $("#nav_my_shifts").addClass("active");
} else if (window.location.pathname === base_location + "echange-de-services") { } else if (window.location.pathname === base_location + "echange-de-services") {
current_location = "shifts_exchange"; current_location = "shifts_exchange";
$( "#main_content" ).load( "/members-space/shifts_exchange", update_content ); $( "#main_content" ).load( "/members_space/shifts_exchange", update_content );
$("#nav_shifts_exchange").addClass("active"); $("#nav_shifts_exchange").addClass("active");
} else { } else {
$( "#main_content" ).load( "/members-space/no_content" ); $( "#main_content" ).load( "/members_space/no_content" );
} }
} }
...@@ -97,20 +98,42 @@ function update_dom() { ...@@ -97,20 +98,42 @@ function update_dom() {
case 'my_info': case 'my_info':
init_my_info(); init_my_info();
break; break;
case 'my_services': case 'my_shifts':
init_my_shifts(); init_my_shifts();
break; break;
case 'shifts_exchange': case 'shifts_exchange':
init_my_shifts(); init_shifts_exchange();
break; break;
default: default:
console.log(`Bad input`); console.log(`Bad input`);
} }
} }
/* - Shifts */
/**
* Prepare a shift line to insert into the DOM.
* Is used in: Home - My Shifts tile ; My Shifts - Incoming shifts section
*
* @param {String} date_begin beginning datetime of the shift
* @returns JQuery node object of the formatted template
*/
function prepare_shift_line_template(date_begin) {
let shift_line_template = $("#shift_line_template");
let datetime_shift_start = new Date(date_begin);
let f_date_shift_start = datetime_shift_start.toLocaleDateString("fr-fr", date_options);
f_date_shift_start = f_date_shift_start.charAt(0).toUpperCase() + f_date_shift_start.slice(1);
shift_line_template.find(".shift_line_date").text(f_date_shift_start);
shift_line_template.find(".shift_line_time").text(datetime_shift_start.toLocaleTimeString("fr-fr"));
return shift_line_template;
}
$(document).ready(function() { $(document).ready(function() {
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
base_location = (app_env === 'dev') ? '/members-space/' : '/'; base_location = (app_env === 'dev') ? '/members_space/' : '/';
update_dom(); update_dom();
}); });
...@@ -10,5 +10,6 @@ urlpatterns = [ ...@@ -10,5 +10,6 @@ urlpatterns = [
url(r'^my_shifts$', views.my_shifts), url(r'^my_shifts$', views.my_shifts),
url(r'^shifts_exchange$', views.shifts_exchange), url(r'^shifts_exchange$', views.shifts_exchange),
url(r'^no_content$', views.no_content), url(r'^no_content$', views.no_content),
url(r'^get_points_history$', views.get_points_history),
url('/*$', views.index), url('/*$', views.index),
] ]
...@@ -3,9 +3,10 @@ from outils.for_view_imports import * ...@@ -3,9 +3,10 @@ from outils.for_view_imports import *
from django.urls import reverse from django.urls import reverse
from sales.models import CagetteSales from outils.common import Verification
from members.models import CagetteMember from members.models import CagetteMember
from shifts.models import CagetteShift from shifts.models import CagetteShift
from members_space.models import CagetteMembersSpace
import hashlib import hashlib
...@@ -28,7 +29,7 @@ def index(request, exception=None): ...@@ -28,7 +29,7 @@ def index(request, exception=None):
'title': 'Espace Membre', 'title': 'Espace Membre',
'app_env': getattr(settings, 'APP_ENV', 'prod') 'app_env': getattr(settings, 'APP_ENV', 'prod')
} }
template = loader.get_template('members-space/index.html') template = loader.get_template('members_space/index.html')
if ('failure' in credentials): if ('failure' in credentials):
# Bad credentials (or none) # Bad credentials (or none)
...@@ -102,36 +103,52 @@ def index(request, exception=None): ...@@ -102,36 +103,52 @@ def index(request, exception=None):
return _get_response_according_to_credentials(request, credentials, context, template) return _get_response_according_to_credentials(request, credentials, context, template)
def home(request): def home(request):
template = loader.get_template('members-space/home.html') template = loader.get_template('members_space/home.html')
context = { context = {
'title': 'Espace Membres', 'title': 'Espace Membres',
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def my_info(request): def my_info(request):
template = loader.get_template('members-space/my_info.html') template = loader.get_template('members_space/my_info.html')
context = { context = {
'title': 'Mes Infos', 'title': 'Mes Infos',
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def my_shifts(request): def my_shifts(request):
template = loader.get_template('members-space/my_shifts.html') template = loader.get_template('members_space/my_shifts.html')
context = { context = {
'title': 'Mes Services', 'title': 'Mes Services',
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def shifts_exchange(request): def shifts_exchange(request):
template = loader.get_template('members-space/shifts_exchange.html') template = loader.get_template('members_space/shifts_exchange.html')
context = { context = {
'title': 'Échange de Services', 'title': 'Échange de Services',
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def no_content(request): def no_content(request):
template = loader.get_template('members-space/no_content.html') template = loader.get_template('members_space/no_content.html')
context = { context = {
'title': 'Contenu non trouvé', 'title': 'Contenu non trouvé',
} }
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
\ No newline at end of file
def get_points_history(request):
res = {}
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()
limit = int(request.GET.get('limit'))
date_from = getattr(settings, 'START_DATE_FOR_POINTS_HISTORY', '2018-01-01')
res["data"] = m.get_points_history(partner_id, limit, date_from)
else:
return JsonResponse(res, status=403)
return JsonResponse(res)
\ No newline at end of file
...@@ -27,3 +27,6 @@ COMPANY_NAME = "Demo interfoodcoop" ...@@ -27,3 +27,6 @@ COMPANY_NAME = "Demo interfoodcoop"
SHOP_CATEGORIES = {} SHOP_CATEGORIES = {}
EXCLUDE_SHOP_CATEGORIES = [] EXCLUDE_SHOP_CATEGORIES = []
MIN_DELAY_FOR_SLOT = 4 MIN_DELAY_FOR_SLOT = 4
# New members space
START_DATE_FOR_POINTS_HISTORY = "2018-01-01"
...@@ -337,6 +337,10 @@ ...@@ -337,6 +337,10 @@
- MEALS_PICKING_TYPE_ID = 10 - MEALS_PICKING_TYPE_ID = 10
### New members space
- START_DATE_FOR_POINTS_HISTORY = "2018-01-01"
......
...@@ -53,7 +53,7 @@ INSTALLED_APPS = ( ...@@ -53,7 +53,7 @@ INSTALLED_APPS = (
'shop', 'shop',
'shelfs', 'shelfs',
'sales', 'sales',
'members-space', 'members_space',
# 'tests' # 'tests'
) )
...@@ -101,6 +101,7 @@ STATICFILES_DIRS = ( ...@@ -101,6 +101,7 @@ STATICFILES_DIRS = (
"shop/static", "shop/static",
"shelfs/static", "shelfs/static",
"orders/static", "orders/static",
"members_space/static",
# "tests/static" # "tests/static"
) )
......
...@@ -45,7 +45,7 @@ urlpatterns = [ ...@@ -45,7 +45,7 @@ urlpatterns = [
url(r'^shop/', include('shop.urls')), url(r'^shop/', include('shop.urls')),
url(r'^shelfs/', include('shelfs.urls')), url(r'^shelfs/', include('shelfs.urls')),
url(r'^sales/', include('sales.urls')), url(r'^sales/', include('sales.urls')),
url(r'^members-space/', include('members-space.urls')), url(r'^members_space/', include('members_space.urls')),
] ]
try: try:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<h1>Mon espace membre</h1> <h1>Mon espace membre</h1>
</div> </div>
<div class="tiles_container"> <div class="tiles_container">
<div class="tile" id="tile_my_info"> <div class="tile" id="home_tile_my_info">
<div class="tile_title"> <div class="tile_title">
Mes Infos Mes Infos
</div> </div>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
À venir... À venir...
</div> </div>
</div> </div>
<div class="tile" id="tile_my_services"> <div class="tile" id="home_tile_my_services">
<div class="tile_title"> <div class="tile_title">
Mes Services Mes Services
</div> </div>
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
</div> </div>
<button type="button", class="btn btn--primary" id="home_go_to_shift_history"> <button type="button", class="btn btn--primary" id="home_go_to_shift_history">
Accéder à l'historique de mes services Accéder à mon historique
</button> </button>
</div> </div>
</div> </div>
<div class="tile" id="tile_services_exchange"> <div class="tile" id="home_tile_services_exchange">
<div class="tile_title"> <div class="tile_title">
Échange de services Échange de services
</div> </div>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</button> </button>
</div> </div>
</div> </div>
<div class="tile" id="tile_help"> <div class="tile" id="home_tile_help">
<div class="tile_title"> <div class="tile_title">
J'ai une demande J'ai une demande
</div> </div>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
{% block additionnal_css %} {% block additionnal_css %}
<link rel="stylesheet" href="{% static "css/members-space.css" %}?v="> <link rel="stylesheet" href="{% static "css/members-space.css" %}?v=">
<link rel="stylesheet" href="{% static "css/members-space-my-shifts.css" %}?v=">
{% endblock %} {% endblock %}
{% block additionnal_scripts %}{% endblock %} {% block additionnal_scripts %}{% endblock %}
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
{% block content %} {% block content %}
<div class="page_body"> <div class="page_body">
{% include "members-space/header.html" %} {% include "members_space/header.html" %}
<div id="main_content" class="page_content"> <div id="main_content" class="page_content">
</div> </div>
...@@ -22,6 +23,16 @@ ...@@ -22,6 +23,16 @@
<span class="shift_line_date"></span> - <span class="shift_line_time"></span> <span class="shift_line_date"></span> - <span class="shift_line_time"></span>
</div> </div>
</div> </div>
<div id="history_line_template">
<div class="history_table_line">
<div class="table_line_el table_line_date"></div>
<div class="table_line_el table_line_created_by"></div>
<div class="table_line_el table_line_service"></div>
<div class="table_line_el table_line_desc"></div>
<div class="table_line_el table_line_pts"></div>
</div>
</div>
</div> </div>
</div> </div>
......
<div id="my_shifts">
<div class="page_title txtcenter">
<h1>Mes Services</h1>
</div>
<div class="tiles_container">
<div class="tile full_width_tile" id="incoming_services_area">
<div class="tile_title">
À venir
</div>
<div class="tile_content" id="incoming_services"></div>
</div>
<div class="tile full_width_tile" id="history_area">
<div class="tile_title">
Historique des mouvements de points
</div>
<div class="tile_content" id="history">
<div class="history_table">
<div class="history_table_header">
<div class="table_header_el table_header_date">
Date
</div>
<div class="table_header_el table_header_created_by">
Créé par
</div>
<div class="table_header_el table_header_service">
Service ??
</div>
<div class="table_header_el table_header_desc">
Description
</div>
<div class="table_header_el table_header_pts">
Mouvement de points
</div>
</div>
<div class="history_table_content">
</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