Adding the core applications code to the repository
This commit is contained in:
29
maraudes/templates/compte_rendu/compterendu.html
Normal file
29
maraudes/templates/compte_rendu/compterendu.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="panel panel-primary">
|
||||
<!-- Default panel contents -->
|
||||
<div class="panel-heading"><h3 class="panel-title">Compte-Rendu</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p class="bg-info">Maraudeurs: {{ maraude.binome.first_name }}, {{ maraude.referent.first_name }}</p>
|
||||
{% if maraude.est_terminee %}<p>Terminée à {{ maraude.heure_fin}} </p>
|
||||
<p>{{maraude.rencontre_count}} rencontres</p>
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
<table class="table table-bordered table-striped">
|
||||
{% for rencontre, observations in maraude %}
|
||||
<tr>
|
||||
<th>{{ rencontre.lieu }}</th>
|
||||
<th>{{ rencontre.heure_debut }}</th>
|
||||
<th style="text-align:right" width="150">Durée: {{ rencontre.duree }}min</th>
|
||||
</tr>
|
||||
{% for observation in observations %}
|
||||
<tr><td>{{ observation.sujet }}</td><td colspan="2"> {{ observation.note }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% if user.is_superuser and maraude.est_terminee %}<div class="panel-footer">
|
||||
<a class="btn btn-primary" href="{% url 'maraudes:update' maraude.pk %}">Modifier</a>
|
||||
</div>{%endif%}
|
||||
</div>
|
||||
144
maraudes/templates/compte_rendu/compterendu_create.html
Normal file
144
maraudes/templates/compte_rendu/compterendu_create.html
Normal file
@@ -0,0 +1,144 @@
|
||||
{% load bootstrap3 %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{{ form.media.js }}{{ form.media.css }}
|
||||
<script type="text/javascript" src="{% static "jquery.formset.js" %}"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$.fn.onAddForm = function(row) {
|
||||
/*
|
||||
* Custom code to integrate with django-select2 and bootstrap3
|
||||
*/
|
||||
// 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);
|
||||
});
|
||||
|
||||
|
||||
/* Lier les boutons de création
|
||||
* Thanks to Derek Morgan, https://dmorgan.info/posts/django-views-bootstrap-modals/
|
||||
*/
|
||||
$(function() {
|
||||
|
||||
var formAjaxSubmit = function(form, modal) {
|
||||
$(form).submit(function (e) {
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
type: $(this).attr('method'),
|
||||
url: $(this).attr('action'),
|
||||
data: $(this).serialize(),
|
||||
success: function (xhr, ajaxOptions, thrownError) {
|
||||
if ( $(xhr).find('.has-error').length > 0 ) {
|
||||
$(modal).find('.modal-body').html(xhr);
|
||||
formAjaxSubmit(form, modal);
|
||||
} else {
|
||||
$(modal).modal('toggle');
|
||||
// Reload page ?
|
||||
}
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
// handle response errors here
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
/* TODO: Use formAjaxSubmit above, but reload page on form success */
|
||||
$('#new-sujet').click(function() {
|
||||
$('#form-modal-body').load('{% url "sujets:create" %}?next={% url "maraudes:create" pk=maraude.id %}', function () {
|
||||
$('.modal-title').text("Nouveau sujet");
|
||||
$('#form-modal').modal('toggle');
|
||||
});
|
||||
});
|
||||
$('#new-lieu').click(function() {
|
||||
$('#form-modal-body').load('{% url "maraudes:lieu-create" %}?next={% url "maraudes:create" pk=maraude.id %}', function () {
|
||||
$('.modal-title').text("Nouveau lieu");
|
||||
$('#form-modal').modal('toggle');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<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">×</button>
|
||||
<h4 class="modal-title">Modal title</h4>
|
||||
</div>
|
||||
<div id="form-modal-body" class="modal-body">
|
||||
...
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sd-12">
|
||||
<form method="post" action="{% url 'maraudes:create' maraude.pk %}?finalize=False">
|
||||
{% csrf_token %}
|
||||
<div class="panel panel-default panel-collapse">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-header">Nouvelle rencontre
|
||||
{% bootstrap_button "Enregistrer" icon="save" button_type="submit" button_class="btn btn-success btn-sm pull-right" %}
|
||||
</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% include "compte_rendu/compterendu_form.html" %}
|
||||
</div>
|
||||
<div class="panel-footer text-right">
|
||||
<div class="btn-group">
|
||||
<a class= "btn btn-primary" id="new-sujet">
|
||||
{% bootstrap_icon "user" %} Nouveau sujet</a>
|
||||
<a class="btn btn-primary" id="new-lieu">
|
||||
{% bootstrap_icon "globe" %} Nouveau lieu</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 col-sd-12">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading"><h4 class="panel-header">Enregistrées
|
||||
<a class="btn btn-danger btn-sm pull-right" href="{% url 'maraudes:create' maraude.pk %}?finalize=True">
|
||||
{% bootstrap_icon "ok-circle" %} Finaliser</a></h4>
|
||||
</div>
|
||||
<table class="table">
|
||||
{% for rencontre in rencontres %}<tr><th colspan="2" class="active">{{ rencontre }}</th></tr>
|
||||
{% for observation in rencontre.observations.all %}<tr>
|
||||
<td>{{observation.sujet}}</td>
|
||||
<td>{{observation.text}}</td>
|
||||
</tr>{% endfor %}{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
62
maraudes/templates/compte_rendu/compterendu_form.html
Normal file
62
maraudes/templates/compte_rendu/compterendu_form.html
Normal file
@@ -0,0 +1,62 @@
|
||||
{% load bootstrap3 %}
|
||||
<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 }}
|
||||
{{ inline_formset.media.js }}
|
||||
{{ inline_formset.media.css }}
|
||||
{% for form in inline_formset %}
|
||||
<div class="dynamic-formset">
|
||||
{% if form.id %}{% bootstrap_field form.id %}{% endif %}
|
||||
{% if form.instance.pk %}{% bootstrap_field form.note_ptr %}{% endif %}
|
||||
|
||||
{% bootstrap_field form.sujet size="small" layout="horizontal" %}
|
||||
{% if inline_formset.instance.pk %}
|
||||
{% bootstrap_field form.DELETE layout="horizontal" %}
|
||||
{% endif %}
|
||||
{% bootstrap_field form.text size="small" layout="horizontal" %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
|
||||
var input = $('#id_heure_debut')
|
||||
var min_value = input.attr('value').split(":")
|
||||
|
||||
$.fn.editHeureValue = function(mod) {
|
||||
var input = $('#id_heure_debut');
|
||||
var value = input.attr('value').split(":");
|
||||
value[1] = parseInt(value[1]) + mod;
|
||||
|
||||
do_change = true
|
||||
for (i=0; i < 3; i++){
|
||||
if (value[i] < min_value[i]){
|
||||
do_change = false
|
||||
};
|
||||
};
|
||||
new_value = value.join(":");
|
||||
if (do_change){
|
||||
input.attr('value', new_value);
|
||||
};
|
||||
};
|
||||
|
||||
$('#minus-5').click(function() {
|
||||
$.fn.editHeureValue(-5)
|
||||
console.log('minus 5')
|
||||
});
|
||||
$('#plus-5').click(function() {
|
||||
$.fn.editHeureValue(5)
|
||||
console.log('plus 5')
|
||||
});
|
||||
});
|
||||
</script>
|
||||
21
maraudes/templates/compte_rendu/compterendu_update.html
Normal file
21
maraudes/templates/compte_rendu/compterendu_update.html
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
{% load bootstrap3 %}
|
||||
<form method="post" action="{% url 'maraudes:update' maraude.pk %}?continue=True">
|
||||
{% csrf_token %}
|
||||
{{ base_formset.management_form }}
|
||||
{% for form, inline_formset in forms %}
|
||||
<div class="col-md-6 col-sd-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading text-right">
|
||||
{% bootstrap_field form.DELETE field_class="col-md-1"%}
|
||||
<button type="submit" class="btn btn-sm btn-success" formaction="{% url 'maraudes:update' maraude.pk %}?continue=False">
|
||||
{% bootstrap_icon "refresh" %} Mettre à jour</button>
|
||||
{% bootstrap_button "Enregistrer et quitter" button_type="submit" button_class="btn-primary btn-sm" icon="ok-circle" %}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% include "compte_rendu/compterendu_form.html" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</form>
|
||||
6
maraudes/templates/maraudes/details.html
Normal file
6
maraudes/templates/maraudes/details.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% if maraude.est_terminee %}
|
||||
{% include "compte_rendu/compterendu.html" with maraude=compte_rendu %}
|
||||
{% else %}
|
||||
{% if user.is_superuser %}<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 %}
|
||||
45
maraudes/templates/maraudes/index.html
Normal file
45
maraudes/templates/maraudes/index.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6" id="prochaine-maraudes">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">Votre prochaine maraude</div>
|
||||
<div class="panel-body">
|
||||
{% if prochaine_maraude %}<p>
|
||||
<span class="glyphicon glyphicon-calendar"></span>
|
||||
<strong>{{ prochaine_maraude.date }} à {{ prochaine_maraude.heure_debut }}
|
||||
avec {% if user.is_superuser %}{{prochaine_maraude.binome}}{%else%}{{prochaine_maraude.referent}}{%endif%}.
|
||||
</strong></p>
|
||||
<hr />
|
||||
<p><mark>Informations, notes, rendez-vous ?</mark></p>
|
||||
{% else %}<p>Aucune maraude prévue.</p>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if dernieres_maraudes %}<div class="col-md-6" id="dernieres-maraudes">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<p>Dernières maraudes
|
||||
<span class="pull-right"><a href="{% url 'maraudes:liste' %}" class="btn btn-primary btn-sm">Aller à la liste</a></span></p>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
{% for maraude in dernieres_maraudes %}
|
||||
<a href="{% url 'maraudes:details' maraude.pk %}" class="list-group-item">
|
||||
<strong>{{ maraude }}</strong> <small>{{maraude.binome}} & {{maraude.referent}}</small>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>{% endif %}
|
||||
|
||||
{% if user.is_superuser %}<div class="col-md-6" id="administration">
|
||||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">Administration</div>
|
||||
<div class="list-group">
|
||||
<a href="{% url 'maraudes:planning' %}" class="list-group-item">Planning</a>
|
||||
<a href="{% url 'admin:maraudes_maraude_changelist' %}" class="list-group-item">Gérer les maraudes</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
1
maraudes/templates/maraudes/lieu_create.html
Normal file
1
maraudes/templates/maraudes/lieu_create.html
Normal file
@@ -0,0 +1 @@
|
||||
{% include "maraudes/lieu_create_inner.html" %}
|
||||
8
maraudes/templates/maraudes/lieu_create_inner.html
Normal file
8
maraudes/templates/maraudes/lieu_create_inner.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% load bootstrap3 %}
|
||||
<div class="row"><div class="col-md-12">
|
||||
<form action="{% url "maraudes:lieu-create" %}" method="post">{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
{% bootstrap_button "Ajouter un lieu" button_type="submit" button_class="btn btn-primary" icon="plus" %}
|
||||
<input type="text" hidden=True name="next" value="{{ next }}" />
|
||||
</form>
|
||||
</div></div>
|
||||
49
maraudes/templates/maraudes/list.html
Normal file
49
maraudes/templates/maraudes/list.html
Normal file
@@ -0,0 +1,49 @@
|
||||
{% load bootstrap3 %}
|
||||
<div class="panel panel-default">
|
||||
<!-- Default panel contents -->
|
||||
<div class="panel-heading text-center">
|
||||
<form action="" method="GET">
|
||||
<label>TODO : Filtrer par date, terminée/non, et autres ?</label>
|
||||
<button class="btn btn-warning" type="submit">Filtrer</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>Maraudes</th>
|
||||
</tr>
|
||||
{% for maraude in object_list %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="btn-group" role="group">
|
||||
{% if maraude.est_terminee %}
|
||||
<a href="{% url 'maraudes:details' maraude.id %}" class="btn btn-primary">
|
||||
{% elif user.is_superuser %}
|
||||
<a href="{% url 'maraudes:create' maraude.id %}" class="btn btn-warning">
|
||||
{% else %}
|
||||
<a href="#" class="btn btn-default disabled">
|
||||
{% endif %}
|
||||
{{maraude.date}}
|
||||
{% if user.is_superuser %}
|
||||
</a><a class="btn btn-danger" href="/admin/maraudes/maraude/{{maraude.id}}/change/">{% bootstrap_icon "edit" %}
|
||||
{% endif %}</a></div>
|
||||
<div class="pull-right">
|
||||
<span class="label label-info">{{ maraude.binome }} & {{ maraude.referent }}</span>
|
||||
<span class="label label-success">{{maraude.rencontres.count}} rencontres</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
</div>
|
||||
{% if is_paginated %}
|
||||
<div class="col-md-12 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 %}
|
||||
16
maraudes/templates/maraudes/menu.html
Normal file
16
maraudes/templates/maraudes/menu.html
Normal file
@@ -0,0 +1,16 @@
|
||||
{% if dernieres_maraudes %}<div class="panel panel-default">
|
||||
<div class="panel-heading">Maraudes</div>
|
||||
<div class="list-group">
|
||||
{% for maraude in dernieres_maraudes %}
|
||||
<a href="{% url 'maraudes:details' maraude.pk %}" class="list-group-item">{{ maraude }}</a>
|
||||
{% endfor %}
|
||||
<a href="{% url 'maraudes:liste' %}" class="list-group-item"><b>Autres...</b></a>
|
||||
</div>
|
||||
</div>{% endif %}
|
||||
|
||||
{% if user.is_superuser %}<div class="panel panel-default">
|
||||
<div class="panel-heading">Administration</div>
|
||||
<div class="list-group">
|
||||
<a href="{% url 'maraudes:planning' %}" class="list-group-item">Planning</a>
|
||||
</div>
|
||||
</div>{% endif %}
|
||||
30
maraudes/templates/planning/planning.html
Normal file
30
maraudes/templates/planning/planning.html
Normal file
@@ -0,0 +1,30 @@
|
||||
{% load bootstrap3 %}
|
||||
<div class="well col-md-12">
|
||||
<form action="" method="get" class="form-inline text-center">
|
||||
<label>Période : </label>
|
||||
{% bootstrap_form select_form layout='inline' %}
|
||||
{% bootstrap_button "Choisir" button_type="submit" %}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{% url 'maraudes:planning' %}?month={{month}}&year={{year}}">
|
||||
{% csrf_token %}
|
||||
{{ formset.management_form }}
|
||||
{% for form in formset %}<div class="col-md-4">
|
||||
<div class="panel {% if form.instance.pk %}panel-info{%else%}panel-warning{%endif%}">
|
||||
<div class="panel-heading text-center">
|
||||
<div class="form-inline">{% if form.id %}{{ form.id }}{% endif %}
|
||||
{% bootstrap_field form.date size="small" show_label=False %}
|
||||
{% bootstrap_field form.heure_debut layout="inline" size="small" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-horizontal">
|
||||
{% bootstrap_field form.binome layout="horizontal" %}
|
||||
{% bootstrap_field form.referent layout="horizontal" size="small" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>{% endfor %}
|
||||
{% bootstrap_button "Enregistrer" button_type="submit" button_class="btn-primary" %}
|
||||
</form>
|
||||
Reference in New Issue
Block a user