2016-08-03 04:38:54 +02:00
{% extends "kfet/base.html" %}
2016-08-04 05:21:04 +02:00
{% load staticfiles %}
2016-08-03 04:38:54 +02:00
2016-08-12 10:03:39 +02:00
{% block title %}Nouveau compte{% endblock %}
2016-08-03 04:38:54 +02:00
{% block extra_head %}
< script src = "{% static " autocomplete_light / autocomplete . js " % } " type = "text/javascript" > < / script >
{% endblock %}
2016-08-12 10:03:39 +02:00
{% block content-header-title %}Création d'un compte{% endblock %}
2016-08-03 04:38:54 +02:00
{% block content %}
2016-08-31 02:52:13 +02:00
{% include 'kfet/base_messages.html' %}
2016-08-03 04:38:54 +02:00
2016-09-03 15:21:26 +02:00
< div class = "row form-only" >
< div class = "col-sm-12 col-md-8 col-md-offset-2" >
< div class = "content-form" >
< form action = "{% url " kfet . account . create " % } " method = "post" class = "account_create" >
{% csrf_token %}
< div >
{{ trigramme_form.trigramme.errors }}
{{ trigramme_form.trigramme }}
< / div >
< div id = "trigramme_valid" > < / div >
< input type = "text" name = "q" id = "search_autocomplete" spellcheck = "false" placeholder = "Chercher un utilisateur par nom, prénom ou identifiant clipper" class = "form-control" >
< div style = "position:relative;" >
< div id = "search_results" > < / div >
< / div >
2016-09-03 16:03:36 +02:00
< div class = "form-horizontal" >
< div id = "form-placeholder" >
{% include 'kfet/account_create_form.html' %}
< / div >
{% if not perms.kfet.add_account %}
2016-09-03 23:44:45 +02:00
{% include 'kfet/form_authentication_snippet.html' %}
2016-09-03 16:03:36 +02:00
{% endif %}
2016-09-03 15:21:26 +02:00
< / div >
< / form >
2016-09-01 05:01:59 +02:00
< / div >
2016-09-03 15:21:26 +02:00
< / div >
< / div >
2016-08-03 04:38:54 +02:00
< script type = "text/javascript" >
$(document).ready(function() {
// Affichage des résultats d'autocomplétion
$('input#search_autocomplete').yourlabsAutocomplete({
url: '{% url "kfet.account.create.autocomplete" %}',
minimumCharacters: 0,
id: 'search_autocomplete',
choiceSelector: 'li:has(a)',
container: $("#search_results"),
box: $("#search_results"),
});
// Chargement du formulaire adapté au choix sélectionné
$('input#search_autocomplete').bind(
'selectChoice',
function(e, choice, autocomplete) {
autocomplete.hide();
link = choice.find('a:first');
if (link.length & & link.attr('href') != undefined) {
$('#form-placeholder').html("").load(link.attr('href'));
}
}
);
// Vérification client de la validité
// et de ladisponibilité du trigramme choisi
$('#id_trigramme').on('input', function() {
2016-09-03 15:21:26 +02:00
var trigramme = $('#id_trigramme').val().toUpperCase();
2016-08-08 12:46:43 +02:00
var container = '#trigramme_valid';
2016-08-03 04:38:54 +02:00
2016-08-08 12:46:43 +02:00
var pattern = /^[^a-z]{3}$/;
2016-08-03 04:38:54 +02:00
if (!(trigramme.match(pattern))) {
2016-09-03 15:21:26 +02:00
$('#id_trigramme')
.css('background', '#fff')
.css('color', '#000');
2016-08-03 04:38:54 +02:00
} else {
$.ajax({
dataType: "json",
url: "{% url "kfet.account.is_validandfree.ajax" %}",
data: { trigramme: trigramme },
}).done(function(data) {
if (data['is_free']) {
2016-09-03 15:21:26 +02:00
$('#id_trigramme').css('background', '#009011');
2016-08-03 04:38:54 +02:00
} else {
2016-09-03 15:21:26 +02:00
$('#id_trigramme').css('background', '#C8102E');
2016-08-03 04:38:54 +02:00
}
2016-09-03 15:21:26 +02:00
$('#id_trigramme').css('color', '#fff');
2016-08-03 04:38:54 +02:00
});
}
});
});
< / script >
{% endblock %}