mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	Merge branch 'notekfet_wrapped' into 'main'
Notekfet wrapped See merge request bde/nk20!298
This commit is contained in:
		@@ -23,9 +23,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
 | 
			
		||||
		let d1 = document.getElementById("consumer");
 | 
			
		||||
		let d2 = document.getElementById("creditor");
 | 
			
		||||
		if (con) { d1.textContent = {{ big_consumer | safe }}[0] + " " + gettext("with") + " " + {{ big_consumer | safe}}[1] + "€";}
 | 
			
		||||
		else { d1.textContent = gettext("Infortunately, you doesn't have consumer this year");};
 | 
			
		||||
		else { d1.textContent = gettext({% trans "Infortunately, you doesn't have consumer this year" %});};
 | 
			
		||||
		if (cre) { d2.textContent = {{ big_creancier | safe}}[0] + " " + gettext("with") + " " + {{ big_creancier | safe}}[1] + "€";}
 | 
			
		||||
		else { d2.textContent = gettext("Congratulations you are a real rat !"); };
 | 
			
		||||
		else { d2.textContent = gettext({% trans "Congratulations you are a real rat !" %}); };
 | 
			
		||||
 | 
			
		||||
	</script>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,17 +6,24 @@ SPDX-License-Identifier: GPL-3.0-or-later
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
<div class="row justify-content-center">   
 | 
			
		||||
    <div class="col-md-10">
 | 
			
		||||
        <div class="card card-border shadow">
 | 
			
		||||
            <div class="card-header text-center">
 | 
			
		||||
		    <h5> {{ title }}</h5>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="card-body px-0 py-0" id="wrapped_table">
 | 
			
		||||
                {% render_table table %}
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
<div id="wrapped_tables">
 | 
			
		||||
{% if tables|length > 0 %}
 | 
			
		||||
<div class="card bg-light mb-3">
 | 
			
		||||
    <h3 class="card-header text-center">
 | 
			
		||||
        {% trans "My wrapped" %}
 | 
			
		||||
    </h3>
 | 
			
		||||
    {% render_table tables.1 %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
{% if tables|length > 0 %}
 | 
			
		||||
<div class="card bg-light mb-3">
 | 
			
		||||
    <h3 class="card-header text-center">
 | 
			
		||||
        {% trans "Public wrapped" %}
 | 
			
		||||
    </h3>
 | 
			
		||||
    {% render_table tables.0 %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
@@ -25,7 +32,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
 | 
			
		||||
	let club_not_public = {{ club_not_public }};
 | 
			
		||||
	if (club_not_public) { (addMsg("{% trans "Do not forget to ask permission to people who are in your wrapped before to make them public" %}", 'warning'));}
 | 
			
		||||
   function refreshTable() {
 | 
			
		||||
	$("#wrapped_table").load(location.pathname + " #wrapped_table");
 | 
			
		||||
	$("#wrapped_tables").load(location.pathname + " #wrapped_tables");
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   function copylink(id) {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,8 @@ import json
 | 
			
		||||
from django.contrib.auth.mixins import LoginRequiredMixin
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.views.generic import DetailView
 | 
			
		||||
from django_tables2.views import SingleTableView
 | 
			
		||||
from django.views.generic.list import ListView
 | 
			
		||||
from django_tables2.views import MultiTableMixin
 | 
			
		||||
from permission.backends import PermissionBackend
 | 
			
		||||
from permission.views import ProtectQuerysetMixin
 | 
			
		||||
 | 
			
		||||
@@ -14,21 +15,29 @@ from .models import Wrapped
 | 
			
		||||
from .tables import WrappedTable
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class WrappedListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
 | 
			
		||||
class WrappedListView(ProtectQuerysetMixin, LoginRequiredMixin, MultiTableMixin, ListView):
 | 
			
		||||
    """
 | 
			
		||||
    Display all Wrapped, and classify by year
 | 
			
		||||
    """
 | 
			
		||||
    model = Wrapped
 | 
			
		||||
    table_class = WrappedTable
 | 
			
		||||
    tables = [
 | 
			
		||||
        lambda data: WrappedTable(data, prefix="public-"),
 | 
			
		||||
        lambda data: WrappedTable(data, prefix="personnal-"),
 | 
			
		||||
    ]
 | 
			
		||||
    template_name = 'wrapped/wrapped_list.html'
 | 
			
		||||
    extra_context = {'title': _("List of wrapped")}
 | 
			
		||||
 | 
			
		||||
    def get_queryset(self, **kwargs):
 | 
			
		||||
        return super().get_queryset(**kwargs).distinct()
 | 
			
		||||
 | 
			
		||||
    def get_table_data(self):
 | 
			
		||||
        return Wrapped.objects.filter(PermissionBackend.filter_queryset(
 | 
			
		||||
            self.request, Wrapped, "change", field='public')).distinct().order_by("-bde__date_start")
 | 
			
		||||
    def get_tables_data(self):
 | 
			
		||||
        return [
 | 
			
		||||
            Wrapped.objects.filter(public=True),
 | 
			
		||||
            Wrapped.objects
 | 
			
		||||
            .filter(PermissionBackend.filter_queryset(self.request, Wrapped, "change", field='public'))
 | 
			
		||||
            .distinct()
 | 
			
		||||
            .order_by("-bde__date_start")
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
    def get_context_data(self, **kwargs):
 | 
			
		||||
        context = super().get_context_data(**kwargs)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user