Remaster (#38)

* setup new 'statistiques' module

* added 'graphos' package and created first test graph

* put graphos in requirements, deleted local folder

* added "load_csv" management command !

* added update of premiere_rencontre field in 'load_csv' management command

* added missing urls.py file

* added 'merge' action and view

* added 'info_completed' ratio

* linked sujets:merge views inside suivi:details

* added link to maraudes:details in notes table headers, if any

* Major reorganisation, moved 'suivi' and 'sujets' to 'notes', cleanup in 'maraudes', dropping 'website' mixins (mostly useless)

* small cleanup

* worked on Maraude and Sujet lists

* corrected missing line in notes.__init__

* restored 'details' view for maraudes and sujets insie 'notes' module

* worked on 'notes': added navigation between maraude's compte-rendu, right content in details, header to list tables

* changed queryset for CompteRenduDetailsView to all notes of same date, minor layout changes

* added right content to 'details-sujet', created 'statistiques' view and update templates

* restored 'statistiques' ajax view in 'details-sujet', fixed 'merge_two' util function

* added auto-creation of FicheStatistique (plus some tests), pagination for notes in 'details-sujet'

* added error-prone cases in paginator

* fixed non-working modals, added titles

* added UpdateStatistiques capacity in CompteRenduCreate view

* fixed missing AjaxTemplateMixin for CreateSujetView, worked on compte-rendu creation scripts

* fixed MaraudeManager.all_of() for common Maraudeurs, added color hints in planning

* re-instated statistiques module link and first test page

* added FinalizeView to send a mail before finalizing compte-rendu

* Added PieChart view for FicheStatistique fields

* small style updates, added 'age' and 'genre' fields from sujets in statistiques.PieChartView

* worked on statistiques, fixed small issues in 'notes' list views

* small theme change

* removed some dead code

* fixed notes.tests, fixed statistiques.info_completed display, added filter in SujetLisView

* added some tests

* added customised admin templates

* added authenticate in CustomAuthenticatationBackend, more verbose login thanks to messages

* added django-nose for test coverage

* Corrected raising exception on first migration

On first migration, qs.exists() would previously be called and raising an Exception, sot he migrations would fail.

* Better try block

* cleaned up custom settings.py, added some overrides of django base_settings

* corrected bad dictionnary key
This commit is contained in:
artus40
2017-06-11 17:16:17 +02:00
committed by GitHub
parent 0be59a61a7
commit be087464fc
155 changed files with 3568 additions and 1988 deletions

View File

@@ -0,0 +1,14 @@
{% extends "base_site.html" %}
{% block title %} Maraudes > {% endblock %}
{% block breadcrumbs %}
<li><a href="{% url "maraudes:index" %}">{{ date }}</a></li>
{% endblock %}
{% block sidebar %}
<div class="panel panel-default">
<div class="panel-body">
{% include "maraudes/menu.html" %}
</div>
</div>{% endblock %}

View File

@@ -0,0 +1,169 @@
{% extends "maraudes/base.html" %}
{% load bootstrap3 staticfiles %}
{% block title %} {{ block.super }} Compte-rendu du {{ object.date }} {% endblock %}
{% block breadcrumbs %}
<li><a href="{% url "maraudes:index" %}">{{ object.date }}</a></li>
<li>Compte-rendu</li>
{% endblock %}
{% block sidebar %}
{{ block.super }}
<div class="panel panel-primary">
<div class="panel-body text-right">
<h4>{% bootstrap_icon "plus" %} Création</h4>
<div class="btn-group" role="group" aria-label="...">
<button id="new-sujet" class="btn btn-default">{% bootstrap_icon "user" %} Sujet</button>
<button id="new-lieu" class="btn btn-default">{% bootstrap_icon "globe" %} Lieu</button>
</div>
<hr />
<h4>Finaliser</h4>
<div class="pull-right"><a class="btn btn-primary" href="{% url 'maraudes:finalize' maraude.pk %}">
{% bootstrap_icon "ok-circle" %} Finaliser</a></div>
</div>
</div>
{% endblock %}
{% block page_content %}
<script type="text/javascript" src="{% static "scripts/jquery.formset.js" %}"></script>
<script type="text/javascript">
/* Dynamic Formsets */
$(function() {
$.fn.onAddForm = function(row) {
// Load django_select2 fields
row.find('.django-select2').djangoSelect2();
var button = row.find('a.btn-delete')
var text = button.text()
button.html('<span class="glyphicon glyphicon-minus"></span> ' + text);
};
$.fn.onDeleteForm = function(row) {
/*
* Custom code when deleting dynamic form
*/
};
});
$(function() {
$('.dynamic-formset').formset({
prefix: '{{ inline_formset.prefix }}',
addText: 'Ajouter une personne',
deleteText: 'Supprimer',
addCssClass: 'btn btn-link btn-add',
deleteCssClass: 'btn btn-link btn-delete',
added: $.fn.onAddForm,
removed: $.fn.onDeleteForm
});
var text = $('a.btn-add').text()
$('a.btn-add').html('<span class="glyphicon glyphicon-plus"></span> ' + text)
text = $('a.btn-delete:first').text()
$('a.btn-delete').html('<span class="glyphicon glyphicon-minus"></span> ' + text);
});
</script>
<div class="row">
<div class="col-lg-7 col-md-12">
<form method="post" action="{% url 'maraudes:create' maraude.pk %}">
{% csrf_token %}
<div class="panel panel-primary panel-collapse">
<div class="panel-heading">
<h4 class="panel-title">Nouvelle rencontre</h4>
</div>
<div class="panel-body">
{% include "maraudes/compterendu_form.html" %}
</div>
<div class="panel-footer text-right">
{% bootstrap_button "Enregistrer" icon="save" button_type="submit" button_class="btn btn-success btn-sm" %}
</div>
</div>
</form>
{{ form.media.js }}{{ form.media.css }}
</div>
<div class="col-lg-5 col-md-12">
<div id="saved-rencontres">
<h4 class="page-header">Enregistrées</h4>
<table class="table table-bordered">
{% for rencontre in rencontres %}<tr><th colspan="2" class="active">{{ rencontre }}</th></tr>
{% for observation in rencontre.observations.all %}<tr>
<td>
<a href="{% url "notes:details-sujet" observation.sujet.pk %}" id="sujet-name-{{observation.sujet.pk}}">{{observation.sujet}}</a>
<a class="btn btn-link btn-xs show-stats-btn" href="#" value="{{observation.sujet.pk}}">
{% bootstrap_icon "stats" %} Mise à jour</a>
</td></tr>
<tr><td>{{observation.text}}</td></tr>{% endfor %}{% endfor %}
</table>
</div>
<div id="update-stats">
<h4 class="page-header"><span id="sujet-name"></span> <small>Fiche statistiques</small>
<div class="pull-right" id="update-buttons">
<label for="submit-form" class="btn btn-primary" id="update-stats-btn" pk="">{% bootstrap_icon "floppy-save" %} Enregistrer</label>
<span class="btn btn-primary btn-sm" id="cancel">{% bootstrap_icon "remove" %}Annuler</span>
</div></h4>
<div id="fiche-stats" class="well well-sm">
</div>
</div>
</div>
</div>
<!-- Modal and button linking -->
<div class="modal fade" id="form-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div id="form-modal-body" class="modal-body">
<div class="alert alert-warning">Content should be there...</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="{% static 'scripts/bootstrap-modal.js' %}"></script>
<script type="text/javascript">
$(function(){
function UpdateStats(pk) {
var name = $("#sujet-name-" + pk).text();
console.log("Update stats for ", pk, ":", name);
$("#fiche-stats").load("/statistiques/update/" + pk);
$("#sujet-name").text(name);
$("#saved-rencontres").hide();
$("#update-stats-btn").attr("pk", pk);
$("#update-stats").show();
};
$("#update-stats").hide();
$(".show-stats-btn").click(function(e) {
var value = $(this).attr("value");
UpdateStats(value);
});
$("#update-stats-btn").click(function(e) {
e.preventDefault();
var pk = $(this).attr("pk");
$.post("/statistiques/update/" + pk + "/", $("#update-stats-form").serialize());
$("#fiche-stats").html("");
$("#saved-rencontres").show();
$("#update-stats").hide();
});
$("#cancel").click(function() {
$("#fiche-stats").html("");
$("#saved-rencontres").show();
$("#update-stats").hide();
});
$.fn.openModalEvent('new-sujet',
'{% url "notes:create-sujet" %}?next={% url "maraudes:create" pk=maraude.pk %}',
'Nouveau sujet');
$.fn.openModalEvent('new-lieu',
'{% url "maraudes:lieu-create" %}?next={% url "maraudes:create" pk=maraude.pk %}',
'Nouveau lieu');
});
</script>
{% endblock %}

View File

@@ -0,0 +1,28 @@
{% load bootstrap3 %}{% load staticfiles %}
<div class="form-inline well well-sm text-center">
{% if form.id %}{% bootstrap_field form.id %}{% endif %}
{% bootstrap_field form.lieu layout="inline" size="small" %}
<div class="input-group">{% bootstrap_field form.heure_debut layout="inline" size="small" %}
<span class="input-group-btn">
<button id="minus-5" class="btn btn-default btn-sm" type="button"><strong>-5</strong></button>
<button id="plus-5" class="btn btn-default btn-sm" type="button"><strong>+5</strong></button>
</span>
</div>
{% bootstrap_field form.duree layout="inline" size="small" %}
</div>
<div class="form-horizontal">
{{ inline_formset.management_form }}
{% for form in inline_formset %}
<div class="dynamic-formset">
{% if form.id %}{% bootstrap_field form.id %}{% endif %}
{% bootstrap_field form.sujet size="small" layout="horizontal" %}
{% bootstrap_field form.text size="small" layout="horizontal" %}
{% if form.instance.pk %}
{% bootstrap_field form.note_ptr %}
{% bootstrap_field form.DELETE layout="horizontal" %}
{% endif %}
</div>
{% endfor %}
</div>
<script type="text/javascript" src="{% static "scripts/update_time.js" %}"></script>

View File

@@ -1,7 +0,0 @@
{% if maraude.est_terminee %}
{% include "compte_rendu/compterendu.html" %}
{% else %}
{% if perms.maraudes.can_add_compterendu %}<a class="btn btn-primary" href="{% url 'maraudes:create' maraude.pk %}">Écrire le compte-rendu</a>
{% else %} <p class="alert alert-info">Le compte-rendu n'a pas encore été écrit</p>{% endif %}
{% endif %}

View File

@@ -0,0 +1,46 @@
{% extends "maraudes/base.html" %}
{% load bootstrap3 %}
{% block title %} {{ block.super }} Compte-rendu du {{ object.date }} {% endblock %}
{% block breadcrumbs %}
<li><a href="{% url "maraudes:index" %}">{{ object.date }}</a></li>
<li>Transmission</li>
{% endblock %}
{% block page_content %}
{% if object.est_terminee %}<div class="alert alert-warning"><p>Ce compte-rendu a déjà été finalisé !</p></div>
{% else %}
<div class="col-md-12 col-lg-7">
<form method="post" action="{% url 'maraudes:finalize' maraude.pk %}">
{% csrf_token %}
<div class="panel panel-primary panel-collapse">
<div class="panel-heading">
<h4 class="panel-title">Envoyer un message</h4>
</div>
<div class="panel-body">
{% bootstrap_form form %}
</div>
<div class="panel-footer text-right">
{% bootstrap_button "Pas de message" icon="remove" button_type="link" href="?no_mail=True" button_class="btn btn-danger btn-sm" %}
{% bootstrap_button "Envoyer" icon="send" button_type="submit" button_class="btn btn-success btn-sm" %}
</div>
</div>
</form>
</div>
<div class="col-md-12 col-lg-5">
<h4 class="page-header">Rencontres</h4>
<table class="table table-bordered">
{% for rencontre in object.rencontres.all %}<tr><th colspan="2" class="active">{{ rencontre }}</th></tr>
{% for observation in rencontre.observations.all %}<tr>
<td>
<a href="{% url "notes:details-sujet" observation.sujet.pk %}" id="sujet-name-{{observation.sujet.pk}}">{{observation.sujet}}</a>
<a class="btn btn-link btn-xs" nohref onclick="UpdateStats({{observation.sujet.pk}});return false;">
{% bootstrap_icon "stats" %} Mise à jour</a>
</td></tr>
<tr><td>{{observation.text}}</td></tr>{% endfor %}{% endfor %}
</table>
</div>
{% endif %}
{% endblock %}

View File

@@ -1,5 +1,15 @@
{% extends "maraudes/base.html" %}
{% block title %} {{ block.super }} Tableau de bord {% endblock %}
{% block breadcrumbs %}
{{ block.super }}
<li>Tableau de bord</li>
{% endblock %}
{% block page_content %}
{% load tables %}
<div class="col-md-6">
<div class="col-lg-6 col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h4 class="panel-title">Votre prochaine maraude</h4>
@@ -11,24 +21,32 @@
avec {% if user.is_superuser %}{{prochaine_maraude.binome}}{%else%}{{prochaine_maraude.referent}}{%endif%}.
</strong></p>
<hr />
{% if prochaine_maraude.est_terminee %}
<a class="btn btn-sm btn-primary" href="{% url 'maraudes:details' pk=prochaine_maraude.pk %}">
Voir le compte-rendu
</a>{%else%}
<a class="btn btn-sm btn-primary" href="{% url 'maraudes:create' pk=prochaine_maraude.pk %}">
Rédiger le compte-rendu
</a>{% endif %}
{% else %}<p>Aucune maraude prévue.</p>{% endif %}
</div>
</div>
</div>
{% if user.is_superuser %}
<div class="col-md-6">
{% if derniers_sujets_rencontres %}
<div class="panel panel-warning">
<div class="panel-heading">
<h4 class="panel-title">Ces derniers temps...</h4>
</div>
{% table derniers_sujets_rencontres cols=3 cell_template="maraudes/table_cell_derniers_sujets.html" %}
</div>
{% endif %}
{% if user.is_superuser and missing_cr %}
<div class="panel panel-warning">
<div class="panel-heading">
<h4 class="panel-title">Compte-rendus en retard</h4>
</div>
{% table missing_cr cols=2 cell_template="maraudes/missing_cr_table_cell.html" %}
{% table missing_cr cols=2 cell_template="maraudes/table_cell_missing_cr.html" %}
</div>
</div>
{% endif %}
</div>
<div class="col-md-12 col-lg-6">
<h4><strong>Nouvelle note :</strong></h4>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
{% include "notes/form_appel.html" with form=appel_form %}
{% include "notes/form_signalement.html" with form=signalement_form %}
</div>
</div>
{% endblock %}

View File

@@ -1 +1,8 @@
{% include "maraudes/lieu_create_inner.html" %}
{% load bootstrap3 %}
<form class="form form-horizontal" action="{% url "maraudes:lieu-create" %}" method="post">{% csrf_token %}
{% bootstrap_form form layout="horizontal"%}
<div class="pull-right">
{% bootstrap_button "Ajouter un lieu" button_type="submit" button_class="btn btn-primary" icon="plus" %}
</div>
<input type="text" hidden=True name="next" value="{{ next }}" />
</form>

View File

@@ -1,8 +0,0 @@
{% load bootstrap3 %}
<form class="form form-horizontal" action="{% url "maraudes:lieu-create" %}" method="post">{% csrf_token %}
{% bootstrap_form form layout="horizontal"%}
<div class="pull-right">
{% bootstrap_button "Ajouter un lieu" button_type="submit" button_class="btn btn-primary" icon="plus" %}
</div>
<input type="text" hidden=True name="next" value="{{ next }}" />
</form>

View File

@@ -1,9 +0,0 @@
{% if object.est_terminee %}<a href="{% url 'maraudes:details' object.id %}" class="btn btn-link">
{% else %}<a href="#" class="btn btn-link disabled">{% endif %}
{{object.date}}</a>
<div class="pull-right">
<span class="label label-info">{{ object.binome }} & {{ object.referent }}</span>
{% if object.est_terminee %}
<span class="label label-success">{{object.rencontres.count}} rencontres</span>
{% endif %}
</div>

View File

@@ -1,32 +0,0 @@
{% load bootstrap3 %}
{% load tables %}
<div class="col-lg-10">
<div class="panel panel-primary">
<!-- Default panel contents -->
<div class="panel-heading text-center">
<h3 class="panel-title">Maraudes passées</h3>
</div>
<!-- Table -->
{% table object_list cols=3 cell_template="maraudes/list_table_cell.html" %}
{% if is_paginated %}
<div class="panel-footer text-center">
<ul class="pagination">
{% for num in page_obj.paginator.page_range %}
<li {% if page_obj.number == num %} class="active" {%endif%}><a href="?page={{num}}">{{num}}</a></li>
{%endfor%}
</ul>
</div>
{% endif %}
</div>
</div>
<div class="pull-left">
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Filtrer <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="{% url 'maraudes:liste' %}">Pas de filtre</a></li>
<li><a href="?filter=month-only">Ce mois-ci</a></li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,25 @@
{% load navbar %}
<ul class="nav nav-pills nav-stacked text-right">
<li role="presentation" {% active namespace="maraudes" viewname="index" %}>
<a href="{% url "maraudes:index" %}">Tableau de bord&nbsp;
<span class="glyphicon glyphicon-dashboard"></span>
</a>
</li>
<li role="presentation" {% active namespace="maraudes" viewname="create" %}
{% if not prochaine_maraude.date == date %} class="disabled">
<a href="#">Compte-rendu&nbsp;
<span class="glyphicon glyphicon-pencil"></span></a>
</li> {% else %}>
<a href="{% if prochaine_maraude.est_terminee %}
{% url 'notes:details-maraude' pk=prochaine_maraude.pk %}
{%else%}
{% url 'maraudes:create' pk=prochaine_maraude.pk %}
{% endif %}">Compte-rendu&nbsp;
<span class="glyphicon glyphicon-pencil"></span></a>
</li> {% endif %}
<li role="presentation" {% active namespace="maraudes" viewname="planning" %}>
<a href="{% url "maraudes:planning" %}">Planning&nbsp;
<span class="glyphicon glyphicon-calendar"></span>
</a>
</li>
</ul>

View File

@@ -1,3 +0,0 @@
<a href="{% url 'maraudes:create' pk=object.pk %}" class="btn btn-link">{{object.date}}</a>
<span class="label label-info">{{object.referent}} & {{object.binome}}</span>

View File

@@ -0,0 +1,61 @@
{% extends "maraudes/base.html" %}
{% load bootstrap3 %}
{% block title %} {{ block.super }} Planning {% endblock %}
{% block breadcrumbs %}
{{ block.super }}
<li>Planning</li>
{% endblock %}
{% block sidebar %}
{{ block.super }}
<div class="panel panel-primary text-center">
<div class="panel-body">
<label for="submit-form" class="btn btn-primary">{% bootstrap_icon "floppy-save" %} Enregistrer</label>
<hr />
<form action="" method="get" class="form-horizontal">
<strong>{% bootstrap_icon "calendar" %} Choisir une autre période : </strong>
{% bootstrap_form select_form layout='horizontal' %}
{% bootstrap_button "Choisir" button_type="submit" button_class="btn btn-primary btn-sm" %}
</form>
</div>
</div>
{% endblock %}
{% block page_content %}
<form method="post" action="{% url 'maraudes:planning' %}?month={{month}}&year={{year}}">
<input type="submit" id="submit-form" class="hidden" />
{% csrf_token %}
{{ formset.management_form }}
<table class="table table-bordered">
<tr class="active">
{% for weekday in weekdays %}<th>{{weekday}}</th>{% endfor %}
</tr>
{% for week in weeks %}
<tr>
{% for day, form in week %}
<td style="min-width:5%;" {% if form %}class="{% if form.instance.id %}success{%else%}warning{%endif%}"{% endif %}>{% if day %}{% if form %}
<div class="row">
<div class="col-lg-2">{% endif %}
<strong>{{ day }}</strong>
{% if form %}</div>
<div class="col-lg-10">
{% bootstrap_field form.id %}
{% bootstrap_field form.date %}
{% bootstrap_field form.heure_debut layout="inline" size="small" %}
</div>
</div>
<div class="form-horizontal">
{% bootstrap_field form.binome layout="horizontal" size="small" show_label=False %}
{% bootstrap_field form.referent layout="horizontal" size="small" show_label=False %}
</div>
{% endif %}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</form>
{% endblock %}

View File

@@ -0,0 +1 @@
<a href="{% url "notes:details-sujet" object.pk %}">{{ object }}</a>

View File

@@ -0,0 +1 @@
<a class="btn btn-sm btn-primary" href="{% url "maraudes:create" pk=object.pk %}"><span class="glyphicon glyphicon-pencil"></span> {{ object }}</a>