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>
|
||||
Reference in New Issue
Block a user