Débugs et structures d'accueil

This commit is contained in:
Evarin 2017-04-27 03:06:51 +02:00
parent 1dbe2aeb0e
commit d36652d16a
4 changed files with 34 additions and 21 deletions

View file

@ -16,7 +16,7 @@ class LieuResource(ModelResource):
class Meta: class Meta:
queryset = Lieu.objects.all() queryset = Lieu.objects.all()
resource_name = "lieu" resource_name = "lieu"
fields = ["nom", "pays", "coord", "type_lieu", "id"] fields = ["nom", "ville", "pays", "coord", "type_lieu", "id"]
authentication = SessionAuthentication() authentication = SessionAuthentication()
def build_filters(self, filters=None, **kwargs): def build_filters(self, filters=None, **kwargs):

View file

@ -124,6 +124,7 @@ function SelectLieuWidget(STATIC_ROOT, API_LIEU, target, callback) {
break; break;
case "country": case "country":
data.pays = obj.short_name; data.pays = obj.short_name;
data.pays_nom = obj.long_name;
break; break;
} }
} }
@ -180,7 +181,7 @@ function SelectLieuWidget(STATIC_ROOT, API_LIEU, target, callback) {
data.marqueur = marqueur; data.marqueur = marqueur;
var desc = $("<div>").append($("<h3>").text(data.nom)) var desc = $("<div>").append($("<h3>").text(data.nom))
.append($("<p>").text(data.ville+", "+data.pays)); .append($("<p>").text(data.ville+", "+data.pays_nom));
var activeBtn = $("<a>", {href:"javascript:void(0);"}) var activeBtn = $("<a>", {href:"javascript:void(0);"})
.prop("_lieustage_data", data) .prop("_lieustage_data", data)
.on("click", choixLieuStage); .on("click", choixLieuStage);

View file

@ -79,7 +79,8 @@
}); });
</script> </script>
{% endif %} {% endif %}
<p><a href="{% url "avisstage:profil" object.auteur.user.username %}">{{ object.auteur.nom }}</a> a fait ce {{ object.get_type_stage_display|lower }} du {{ object.date_debut }} au {{ object.date_fin }}, supervisé par {{ object.encadrants }}</p> <p><a href="{% url "avisstage:profil" object.auteur.user.username %}">{{ object.auteur.nom }}</a> a fait ce {{ object.get_type_stage_display|lower }}
du {{ object.date_debut }} au {{ object.date_fin }}{% if object.structure %}, au sein de {{ object.structure }}{% endif %}{% if object.encadrants %}, supervisé par {{ object.encadrants }}{% endif %}.</p>
<ul class="infos"> <ul class="infos">
{% for matiere in object.matieres.all %} {% for matiere in object.matieres.all %}
<li class="matiere">{{ matiere.nom }}</li> <li class="matiere">{{ matiere.nom }}</li>

View file

@ -5,9 +5,9 @@
<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyDd4innPShfHcW8KDJB833vZHZSsqt-ACw"></script> <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyDd4innPShfHcW8KDJB833vZHZSsqt-ACw"></script>
<script type="text/javascript" src="{% static "js/leaflet.js" %}"></script> <script type="text/javascript" src="{% static "js/leaflet.js" %}"></script>
<script type="text/javascript" src="{% static "js/leaflet-gplaces-autocomplete.js" %}"></script> <script type="text/javascript" src="{% static "js/leaflet-gplaces-autocomplete.js" %}"></script>
<script type="text/javascript" src="//maps.stamen.com/js/tile.stamen.js?v1.3.0"></script>
<script type="text/javascript" src="{% static "jquery-autosuggest/js/jquery.autoSuggest.minified.js" %}"> </script> <script type="text/javascript" src="{% static "jquery-autosuggest/js/jquery.autoSuggest.minified.js" %}"> </script>
<link rel="stylesheet" type="text/css" href="{% static "css/leaflet.css" %}" /> <link rel="stylesheet" type="text/css" href="{% static "css/leaflet.css" %}" />
<script type="text/javascript" src="{% static "js/tile.stamen.js" %}"></script>
<script type="text/javascript" src="{% static "js/tinymce/tinymce.min.js" %}"></script> <script type="text/javascript" src="{% static "js/tinymce/tinymce.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/select_lieu.js" %}"></script> <script type="text/javascript" src="{% static "js/select_lieu.js" %}"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -17,21 +17,26 @@
$(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' }); $(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });
// RICH TEXT FIELDS // RICH TEXT FIELDS
var txtr = $("textarea.tinymce"); var rich_texts = [];
function initRichTexts(selector) {
var txtr = $(selector+" textarea.tinymce");
$.each(txtr, function(i, item) { $.each(txtr, function(i, item) {
var newitem = $("<div>", {"class":"tinymce"}).html(item.value) var newitem = $("<div>", {"class":"tinymce"}).html(item.value)
item.fakeinput = newitem; item.fakeinput = newitem;
item.style.display = "none"; item.style.display = "none";
$(item).parent().append(newitem); $(item).parent().append(newitem);
rich_texts.push(item);
}); });
tinyMCE.init({ tinyMCE.init({
selector: "div.tinymce", selector: selector+" div.tinymce",
menubar: false, menubar: false,
plugins: "paste,searchreplace,lists,autolink,link", plugins: "paste,searchreplace,lists,autolink,link",
toolbar: 'undo redo | bold italic underline strikethrough | bullist numlist outdent indent | link', toolbar: 'undo redo | bold italic underline strikethrough | bullist numlist outdent indent | link',
inline: true, inline: true,
language: "fr_FR", language: "fr_FR",
}); });
};
// SELECT MULTIPLE FIELDS // SELECT MULTIPLE FIELDS
var slts = $("select[multiple]"); var slts = $("select[multiple]");
@ -103,7 +108,9 @@
// Créer un nouveau lieu // Créer un nouveau lieu
var cnt = $("#id_lieux-TOTAL_FORMS"); var cnt = $("#id_lieux-TOTAL_FORMS");
var i_form = cnt.val()*1; var i_form = cnt.val()*1;
dest_form = $("<div>").html(avis_lieu_template.replace(/__prefix__/g, i_form)); var idform = "avis-lieux-"+i_form;
dest_form = $("<div>", {id: idform, class:"avis_lieu"})
.html(avis_lieu_template.replace(/__prefix__/g, i_form));
dest_btn = $("<a>", {href:"javascript:void(0);", dest_btn = $("<a>", {href:"javascript:void(0);",
class:"lieu-change", class:"lieu-change",
id:"change-lieux-"+i_form}) id:"change-lieux-"+i_form})
@ -112,6 +119,7 @@
cnt.val(i_form+1); cnt.val(i_form+1);
$("#avis_lieu_container").append(dest_form); $("#avis_lieu_container").append(dest_form);
initRichTexts("#"+idform);
} else { } else {
// Changer un lieu existant // Changer un lieu existant
dest_form = $("#avis-lieux-"+lieu_focus); dest_form = $("#avis-lieux-"+lieu_focus);
@ -126,9 +134,12 @@
} }
// TODO gérer le cas de l'actualisation du formulaire où le lieu affiché n'est plus le vrai lieu // TODO gérer le cas de l'actualisation du formulaire où le lieu affiché n'est plus le vrai lieu
initRichTexts("");
// CLEANUP ON SENDING // CLEANUP ON SENDING
$("#stageform").submit(function() { $("#stageform").submit(function() {
$.each(txtr, function(i, item) { $.each(rich_texts, function(i, item) {
item.value = tinyMCE.get(item.fakeinput.attr("id")).getContent(); item.value = tinyMCE.get(item.fakeinput.attr("id")).getContent();
}); });
$.each(slts, function(i, item) { $.each(slts, function(i, item) {