feat: create and update accounting periods
This commit is contained in:
parent
a53c9be7ad
commit
ea8e5b9bf1
4 changed files with 75 additions and 7 deletions
|
@ -22,7 +22,11 @@
|
|||
{% if forloop.first %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
{% if user.profile.is_buro %}
|
||||
<th><a href="{% url 'cof_clubs:acct-period-update' period.id %}">{{ period.name }}</a></th>
|
||||
{% else %}
|
||||
<th>{{ period.name }}</th>
|
||||
{% endif %}
|
||||
{% if forloop.last %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
@ -47,6 +51,13 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if user.profile.is_buro %}
|
||||
<div class="buttons">
|
||||
<a class="button is-warning" href="{% url 'cof_clubs:acct-period-create' %}">
|
||||
Créer un exercice comptable
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
{% extends "cof_clubs/base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<section class="section">
|
||||
<h1 class="title">{% trans "Création/Modification d'un exercice comptable" %}</h1>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{% include "bulma/form.html" with errors=True form=form %}
|
||||
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">
|
||||
<span>{% trans "Enregister" %}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
{% endblock %}
|
|
@ -5,6 +5,16 @@ from . import views
|
|||
app_name = "cof_clubs"
|
||||
urlpatterns = [
|
||||
path("", views.ClubListView.as_view(), name="club-list"),
|
||||
path(
|
||||
"acct-period/add",
|
||||
views.ClubBudgetAccountingPeriodCreateView.as_view(),
|
||||
name="acct-period-create",
|
||||
),
|
||||
path(
|
||||
"acct-period/<int:pk>",
|
||||
views.ClubBudgetAccountingPeriodUpdateView.as_view(),
|
||||
name="acct-period-update",
|
||||
),
|
||||
path("club/<int:pk>", views.ClubDetailView.as_view(), name="club-detail"),
|
||||
path("club/add", views.ClubCreateView.as_view(), name="club-create"),
|
||||
path(
|
||||
|
|
|
@ -1,20 +1,44 @@
|
|||
from django.contrib.auth.mixins import AccessMixin, LoginRequiredMixin
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.db import transaction
|
||||
from django.db.models import Sum
|
||||
from django.urls import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.views.generic import DetailView, TemplateView
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView
|
||||
from django.views.generic.edit import CreateView, DeleteView, FormView, UpdateView
|
||||
|
||||
from gestioncof.decorators import BuroRequiredMixin
|
||||
|
||||
from .forms import ClubBudgetLineForm, ClubBudgetLineFullForm
|
||||
from .forms import (
|
||||
ClubBudgetLineCommonForm,
|
||||
ClubBudgetLineForm,
|
||||
ClubBudgetLineFormSet,
|
||||
ClubBudgetLineFullForm,
|
||||
)
|
||||
from .mixins import BudgetLineAccessMixin
|
||||
from .models import Club, ClubBudgetAccountingPeriod, ClubBudgetLine
|
||||
|
||||
|
||||
class ClubCreateView(BuroRequiredMixin, CreateView):
|
||||
class ClubCreateView(BuroRequiredMixin, SuccessMessageMixin, CreateView):
|
||||
model = Club
|
||||
fields = ["name", "description", "respos", "budget_managers"]
|
||||
|
||||
success_message = "Le club %(name)s a été créé avec succès"
|
||||
|
||||
|
||||
class ClubBudgetAccountingPeriodCreateView(BuroRequiredMixin, CreateView):
|
||||
model = ClubBudgetAccountingPeriod
|
||||
fields = ["name"]
|
||||
|
||||
success_url = reverse_lazy("cof_clubs:club-list")
|
||||
|
||||
|
||||
class ClubBudgetAccountingPeriodUpdateView(BuroRequiredMixin, UpdateView):
|
||||
model = ClubBudgetAccountingPeriod
|
||||
fields = ["name", "is_archived"]
|
||||
|
||||
success_url = reverse_lazy("cof_clubs:club-list")
|
||||
|
||||
|
||||
class ClubListView(LoginRequiredMixin, TemplateView):
|
||||
template_name = "cof_clubs/club_list.html"
|
||||
|
@ -29,9 +53,10 @@ class ClubListView(LoginRequiredMixin, TemplateView):
|
|||
if self.request.user.profile.is_buro:
|
||||
managed_clubs = Club.objects.all().order_by("name") # TODO useless
|
||||
else:
|
||||
managed_clubs = self.request.user.managed_budgets_set.order_by(
|
||||
"name"
|
||||
) # TODO: useless
|
||||
managed_clubs = (
|
||||
self.request.user.managed_budgets_set.all()
|
||||
| self.request.user.respo_set.all()
|
||||
).order_by("name")
|
||||
data = (
|
||||
ClubBudgetLine.objects.filter(
|
||||
accounting_period__is_archived=False, club__in=managed_clubs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue