supprimer allocation_list.pt, appel de allocation_edit.pt depuis home
This commit is contained in:
@@ -7,7 +7,6 @@ def includeme(config):
|
|||||||
# actifs
|
# actifs
|
||||||
config.add_route('actif_edit', '/actif_edit/{no_id}')
|
config.add_route('actif_edit', '/actif_edit/{no_id}')
|
||||||
config.add_route('actif2_edit', '/actif2_edit/{no_id}')
|
config.add_route('actif2_edit', '/actif2_edit/{no_id}')
|
||||||
config.add_route('allocation_list', '/allocation_list')
|
|
||||||
config.add_route('allocation_edit', '/allocation_edit/{no_cat}')
|
config.add_route('allocation_edit', '/allocation_edit/{no_cat}')
|
||||||
config.add_route('histo_list', '/histo_list')
|
config.add_route('histo_list', '/histo_list')
|
||||||
config.add_route('histo_edit', '/histo_edit/{no_id}')
|
config.add_route('histo_edit', '/histo_edit/{no_id}')
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
<metal:block use-macro="main_template">
|
|
||||||
<div metal:fill-slot="content">
|
|
||||||
|
|
||||||
<div tal:condition="message" tal:content="message" class="alert alert-danger" />
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<a href="${request.application_url}/" class="btn btn-default" role="button">
|
|
||||||
<span class="glyphicon glyphicon-chevron-left"></span> Retour</a>
|
|
||||||
<a href="allocation_edit/0" class="btn btn-success" role="button">
|
|
||||||
<span class="glyphicon glyphicon-plus"></span> Nouvelle classe</a>
|
|
||||||
</p>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-5">
|
|
||||||
<table id="allocation_list" class="table table-condensed table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Classe</th>
|
|
||||||
<th class="text-right">% cible</th>
|
|
||||||
<th class="text-center">Type</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr tal:repeat="item items">
|
|
||||||
<td class="${item.bg_color}"><a href="allocation_edit/${item.no_cat}">${item.classe}</a></td>
|
|
||||||
<td class="text-right">${item.pc_cible} %</td>
|
|
||||||
<td class="text-center">${item.type}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="text-right"><b>Total</b></td>
|
|
||||||
<td class="text-right"><b>${total} %</b></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-7">
|
|
||||||
<!-- graphique donut -->
|
|
||||||
<div id="donutchart" style="width: 100%; height: 500px;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<p><b>Notes :</b></p>
|
|
||||||
<ul>
|
|
||||||
<li>Mon allocation est inspirée de celle du <b>Dr. Bernstein's No Brainer</b> qui a, à mon avis,
|
|
||||||
le mérite d'être le plus simple à implémenter parmi les <a href="http://www.marketwatch.com/lazyportfolio" target="_blank">8 Lazy portfolios</a> suivi par Market Watch</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
google.charts.load("current", {packages:["corechart"]});
|
|
||||||
google.charts.setOnLoadCallback(drawChart);
|
|
||||||
var dataSet = ${donut_data};
|
|
||||||
|
|
||||||
function drawChart() {
|
|
||||||
var data = google.visualization.arrayToDataTable(dataSet);
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
title: 'Allocation cible',
|
|
||||||
pieHole: 0.4,
|
|
||||||
slices: {
|
|
||||||
0: {color: 'SteelBlue'}, 1: {color: 'LightSteelBlue'},
|
|
||||||
2: {color: 'Maroon'}, 3: {color: 'Brown'},
|
|
||||||
5: {offset: 0.2, color: 'DarkGreen'}, 6: {offset: 0.3, color: 'Green'},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
|
|
||||||
chart.draw(data, options);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</div><!-- content -->
|
|
||||||
</metal:block>
|
|
||||||
|
|
||||||
@@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
<div tal:condition="message" tal:content="message" class="alert alert-danger" />
|
<div tal:condition="message" tal:content="message" class="alert alert-danger" />
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="allocation_edit/0" class="btn btn-success" role="button">
|
||||||
|
<span class="glyphicon glyphicon-plus"></span> Nouvelle classe</a>
|
||||||
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<table id="categories_list" class="table table-condensed table-bordered">
|
<table id="categories_list" class="table table-condensed table-bordered">
|
||||||
@@ -18,7 +22,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr tal:repeat="item items">
|
<tr tal:repeat="item items">
|
||||||
<td class="${item.bg_color}">${item.classe}</td>
|
<td class="${item.bg_color}">${item.classe}</td>
|
||||||
<td class="text-right">${item.pc_cible} %</td>
|
<td class="text-right"><a href="allocation_edit/${item.no_cat}">${item.pc_cible} %</a></td>
|
||||||
<td class="text-right">${layout.to_percent(item.pc_atteint,1)}</td>
|
<td class="text-right">${layout.to_percent(item.pc_atteint,1)}</td>
|
||||||
<td tal:condition="(item.pc_atteint - item.pc_cible)>=0" class="text-right" style="color: green;">${layout.to_percent(item.pc_atteint - item.pc_cible,1)}</td>
|
<td tal:condition="(item.pc_atteint - item.pc_cible)>=0" class="text-right" style="color: green;">${layout.to_percent(item.pc_atteint - item.pc_cible,1)}</td>
|
||||||
<td tal:condition="(item.pc_atteint - item.pc_cible) <0" class="text-right" style="color: red;">${layout.to_percent(item.pc_atteint - item.pc_cible,1)}</td>
|
<td tal:condition="(item.pc_atteint - item.pc_cible) <0" class="text-right" style="color: red;">${layout.to_percent(item.pc_atteint - item.pc_cible,1)}</td>
|
||||||
@@ -33,7 +37,7 @@
|
|||||||
<table id="portfolio" class="table table-condensed table-bordered">
|
<table id="portfolio" class="table table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Porteffeuille</th>
|
<th>Portefeuille</th>
|
||||||
<th class="text-right">Montant</th>
|
<th class="text-right">Montant</th>
|
||||||
<th class="text-right">%</th>
|
<th class="text-right">%</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse" id="myNavbar" tal:condition="not layout.isAnonymous()">
|
<div class="collapse navbar-collapse" id="myNavbar" tal:condition="not layout.isAnonymous()">
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li><a href="${request.application_url}/allocation_list">ALLOCATION</a></li>
|
|
||||||
<li><a href="${request.application_url}/histo_list">HISTORIQUE</a></li>
|
<li><a href="${request.application_url}/histo_list">HISTORIQUE</a></li>
|
||||||
<li><a href="${request.application_url}/doc_list">DOCS</a></li>
|
<li><a href="${request.application_url}/doc_list">DOCS</a></li>
|
||||||
${panel('dropdown_menu_panel')}
|
${panel('dropdown_menu_panel')}
|
||||||
|
|||||||
@@ -150,34 +150,6 @@ def actif2_edit(request):
|
|||||||
'message': message,
|
'message': message,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='allocation_list', renderer='../templates/actifs/allocation_list.pt', permission='view')
|
|
||||||
def allocation_list(request):
|
|
||||||
message = ''
|
|
||||||
|
|
||||||
# lire les allocation
|
|
||||||
items = get_allocation(request, '0')
|
|
||||||
# calculer % total
|
|
||||||
total = 0
|
|
||||||
donut_data=[]
|
|
||||||
donut_data.append(('Allocation', 'Pourcent'))
|
|
||||||
|
|
||||||
for item in items:
|
|
||||||
# totaliser les pourcentages
|
|
||||||
total += item.pc_cible
|
|
||||||
# construire la liste pour donut
|
|
||||||
d = (item.classe, item.pc_cible)
|
|
||||||
donut_data.append(d)
|
|
||||||
|
|
||||||
if total <> 100:
|
|
||||||
message = u'Attention, le total de votre répartition cible ne fait pas 100%.'
|
|
||||||
|
|
||||||
return {
|
|
||||||
'page_title': u"Allocation cible",
|
|
||||||
'message': message,
|
|
||||||
'items': items,
|
|
||||||
'total': total,
|
|
||||||
'donut_data': json.dumps(donut_data),
|
|
||||||
}
|
|
||||||
|
|
||||||
@view_config(route_name='allocation_edit', renderer='../templates/actifs/allocation_edit.pt', permission='view')
|
@view_config(route_name='allocation_edit', renderer='../templates/actifs/allocation_edit.pt', permission='view')
|
||||||
def allocation_edit(request):
|
def allocation_edit(request):
|
||||||
@@ -217,7 +189,7 @@ def allocation_edit(request):
|
|||||||
if 'form.deleted' in request.params:
|
if 'form.deleted' in request.params:
|
||||||
delete_allocation(request, no_cat)
|
delete_allocation(request, no_cat)
|
||||||
request.session.flash(u"La fiche a été supprimée avec succès.", 'success')
|
request.session.flash(u"La fiche a été supprimée avec succès.", 'success')
|
||||||
return HTTPFound(location=request.route_url('allocation_list'))
|
return HTTPFound(location=request.route_url('home'))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': page_title,
|
'page_title': page_title,
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ def home(request):
|
|||||||
donut_actuel=[]
|
donut_actuel=[]
|
||||||
donut_actuel.append(('Allocation actuelle', 'Pourcent'))
|
donut_actuel.append(('Allocation actuelle', 'Pourcent'))
|
||||||
|
|
||||||
|
# calculer % total
|
||||||
|
total = 0
|
||||||
for item in items:
|
for item in items:
|
||||||
# construire la liste pour donut cible
|
# construire la liste pour donut cible
|
||||||
d = (item.classe, item.pc_cible)
|
d = (item.classe, item.pc_cible)
|
||||||
@@ -92,6 +94,11 @@ def home(request):
|
|||||||
# construire la liste pour donut actuel
|
# construire la liste pour donut actuel
|
||||||
d = (item.classe, int(item.pc_atteint * 10))
|
d = (item.classe, int(item.pc_atteint * 10))
|
||||||
donut_actuel.append(d)
|
donut_actuel.append(d)
|
||||||
|
# totaliser les pourcentages
|
||||||
|
total += item.pc_cible
|
||||||
|
|
||||||
|
if total <> 100:
|
||||||
|
message = u'Attention, le total de votre répartition cible est incorrect : %s.' % total
|
||||||
|
|
||||||
# lire les actifs
|
# lire les actifs
|
||||||
actifs = get_actifs(request, '0')
|
actifs = get_actifs(request, '0')
|
||||||
|
|||||||
Reference in New Issue
Block a user