diff --git a/cof_clubs/templates/cof_clubs/club_list.html b/cof_clubs/templates/cof_clubs/club_list.html
index af5b4535..03ff1bc0 100644
--- a/cof_clubs/templates/cof_clubs/club_list.html
+++ b/cof_clubs/templates/cof_clubs/club_list.html
@@ -22,7 +22,11 @@
{% if forloop.first %}
{% endif %}
+ {% if user.profile.is_buro %}
+ {{ period.name }} |
+ {% else %}
{{ period.name }} |
+ {% endif %}
{% if forloop.last %}
{% endif %}
@@ -47,6 +51,13 @@
{% endfor %}
+ {% if user.profile.is_buro %}
+
+ {% endif %}
{% endblock content %}
diff --git a/cof_clubs/templates/cof_clubs/clubbudgetaccountingperiod_form.html b/cof_clubs/templates/cof_clubs/clubbudgetaccountingperiod_form.html
new file mode 100644
index 00000000..10236584
--- /dev/null
+++ b/cof_clubs/templates/cof_clubs/clubbudgetaccountingperiod_form.html
@@ -0,0 +1,22 @@
+{% extends "cof_clubs/base.html" %}
+
+{% load i18n %}
+
+{% block content %}
+
+ {% trans "Création/Modification d'un exercice comptable" %}
+
+
+{% endblock %}
diff --git a/cof_clubs/urls.py b/cof_clubs/urls.py
index fa78b615..6b209fb0 100644
--- a/cof_clubs/urls.py
+++ b/cof_clubs/urls.py
@@ -5,6 +5,16 @@ from . import views
app_name = "cof_clubs"
urlpatterns = [
path("club/", views.ClubListView.as_view(), name="club-list"),
+ path(
+ "acct-period/add",
+ views.ClubBudgetAccountingPeriodCreateView.as_view(),
+ name="acct-period-create",
+ ),
+ path(
+ "acct-period/",
+ views.ClubBudgetAccountingPeriodUpdateView.as_view(),
+ name="acct-period-update",
+ ),
path("club/", views.ClubDetailView.as_view(), name="club-detail"),
path("club/add", views.ClubCreateView.as_view(), name="club-create"),
path(
diff --git a/cof_clubs/views.py b/cof_clubs/views.py
index 3cb49a24..61c9a716 100644
--- a/cof_clubs/views.py
+++ b/cof_clubs/views.py
@@ -1,20 +1,39 @@
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
+from .forms import ClubBudgetLineCommonForm, ClubBudgetLineForm, ClubBudgetLineFormSet
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 +48,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