mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	Reorder templates
This commit is contained in:
		
							
								
								
									
										75
									
								
								apps/activity/templates/activity/activity_detail.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								apps/activity/templates/activity/activity_detail.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% load static %}
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load render_table from django_tables2 %}
 | 
			
		||||
{% load pretty_money %}
 | 
			
		||||
{% load perms %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
 | 
			
		||||
    {% include "activity/activity_info.html" %}
 | 
			
		||||
 | 
			
		||||
    {% if guests.data %}
 | 
			
		||||
        <hr>
 | 
			
		||||
        <h2>{% trans "Guests list" %}</h2>
 | 
			
		||||
        <div id="guests_table">
 | 
			
		||||
            {% render_table guests %}
 | 
			
		||||
        </div>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block extrajavascript %}
 | 
			
		||||
<script>
 | 
			
		||||
    function remove_guest(guest_id) {
 | 
			
		||||
        $.ajax({
 | 
			
		||||
         url:"/api/activity/guest/" + guest_id + "/",
 | 
			
		||||
         method:"DELETE",
 | 
			
		||||
         headers: {"X-CSRFTOKEN": CSRF_TOKEN}
 | 
			
		||||
     })
 | 
			
		||||
      .done(function() {
 | 
			
		||||
          addMsg('Invité supprimé','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);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
							
								
								
									
										152
									
								
								apps/activity/templates/activity/activity_entry.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								apps/activity/templates/activity/activity_entry.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,152 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% load static %}
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load render_table from django_tables2 %}
 | 
			
		||||
{% load pretty_money %}
 | 
			
		||||
{% load perms %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <div class="row">
 | 
			
		||||
        <div class="col-xl-12">
 | 
			
		||||
            <div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
 | 
			
		||||
                <a href="{% url "note:transfer" %}#transfer" class="btn btn-sm btn-outline-primary">
 | 
			
		||||
                    {% trans "Transfer" %}
 | 
			
		||||
                </a>
 | 
			
		||||
                {% if "note.notespecial"|not_empty_model_list %}
 | 
			
		||||
                    <a href="{% url "note:transfer" %}#credit" class="btn btn-sm btn-outline-primary">
 | 
			
		||||
                        {% trans "Credit" %}
 | 
			
		||||
                    </a>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
                {% for a in activities_open %}
 | 
			
		||||
                    <a href="{% url "activity:activity_entry" pk=a.pk %}" class="btn btn-sm btn-outline-primary{% if a.pk == activity.pk %} active{% endif %}">
 | 
			
		||||
                        {% trans "Entries" %} {{ a.name }}
 | 
			
		||||
                    </a>
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <a href="{% url "activity:activity_detail" pk=activity.pk %}">
 | 
			
		||||
        <button class="btn btn-light">{% trans "Return to activity page" %}</button>
 | 
			
		||||
    </a>
 | 
			
		||||
 | 
			
		||||
    <input id="alias" type="text" class="form-control" placeholder="Nom/note ...">
 | 
			
		||||
 | 
			
		||||
    <hr>
 | 
			
		||||
 | 
			
		||||
    <div id="entry_table">
 | 
			
		||||
        <h2 class="text-center">{{ entries.count }} {% if entries.count >= 2 %}{% trans "entries" %}{% else %}{% trans "entry" %}{% endif %}</h2>
 | 
			
		||||
        {% 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.pathname + "?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");
 | 
			
		||||
                let last_name = target.attr("data-last-name");
 | 
			
		||||
                let first_name = target.attr("data-first-name");
 | 
			
		||||
 | 
			
		||||
                if (type === "membership") {
 | 
			
		||||
                    $.post("/api/activity/entry/?format=json", {
 | 
			
		||||
                        csrfmiddlewaretoken: CSRF_TOKEN,
 | 
			
		||||
                        activity: {{ activity.id }},
 | 
			
		||||
                        note: id,
 | 
			
		||||
                        guest: null
 | 
			
		||||
                    }).done(function () {
 | 
			
		||||
                        if (target.hasClass("table-info"))
 | 
			
		||||
                            addMsg("Entrée effectuée, mais attention : la personne n'est plus adhérente Kfet.", "warning", 10000);
 | 
			
		||||
                        else
 | 
			
		||||
                            addMsg("Entrée effectuée !", "success", 4000);
 | 
			
		||||
                        reloadTable(true);
 | 
			
		||||
                    }).fail(function(xhr) {
 | 
			
		||||
                        errMsg(xhr.responseJSON, 4000);
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    let line_obj = $("#buttons_guest_" + id);
 | 
			
		||||
                    if (line_obj.length || target.attr('class').includes("table-success")) {
 | 
			
		||||
                        line_obj.remove();
 | 
			
		||||
                        return;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    let tr = "<tr class='text-center'>" +
 | 
			
		||||
                        "<td id='buttons_guest_" + id + "' style='table-danger center' colspan='5'>" +
 | 
			
		||||
                        "<button id='transaction_guest_" + id + "' class='btn btn-secondary'>Payer avec la note de l'hôte</button> " +
 | 
			
		||||
                        "<button id='transaction_guest_" + id + "_especes' class='btn btn-secondary'>Payer en espèces</button> " +
 | 
			
		||||
                        "<button id='transaction_guest_" + id + "_cb' class='btn btn-secondary'>Payer en CB</button></td>" +
 | 
			
		||||
                        "<tr>";
 | 
			
		||||
                    $(tr).insertAfter(target);
 | 
			
		||||
 | 
			
		||||
                    let makeTransaction = function() {
 | 
			
		||||
                        $.post("/api/activity/entry/?format=json", {
 | 
			
		||||
                            csrfmiddlewaretoken: CSRF_TOKEN,
 | 
			
		||||
                            activity: {{ activity.id }},
 | 
			
		||||
                            note: target.attr("data-inviter"),
 | 
			
		||||
                            guest: id
 | 
			
		||||
                        }).done(function () {
 | 
			
		||||
                            if (target.hasClass("table-info"))
 | 
			
		||||
                                addMsg("Entrée effectuée, mais attention : la personne n'est plus adhérente Kfet.", "warning", 10000);
 | 
			
		||||
                            else
 | 
			
		||||
                                addMsg("Entrée effectuée !", "success", 4000);
 | 
			
		||||
                            reloadTable(true);
 | 
			
		||||
                        }).fail(function (xhr) {
 | 
			
		||||
                            errMsg(xhr.responseJSON, 4000);
 | 
			
		||||
                        });
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    let credit = function(credit_id, credit_name) {
 | 
			
		||||
                        return function() {
 | 
			
		||||
                            $.post("/api/note/transaction/transaction/",
 | 
			
		||||
                                {
 | 
			
		||||
                                    "csrfmiddlewaretoken": CSRF_TOKEN,
 | 
			
		||||
                                    "quantity": 1,
 | 
			
		||||
                                    "amount": {{ activity.activity_type.guest_entry_fee }},
 | 
			
		||||
                                    "reason": "Crédit " + credit_name + " (invitation {{ activity.name }})",
 | 
			
		||||
                                    "valid": true,
 | 
			
		||||
                                    "polymorphic_ctype": {{ notespecial_ctype }},
 | 
			
		||||
                                    "resourcetype": "SpecialTransaction",
 | 
			
		||||
                                    "source": credit_id,
 | 
			
		||||
                                    "destination": target.attr('data-inviter'),
 | 
			
		||||
                                    "last_name": last_name,
 | 
			
		||||
                                    "first_name": first_name,
 | 
			
		||||
                                    "bank": ""
 | 
			
		||||
                                }).done(function () {
 | 
			
		||||
                                makeTransaction();
 | 
			
		||||
                                reset();
 | 
			
		||||
                            }).fail(function (xhr) {
 | 
			
		||||
                                errMsg(xhr.responseJSON, 4000);
 | 
			
		||||
                            });
 | 
			
		||||
                        };
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    $("#transaction_guest_" + id).click(makeTransaction);
 | 
			
		||||
                    $("#transaction_guest_" + id + "_especes").click(credit(1, "espèces"));
 | 
			
		||||
                    $("#transaction_guest_" + id + "_cb").click(credit(2, "carte bancaire"));
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    </script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
							
								
								
									
										11
									
								
								apps/activity/templates/activity/activity_form.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								apps/activity/templates/activity/activity_form.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% load static %}
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load crispy_forms_tags %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
<form method="post">
 | 
			
		||||
{% csrf_token %}
 | 
			
		||||
{{form|crispy}}
 | 
			
		||||
<button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
 | 
			
		||||
</form>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
							
								
								
									
										78
									
								
								apps/activity/templates/activity/activity_info.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								apps/activity/templates/activity/activity_info.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
{% load perms %}
 | 
			
		||||
{% load pretty_money %}
 | 
			
		||||
 | 
			
		||||
{% url 'activity:activity_detail' activity.pk as activity_detail_url %}
 | 
			
		||||
 | 
			
		||||
<div id="activity_info" class="card bg-light shadow">
 | 
			
		||||
    <div class="card-header text-center">
 | 
			
		||||
        <h4>
 | 
			
		||||
            {% if request.path_info != activity_detail_url %}
 | 
			
		||||
                <a href="{{ activity_detail_url }}">{{ activity.name }}</a>
 | 
			
		||||
            {% else %}
 | 
			
		||||
                {{ activity.name }}
 | 
			
		||||
            {% endif %}
 | 
			
		||||
        </h4>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="card-body" id="profile_infos">
 | 
			
		||||
        <dl class="row">
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'description'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6"> {{ activity.description }}</dd>
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'type'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6"> {{ activity.activity_type }}</dd>
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'start date'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6">{{ activity.date_start }}</dd>
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'end date'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6">{{ activity.date_end }}</dd>
 | 
			
		||||
 | 
			
		||||
            {% if ".view_"|has_perm:activity.creater %}
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'creater'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6"><a href="{% url "member:user_detail" pk=activity.creater.pk %}">{{ activity.creater }}</a></dd>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'organizer'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6"><a href="{% url "member:club_detail" pk=activity.organizer.pk %}">{{ activity.organizer }}</a></dd>
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'attendees club'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6"><a href="{% url "member:club_detail" pk=activity.attendees_club.pk %}">{{ activity.attendees_club }}</a></dd>
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'can invite'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6">{{ activity.activity_type.can_invite|yesno }}</dd>
 | 
			
		||||
 | 
			
		||||
            {% if activity.activity_type.can_invite %}
 | 
			
		||||
                <dt class="col-xl-6">{% trans 'guest entry fee'|capfirst %}</dt>
 | 
			
		||||
                <dd class="col-xl-6">{{ activity.activity_type.guest_entry_fee|pretty_money }}</dd>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'valid'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6">{{ activity.valid|yesno }}</dd>
 | 
			
		||||
 | 
			
		||||
            <dt class="col-xl-6">{% trans 'opened'|capfirst %}</dt>
 | 
			
		||||
            <dd class="col-xl-6">{{ activity.open|yesno }}</dd>
 | 
			
		||||
        </dl>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <div class="card-footer text-center">
 | 
			
		||||
        {% if activity.open and activity.activity_type.manage_entries and ".change__open"|has_perm:activity %}
 | 
			
		||||
            <a class="btn btn-warning btn-sm my-1" href="{% url 'activity:activity_entry' pk=activity.pk %}"> {% trans "Entry page" %}</a>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
 | 
			
		||||
        {% if request.path_info == activity_detail_url %}
 | 
			
		||||
            {% if activity.valid and ".change__open"|has_perm:activity %}
 | 
			
		||||
                <a class="btn btn-warning btn-sm my-1" id="open_activity"> {% if activity.open %}{% trans "close"|capfirst %}{% else %}{% trans "open"|capfirst %}{% endif %}</a>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
            {% if not activity.open and ".change__valid"|has_perm:activity %}
 | 
			
		||||
                <a class="btn btn-success btn-sm my-1" id="validate_activity"> {% if activity.valid %}{% trans "invalidate"|capfirst %}{% else %}{% trans "validate"|capfirst %}{% endif %}</a>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
            {% if ".change_"|has_perm:activity %}
 | 
			
		||||
                <a class="btn btn-primary btn-sm my-1" href="{% url 'activity:activity_update' pk=activity.pk %}" data-turbolinks="false"> {% trans "edit"|capfirst %}</a>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
            {% if activity.activity_type.can_invite and not activity_started %}
 | 
			
		||||
                <a class="btn btn-primary btn-sm my-1" href="{% url 'activity:activity_invite' pk=activity.pk %}" data-turbolinks="false"> {% trans "Invite" %}</a>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
							
								
								
									
										15
									
								
								apps/activity/templates/activity/activity_invite.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								apps/activity/templates/activity/activity_invite.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% load render_table from django_tables2 %}
 | 
			
		||||
{% load i18n crispy_forms_tags %}
 | 
			
		||||
{% block content %}
 | 
			
		||||
    <form method="post">
 | 
			
		||||
        {% csrf_token %}
 | 
			
		||||
        {{ form|crispy }}
 | 
			
		||||
        <button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
 | 
			
		||||
    </form>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block extrajavascript %}
 | 
			
		||||
    <script type="text/javascript">
 | 
			
		||||
    </script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
							
								
								
									
										41
									
								
								apps/activity/templates/activity/activity_list.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								apps/activity/templates/activity/activity_list.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
{% extends "base.html" %}
 | 
			
		||||
{% load render_table from django_tables2 %}
 | 
			
		||||
{% load i18n crispy_forms_tags%}
 | 
			
		||||
{% block content %}
 | 
			
		||||
    {% if started_activities %}
 | 
			
		||||
        <h2>{% trans "Current activity" %}</h2>
 | 
			
		||||
        {% for activity in started_activities %}
 | 
			
		||||
            {% include "activity/activity_info.html" %}
 | 
			
		||||
            <hr>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
 | 
			
		||||
    <h2>{% trans "Upcoming activities" %}</h2>
 | 
			
		||||
    {% if upcoming.data %}
 | 
			
		||||
        {% render_table upcoming %}
 | 
			
		||||
    {% else %}
 | 
			
		||||
        <div class="alert alert-warning">
 | 
			
		||||
            {% trans "There is no planned activity." %}
 | 
			
		||||
        </div>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
 | 
			
		||||
    <a class="btn btn-primary" href="{% url 'activity:activity_create' %}" data-turbolinks="false">{% trans 'New activity' %}</a>
 | 
			
		||||
 | 
			
		||||
    <hr>
 | 
			
		||||
 | 
			
		||||
    <h2>{% trans "All activities" %}</h2>
 | 
			
		||||
 | 
			
		||||
    {% render_table table %}
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block extrajavascript %}
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
 | 
			
		||||
$(document).ready(function($) {
 | 
			
		||||
    $(".table-row").click(function() {
 | 
			
		||||
        window.document.location = $(this).data("href");
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
		Reference in New Issue
	
	Block a user