1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 16:02:25 +00:00
nk20/templates/activity/activity_entry.html

75 lines
2.3 KiB
HTML
Raw Normal View History

2020-03-28 00:45:13 +00:00
{% 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 ...">
2020-03-28 12:38:31 +00:00
<hr>
2020-03-28 00:45:13 +00:00
<div id="entry_table">
{% render_table table %}
</div>
{% endblock %}
{% block extrajavascript %}
<script>
old_pattern = null;
alias_obj = $("#alias");
2020-03-28 12:38:31 +00:00
function reloadTable(force=false) {
2020-03-28 00:45:13 +00:00
let pattern = alias_obj.val();
2020-03-28 12:38:31 +00:00
if ((pattern === old_pattern || pattern === "") && !force)
2020-03-28 00:45:13 +00:00
return;
2020-03-28 12:38:31 +00:00
$("#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);
});
});
}
2020-03-28 00:45:13 +00:00
</script>
{% endblock %}