mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-27 02:43:01 +00:00
Merge branch 'master' into 'turbolinks'
# Conflicts: # apps/note/views.py
This commit is contained in:
commit
ae90a957ce
@ -12,7 +12,6 @@ urlpatterns = [
|
|||||||
path('buttons/create/', views.TransactionTemplateCreateView.as_view(), name='template_create'),
|
path('buttons/create/', views.TransactionTemplateCreateView.as_view(), name='template_create'),
|
||||||
path('buttons/update/<int:pk>/', views.TransactionTemplateUpdateView.as_view(), name='template_update'),
|
path('buttons/update/<int:pk>/', views.TransactionTemplateUpdateView.as_view(), name='template_update'),
|
||||||
path('buttons/', views.TransactionTemplateListView.as_view(), name='template_list'),
|
path('buttons/', views.TransactionTemplateListView.as_view(), name='template_list'),
|
||||||
path('consos/<str:template_type>/', views.ConsoView.as_view(), name='consos'),
|
|
||||||
path('consos/', views.ConsoView.as_view(), name='consos'),
|
path('consos/', views.ConsoView.as_view(), name='consos'),
|
||||||
|
|
||||||
# API for the note autocompleter
|
# API for the note autocompleter
|
||||||
|
@ -8,7 +8,7 @@ from django.urls import reverse
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import CreateView, ListView, UpdateView
|
from django.views.generic import CreateView, ListView, UpdateView
|
||||||
|
|
||||||
from .models import Transaction, TransactionCategory, TransactionTemplate, Alias
|
from .models import Transaction, TransactionTemplate, Alias
|
||||||
from .forms import TransactionForm, TransactionTemplateForm, ConsoForm
|
from .forms import TransactionForm, TransactionTemplateForm, ConsoForm
|
||||||
|
|
||||||
|
|
||||||
@ -138,21 +138,17 @@ class ConsoView(LoginRequiredMixin, CreateView):
|
|||||||
Add some context variables in template such as page title
|
Add some context variables in template such as page title
|
||||||
"""
|
"""
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['template_types'] = TransactionCategory.objects.all()
|
context['transaction_templates'] = TransactionTemplate.objects.all() \
|
||||||
|
.order_by('template_type')
|
||||||
|
context['title'] = _("Consommations")
|
||||||
|
|
||||||
|
# select2 compatibility
|
||||||
context['no_cache'] = True
|
context['no_cache'] = True
|
||||||
|
|
||||||
if 'template_type' not in self.kwargs.keys():
|
|
||||||
return context
|
|
||||||
|
|
||||||
template_type = TransactionCategory.objects.filter(
|
|
||||||
name=self.kwargs.get('template_type')).get()
|
|
||||||
context['buttons'] = TransactionTemplate.objects.filter(
|
|
||||||
template_type=template_type)
|
|
||||||
context['title'] = template_type
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('note:consos',
|
"""
|
||||||
args=(self.kwargs.get('template_type'), ))
|
When clicking a button, reload the same page
|
||||||
|
"""
|
||||||
|
return reverse('note:consos')
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
<i class="fa fa-users"></i> {% trans "View my memberships" %}
|
<i class="fa fa-users"></i> {% trans "View my memberships" %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="clubListCollapse" class="collapse overflow-auto show" aria-labelledby="clubListHeading" data-parent="#accordionProfile">
|
<div id="clubListCollapse" class="collapse show" style="overflow:auto hidden" aria-labelledby="clubListHeading" data-parent="#accordionProfile">
|
||||||
{% render_table club_list %}
|
{% render_table club_list %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<i class="fa fa-euro"></i> Historique des transactions
|
<i class="fa fa-euro"></i> Historique des transactions
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="historyListCollapse" class="collapse overflow-auto" aria-labelledby="historyListHeading" data-parent="#accordionProfile">
|
<div id="historyListCollapse" class="collapse" style="overflow:auto hidden" aria-labelledby="historyListHeading" data-parent="#accordionProfile">
|
||||||
{% render_table history_list %}
|
{% render_table history_list %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,13 +2,18 @@
|
|||||||
|
|
||||||
{% load i18n static pretty_money %}
|
{% load i18n static pretty_money %}
|
||||||
|
|
||||||
|
{# Remove page title #}
|
||||||
|
{% block contenttitle %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<fieldset class="module aligned">
|
{# Regroup buttons under categories #}
|
||||||
{% for type in template_types %}
|
{% regroup transaction_templates by template_type as template_types %}
|
||||||
<a href="{% url 'note:consos' template_type=type %}"><button>{{ type }}</button></a>
|
|
||||||
{% endfor %}
|
<form method="post" onsubmit="window.onbeforeunload=null">
|
||||||
</fieldset>
|
{% csrf_token %}
|
||||||
<form method="post" onsubmit="window.onbeforeunload=null">{% csrf_token %}
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-5 mb-4">
|
||||||
{% if form.non_field_errors %}
|
{% if form.non_field_errors %}
|
||||||
<p class="errornote">
|
<p class="errornote">
|
||||||
{% for error in form.non_field_errors %}
|
{% for error in form.non_field_errors %}
|
||||||
@ -16,7 +21,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<fieldset class="module aligned">
|
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
<div class="form-row{% if field.errors %} errors{% endif %}">
|
<div class="form-row{% if field.errors %} errors{% endif %}">
|
||||||
{{ field.errors }}
|
{{ field.errors }}
|
||||||
@ -33,9 +37,61 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for button in buttons %}
|
</div>
|
||||||
<button name="button" value="{{ button.name }}">{{ button.name }} ({{ button.amount | pretty_money }})</button>
|
|
||||||
|
<div class="col-sm-7">
|
||||||
|
<div class="card text-center shadow">
|
||||||
|
{# Tabs for button categories #}
|
||||||
|
<div class="card-header">
|
||||||
|
<ul class="nav nav-tabs nav-fill card-header-tabs">
|
||||||
|
{% for template_type in template_types %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#{{ template_type.grouper|slugify }}">
|
||||||
|
{{ template_type.grouper }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Tabs content #}
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="tab-content">
|
||||||
|
{% for template_type in template_types %}
|
||||||
|
<div class="tab-pane" id="{{ template_type.grouper|slugify }}">
|
||||||
|
<div class="d-inline-flex flex-wrap justify-content-center">
|
||||||
|
{% for button in template_type.list %}
|
||||||
|
<button class="btn btn-outline-dark rounded-0 flex-fill"
|
||||||
|
name="button" value="{{ button.name }}">
|
||||||
|
{{ button.name }} ({{ button.amount | pretty_money }})
|
||||||
|
</button>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extrajavascript %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
// If hash of a category in the URL, then select this category
|
||||||
|
// else select the first one
|
||||||
|
if (location.hash) {
|
||||||
|
$("a[href='" + location.hash + "']").tab("show");
|
||||||
|
} else {
|
||||||
|
$("a[data-toggle='tab']").first().tab("show");
|
||||||
|
}
|
||||||
|
|
||||||
|
// When selecting a category, change URL
|
||||||
|
$(document.body).on("click", "a[data-toggle='tab']", function(event) {
|
||||||
|
location.hash = this.getAttribute("href");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user