mirror of https://gitlab.crans.org/bde/nk20
75 lines
2.3 KiB
HTML
75 lines
2.3 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
{% load i18n %}
|
|
{% load render_table from django_tables2 %}
|
|
{% load pretty_money %}
|
|
{% load perms %}
|
|
|
|
{% block content %}
|
|
<input id="alias" type="text" class="form-control" placeholder="Nom/note ...">
|
|
|
|
<hr>
|
|
|
|
<div id="entry_table">
|
|
{% render_table table %}
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extrajavascript %}
|
|
<script>
|
|
old_pattern = null;
|
|
alias_obj = $("#alias");
|
|
|
|
function reloadTable(force=false) {
|
|
let pattern = alias_obj.val();
|
|
|
|
if ((pattern === old_pattern || pattern === "") && !force)
|
|
return;
|
|
|
|
$("#entry_table").load(location.href + "?search=" + pattern.replace(" ", "%20") + " #entry_table", init);
|
|
refreshBalance();
|
|
}
|
|
|
|
alias_obj.keyup(reloadTable);
|
|
|
|
$(document).ready(init);
|
|
|
|
function init() {
|
|
$(".table-row").click(function(e) {
|
|
let target = e.target.parentElement;
|
|
target = $("#" + target.id);
|
|
|
|
let type = target.attr("data-type");
|
|
let id = target.attr("data-id");
|
|
|
|
if (type === "membership") {
|
|
$.post("/api/activity/entry/?format=json", {
|
|
csrfmiddlewaretoken: CSRF_TOKEN,
|
|
activity: {{ activity.id }},
|
|
note: id,
|
|
guest: null
|
|
}).done(function () {
|
|
addMsg("Entrée effectuée !", "success");
|
|
reloadTable(true);
|
|
}).fail(function(xhr) {
|
|
errMsg(xhr.responseJSON);
|
|
});
|
|
}
|
|
else {
|
|
}
|
|
$.post("/api/activity/entry/?format=json", {
|
|
csrfmiddlewaretoken: CSRF_TOKEN,
|
|
activity: {{ activity.id }},
|
|
note: target.attr("data-inviter"),
|
|
guest: id
|
|
}).done(function () {
|
|
addMsg("Entrée effectuée !", "success");
|
|
reloadTable(true);
|
|
}).fail(function(xhr) {
|
|
errMsg(xhr.responseJSON);
|
|
});
|
|
});
|
|
}
|
|
</script>
|
|
{% endblock %}
|