Commit 92cd8f2f authored by Charlie Jacomme's avatar Charlie Jacomme

[readhesions]Creation de tout ce qui faut

parent 82a66d1f
......@@ -84,6 +84,31 @@ def search(request):
response = sock_ou_response
return response
@csrf_exempt
def search_readhesion(request):
"""Renvoie l'objet JSON résultat d'un search,
destiné à être chargé par javascript"""
if (request.method == "GET") or (request.session.get("logged", None) != "ok"):
return HttpResponse("Get the fuck out of here", status=444)
else:
try:
asked = request.POST["asked"]
except:
return HttpResponse("")
success, sock_ou_response = nk.socket_still_alive(request)
if success:
sock = sock_ou_response
flags = "ioaAhH" # dans la recherche de base on ne cherhe pas sur les alias et les historiques, mais on prend les comptes non à jour
data = [flags, ["idbde", "nom", "prenom", "pseudo", "mail"], asked]
sock.write(json.dumps(["search", data]))
out = nk.full_read(sock)["msg"]
return HttpResponse(json.dumps(out))
else:
response = sock_ou_response
return response
@csrf_exempt
def get_boutons(request):
"""Renvoie l'objet JSON résultat d'un get_boutons,
......
......@@ -70,6 +70,28 @@ class PreinscriptionForm(BaseCompteRelatedForm):
del out["idcrans"]
return out
class ReadhesionForm(forms.Form):
"""Formulaire de réadhésion"""
wei = forms.BooleanField(label="Inscription au WEI", required=False)
section = forms.CharField(label="Section", required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
# partie paiement
on_note = FrenchFloatField(label="Montant à mettre sur la note", required=False, initial=0, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
type_de_paiement = forms.ChoiceField(label="Type de paiement", choices=[("cheque", "Chèque"), ("especes", "Espèces"), ("virement", "Virement bancaire"), ("soge", "Société Générale")])
pay_nom = forms.CharField(label="Nom¹ (pour le paiement)", required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
pay_prenom = forms.CharField(label="Prénom¹ (pour le paiement)", required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
pay_banque = forms.CharField(label="Banque¹ (pour le paiement)", required=False, widget=forms.TextInput(attrs={"autocomplete" : "off"}))
def clean(self):
"""des valeurs par défaut"""
out = forms.Form.clean(self)
if out.has_key("on_note") and type(out["on_note"]) == float:
out["on_note"] = int(100 * out["on_note"])
else:
out["on_note"] = 0
if out.has_key("section") and (out["section"] == ""):
del out["section"]
return out
class InscriptionForm(CompteRelatedForm):
"""Formulaire pour inscrire un nouveau compte"""
wei = forms.BooleanField(label="Inscription au WEI", required=False)
......
......@@ -38,6 +38,8 @@ urlpatterns = patterns('note.views',
url(ur'^/comptes/(?P<idbde>[^/]*)/aliases/*$', 'aliases'),
url(ur'^/comptes/(?P<idbde>[^/]*)/aliases/delete(?P<delall>_all)?/(?P<idalias>[^/]*)/*$', 'unalias'),
url(ur'^/comptes/(?P<idbde>[^/]*)/historique_pseudo/*$', 'historique_pseudo'),
#les réadhésions
url(ur'^/readhesions/(?P<idbde>[^/]*)/*$', 'readhesions'),
# la gestion des boutons
url(ur'^/boutons/*$', 'boutons'),
url(ur'^/boutons/(?P<idbouton>[^/]*)(?P<delete>/delete)?/*$', 'boutons'),
......@@ -53,6 +55,7 @@ urlpatterns += patterns('note.ajaj',
# les pages de requêtes AJAJ
url(ur'^/quick_search/*$', 'quick_search'),
url(ur'^/search/*$', 'search'),
url(ur'^/search_readhesion/*$', 'search_readhesion'),
url(ur'^/get_boutons/*$', 'get_boutons'),
url(ur'^/get_display_info/*$', 'get_display_info'),
url(ur'^/get_photo/(?P<idbde>[^/]*)/*$', 'get_photo'),
......
......@@ -405,6 +405,45 @@ def comptes(request, sock, kwargs):
else:
return HttpResponse("Méthode invalide", status=400)
@standard_page_withignores(["idbde"])
def readhesions(request, sock, kwargs):
"""La page de recherche d'un compte ou qui l'affiche.
Dans ``kwargs`` :
* ``idbde`` si on affiche un compte
"""
idbde = kwargs["idbde"]
if request.method == "GET":
if idbde is None:
return ({}, "note/readhesions.html")
else:
variables = utilities._prepare_variables(sock, idbde, request)
form = forms.ReadhesionForm(label_suffix=" :")
variables["form"] = form
return (variables, "note/une_readhesion.html")
else:
form = forms.ReadhesionForm(request.POST, label_suffix=" :")
if form.is_valid():
readhdata = form.cleaned_data
# Il faut formater ça correctement pour l'envoyer au serveur NK
pay = {"type": readhdata["type_de_paiement"], "montant" : readhdata["on_note"],
"nom": readhdata["pay_nom"], "prenom": readhdata["pay_prenom"], "banque": readhdata["pay_banque"]}
# On vire les champs en question du dico
for champ in ["on_note", "type_de_paiement", "pay_nom", "pay_prenom", "pay_banque"]:
del readhdata[champ]
if pay["montant"] > 0 :
readhdata["pay"] = pay
readhdata["idbde"] = idbde
sock.write(json.dumps(["readherer", readhdata]))
out = nk.full_read(sock)
if nk._is_success_code(out["retcode"]):
messages.add_success(request, settings.SUCCMSG_READHESION)
return ({}, "note/readhesions.html")
else:
messages.add_error(request, out["errmsg"])
return HttpResponseRedirect("%sreadhesions/%s/" % (settings.NOTE_ROOT_URL, idbde))
@standard_page
def historique_transactions(request, sock, kwargs):
"""Page de l'historique des transactions d'un compte.
......
......@@ -8,6 +8,7 @@
**/
/* fonctions de hl et de cliquabilité des lignes du tableau de recherche */
var readhesion = false;
function ChangeColor(tableRow, highLight)
{
if (highLight)
......@@ -35,7 +36,12 @@ function request(asked, callback) {
}
};
/* On envoie la requête en POST */
if (readhesion) {
xhr.open("POST", NOTE_ROOT_URL + "search_readhesion/", true);
}
else {
xhr.open("POST", NOTE_ROOT_URL + "search/", true);
}
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("asked=" + encodeURIComponent(asked));
}
......@@ -145,7 +151,13 @@ function readData(oData) {
caze.appendChild(document.createTextNode(gotlist[i]["section"]));
ligne.appendChild(caze);
// on rend la ligne cliquable
if (readhesion) {
ligne.addEventListener("click", GoTo.bind("trapped", NOTE_ROOT_URL + "readhesions/" + gotlist[i]["idbde"] + "/"));
}
else
{
ligne.addEventListener("click", GoTo.bind("trapped", NOTE_ROOT_URL + "comptes/" + gotlist[i]["idbde"] + "/"));
}
// on ajoute la ligne au tableau
tbody.appendChild(ligne);
}
......
{% extends "note/base.html" %}
{% block title %}Comptes{% endblock %}
{% block additional_javascript %}
<script type="text/javascript" src="{{ STATIC_URL }}js/custom/getXMLHttpRequest.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/custom/liste_dynamique_search.js"></script>
<script type="text/javascript"> var readhesion = true;</script>
{% endblock %}
{% block mainstyle %}main_style{% endblock %}
{% block content %}
<div class="tabbable">
<div class="labels" >
<ul id="tab-labels">
<li><h5><a href="{{ NOTE_ROOT_URL }}readhesion/" class="default active">Réadhésion</a></h5> </li>
</ul>
</div>
<div id="tab-panels">
<div><div class="search2 search"><input type="text" name="Recherche" id="id_search_field" autocomplete="off" value="" onKeyUp="javascript:search_field_moved();return(false);" />
</div></div>
<div >
<div class="liste_comptes" >
<table id="liste_comptes" class="table-stripped">
</table>
</div>
</div>
</div>
{% endblock %}
{% extends "note/base.html" %}
{% load note_templatetags %}
{% block mainstyle %}main_style{% endblock %}
{% block title %}Compte n°{{ compte.idbde }}{% endblock %}
{% block content %}
<div class="labels" >
<ul id="tab-labels">
<li><h5><a href="{{ NOTE_ROOT_URL }}readhesions" class="default active"> Réadhesions </a></h5> </li>
</ul>
</div>
<div id="tab-panels">
<div class="forms">
{% if compte %}
{% if compte.deleted %}
<h2 class="text-error">Compte supprimé</h2>
{% else %}
<div class="photo">
<img src="{{urlphoto}}"></img>
</div>
{% endif %}
<div>
<table class="un_compte">
<caption>Compte n°{{ compte.idbde }}</caption>
<tr><td>Nom</td> <td>{{ compte.nom }}</td></tr>
<tr><td>Prénom</td> <td>{{ compte.prenom }}</td></tr>
<tr><td>Pseudo</td> <td>{{ compte.pseudo }}</td></tr>
<tr><td>Solde</td> <td>{% euro compte.solde %}</td></tr>
<tr><td>Années d'adhésion</td> <td>{{ compte.annees }}</td></tr>
</table>
</div>
{% endif %}
</div>
<form method="post" action="" class="form-horizontal">{% csrf_token %}
<legend>Réadhésion au BDE de l'ENS Cachan</legend>
{% include "note/form_contents.html" %}
</form>
</div>
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment