mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 09:12:11 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			123 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			123 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{% extends "base.html" %}
 | 
						|
{% comment %}
 | 
						|
SPDX-License-Identifier: GPL-3.0-or-later
 | 
						|
{% endcomment %}
 | 
						|
{% load i18n perms %}
 | 
						|
{% load render_table from django_tables2 %}
 | 
						|
{% load static django_tables2 i18n %}
 | 
						|
 | 
						|
{% block content %}
 | 
						|
<h1 class="text-white">{{ title }}</h1>
 | 
						|
{% include "activity/includes/activity_info.html" %}
 | 
						|
 | 
						|
{% if activity.activity_type.manage_entries and ".change__opener"|has_perm:activity %}
 | 
						|
    <div class="card bg-white mb-3">
 | 
						|
        <h3 class="card-header text-center">
 | 
						|
            {% trans "Openers" %}
 | 
						|
        </h3>
 | 
						|
        <div class="card-body">
 | 
						|
            <form class="input-group" method="POST" id="form_opener">
 | 
						|
                {% csrf_token %}
 | 
						|
                <input type="hidden" name="activity" value="{{ object.pk }}">
 | 
						|
                {%include "autocomplete_model.html" %}
 | 
						|
                <div class="input-group-append">
 | 
						|
                    <input type="submit" class="btn btn-success" value="{% trans "Add" %}">
 | 
						|
                </div>
 | 
						|
            </form>
 | 
						|
        </div>
 | 
						|
        {% render_table opener %}
 | 
						|
    </div>
 | 
						|
{% endif %}
 | 
						|
 | 
						|
{% if guests.data %}
 | 
						|
<div class="card bg-white mb-3">
 | 
						|
    <h3 class="card-header text-center">
 | 
						|
        {% trans "Guests list" %}
 | 
						|
    </h3>
 | 
						|
    <div id="guests_table">
 | 
						|
        {% render_table guests %}
 | 
						|
    </div>
 | 
						|
    <div class="card-footer text-center">
 | 
						|
        <button class="btn btn-block btn-primary mb-3" onclick="window.location.href='?_export=1&table=guests'">
 | 
						|
            {% trans "Export to CSV" %}
 | 
						|
        </button>
 | 
						|
    </div>
 | 
						|
</div>
 | 
						|
{% endif %}
 | 
						|
{% endblock %}
 | 
						|
 | 
						|
{% block extrajavascript %}
 | 
						|
<script src="{% static "activity/js/opener.js" %}"></script>
 | 
						|
<script src="{% static "js/autocomplete_model.js" %}"></script>
 | 
						|
<script>
 | 
						|
    function remove_guest(guest_id) {
 | 
						|
        $.ajax({
 | 
						|
         url:"/api/activity/guest/" + guest_id + "/",
 | 
						|
         method:"DELETE",
 | 
						|
         headers: {"X-CSRFTOKEN": CSRF_TOKEN}
 | 
						|
     })
 | 
						|
      .done(function() {
 | 
						|
          addMsg('{% trans "Guest deleted" %}', 'success');
 | 
						|
          $("#guests_table").load(location.pathname + " #guests_table");
 | 
						|
      })
 | 
						|
      .fail(function(xhr, textStatus, error) {
 | 
						|
          errMsg(xhr.responseJSON);
 | 
						|
      });
 | 
						|
    }
 | 
						|
 | 
						|
    $("#open_activity").click(function() {
 | 
						|
        $.ajax({
 | 
						|
            url: "/api/activity/activity/{{ activity.pk }}/",
 | 
						|
            type: "PATCH",
 | 
						|
            dataType: "json",
 | 
						|
            headers: {
 | 
						|
                "X-CSRFTOKEN": CSRF_TOKEN
 | 
						|
            },
 | 
						|
            data: {
 | 
						|
                open: {{ activity.open|yesno:'false,true' }}
 | 
						|
            }
 | 
						|
        }).done(function () {
 | 
						|
            reloadWithTurbolinks();
 | 
						|
        }).fail(function (xhr) {
 | 
						|
            errMsg(xhr.responseJSON);
 | 
						|
        });
 | 
						|
    });
 | 
						|
 | 
						|
    $("#validate_activity").click(function () {
 | 
						|
        $.ajax({
 | 
						|
            url: "/api/activity/activity/{{ activity.pk }}/",
 | 
						|
            type: "PATCH",
 | 
						|
            dataType: "json",
 | 
						|
            headers: {
 | 
						|
                "X-CSRFTOKEN": CSRF_TOKEN
 | 
						|
            },
 | 
						|
            data: {
 | 
						|
                valid: {{ activity.valid|yesno:'false,true' }}
 | 
						|
            }
 | 
						|
        }).done(function () {
 | 
						|
            reloadWithTurbolinks();
 | 
						|
        }).fail(function (xhr) {
 | 
						|
            errMsg(xhr.responseJSON);
 | 
						|
        });
 | 
						|
    });
 | 
						|
    $("#delete_activity").click(function () {
 | 
						|
        if (!confirm("{% trans 'Are you sure you want to delete this activity?' %}")) {
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        $.ajax({
 | 
						|
            url: "/api/activity/activity/{{ activity.pk }}/",
 | 
						|
            type: "DELETE",
 | 
						|
            headers: {
 | 
						|
                "X-CSRFTOKEN": CSRF_TOKEN
 | 
						|
            }
 | 
						|
        }).done(function () {
 | 
						|
            addMsg("{% trans 'Activity deleted' %}", "success");
 | 
						|
            window.location.href = "/activity/";  // Redirige vers la liste des activités
 | 
						|
        }).fail(function (xhr) {
 | 
						|
            errMsg(xhr.responseJSON);
 | 
						|
        });
 | 
						|
    });
 | 
						|
</script>
 | 
						|
{% endblock %}
 |