From 9fe47229fd01e463277921c10842b5a8f673637a Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Thu, 15 Aug 2019 21:49:59 +0200 Subject: [PATCH] Detail view of club: member list and history --- apps/member/views.py | 19 ++++++++++ templates/member/club_detail.html | 61 +++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/apps/member/views.py b/apps/member/views.py index 4c0900ab..f915d4e8 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -9,9 +9,15 @@ from django.views.generic import CreateView, ListView, DetailView from django.http import HttpResponseRedirect from django.contrib.auth.forms import UserCreationForm from django.urls import reverse_lazy +from django.db.models import Q + +from django_tables2.views import SingleTableView + from .models import Profile, Club, Membership from .forms import ProfileForm, ClubForm,MembershipForm, MemberFormSet,FormSetHelper +from .tables import ClubTable +from note.models.transactions import Transaction class UserCreateView(CreateView): """ @@ -63,7 +69,20 @@ class ClubListView(LoginRequiredMixin,SingleTableView): class ClubDetailView(LoginRequiredMixin,DetailView): model = Club + context_object_name="club" + def get_context_data(self,**kwargs): + context = super().get_context_data(**kwargs) + club = context["club"] + club_transactions = \ + Transaction.objects.all().filter(Q(source=club.note) | Q(destination=club.note)) + context['history_list'] = club_transactions + club_member = \ + Membership.objects.all().filter(club=club) + #TODO: consider only valid Membership + context['member_list'] = club_member + return context + class ClubAddMemberView(LoginRequiredMixin,CreateView): model = Membership form_class = MembershipForm diff --git a/templates/member/club_detail.html b/templates/member/club_detail.html index ddac22aa..d8e6f805 100644 --- a/templates/member/club_detail.html +++ b/templates/member/club_detail.html @@ -1,8 +1,61 @@ {% extends "base.html" %} {% load static %} +{% load i18n %} +{% load render_table from django_tables2 %} {% block content %} -

Clubs

-
{{ object.name }}
+

Clubs

+

Club {{ object.name }}

+
+
{% trans 'Membership starts on' %}
+
{{ club.membership_start }}
+
{% trans 'Membership ends on' %}
+
{{ club.membership_end }}
+
{% trans 'Membership duration' %}
+
{{ club.membership_duration }}
+
Aliases
+
{{ club.note.aliases_set.all }}
+
{% trans 'balance' %}
+
{{ club.note.balance }}
- Ajouter des membres -{% endblock %} +
+ + +
+ Ajouter des membres + Modifier les informations + Ajouter des roles +
+ +
+
+
+
+ +
+
+ +
+
+ + {% render_table member_list %} +
+
+
+
+
+
+ +
+
+
+
+ {% render_table history_list %} +
+
+
+
+ {% endblock %}