mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Add simple club stats
This commit is contained in:
parent
c48449cd50
commit
114272df2f
49
club/templates/club/stats.jinja
Normal file
49
club/templates/club/stats.jinja
Normal file
@ -0,0 +1,49 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Club stats{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if club_list %}
|
||||
<h3>{% trans %}Club stats{% endtrans %}</h3>
|
||||
<form action="" method="GET">
|
||||
{% csrf_token %}
|
||||
<p>
|
||||
<select name="branch">
|
||||
{% for b in settings.SITH_PROFILE_DEPARTMENTS %}
|
||||
<option value="{{ b[0] }}">{{ b[0] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</p>
|
||||
<p><input type="submit" value="{% trans %}Show{% endtrans %}" /></p>
|
||||
</form>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Club</td>
|
||||
<td>Member number</td>
|
||||
<td>Old member number</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for c in club_list.order_by('id') %}
|
||||
{% set members = c.members.all() %}
|
||||
{% if request.GET['branch'] %}
|
||||
{% set members = members.filter(user__department=request.GET['branch']) %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>{{ c.get_display_name() }}</td>
|
||||
<td>{{ members.filter(end_date=None, role__gt=settings.SITH_MAXIMUM_FREE_ROLE).count() }}</td>
|
||||
<td>{{ members.exclude(end_date=None, role__gt=settings.SITH_MAXIMUM_FREE_ROLE).count() }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
{% trans %}There is no club in this website.{% endtrans %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ from club.views import *
|
||||
urlpatterns = [
|
||||
url(r'^$', ClubListView.as_view(), name='club_list'),
|
||||
url(r'^new$', ClubCreateView.as_view(), name='club_new'),
|
||||
url(r'^stats$', ClubStatView.as_view(), name='club_stats'),
|
||||
url(r'^(?P<club_id>[0-9]+)/$', ClubView.as_view(), name='club_view'),
|
||||
url(r'^(?P<club_id>[0-9]+)/edit$', ClubEditView.as_view(), name='club_edit'),
|
||||
url(r'^(?P<club_id>[0-9]+)/members$', ClubMembersView.as_view(), name='club_members'),
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django import forms
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic import ListView, DetailView, TemplateView
|
||||
from django.views.generic.edit import UpdateView, CreateView
|
||||
from django.forms import CheckboxSelectMultiple
|
||||
from django.core.exceptions import ValidationError
|
||||
@ -17,6 +17,7 @@ from datetime import timedelta
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
|
||||
from core.views.forms import SelectDate, SelectSingle, SelectDateTime
|
||||
from club.models import Club, Membership
|
||||
from core.models import User
|
||||
from sith.settings import SITH_MAXIMUM_FREE_ROLE, SITH_MAIN_BOARD_GROUP
|
||||
from counter.models import Product, Selling, Counter
|
||||
|
||||
@ -283,3 +284,10 @@ class MembershipSetOldView(CanEditMixin, DetailView):
|
||||
self.object = self.get_object()
|
||||
return HttpResponseRedirect(reverse('club:club_members', args=self.args, kwargs={'club_id': self.object.club.id}))
|
||||
|
||||
class ClubStatView(TemplateView):
|
||||
template_name="club/stats.jinja"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super(ClubStatView, self).get_context_data(**kwargs)
|
||||
kwargs['club_list'] = Club.objects.all()
|
||||
return kwargs
|
||||
|
@ -143,21 +143,8 @@ class User(AbstractBaseUser):
|
||||
("FORMER STUDENT", _("Former student")),
|
||||
("SERVICE", _("Service")),
|
||||
], blank=True, default="")
|
||||
department = models.CharField(_("department"), max_length=15, choices=[
|
||||
("TC", _("TC")),
|
||||
("IMSI", _("IMSI")),
|
||||
("IMAP", _("IMAP")),
|
||||
("INFO", _("INFO")),
|
||||
("GI", _("GI")),
|
||||
("E", _("E")),
|
||||
("EE", _("EE")),
|
||||
("GESC", _("GESC")),
|
||||
("GMC", _("GMC")),
|
||||
("MC", _("MC")),
|
||||
("EDIM", _("EDIM")),
|
||||
("HUMA", _("Humanities")),
|
||||
("NA", _("N/A")),
|
||||
], default="NA", blank=True)
|
||||
department = models.CharField(_("department"), max_length=15, choices=settings.SITH_PROFILE_DEPARTMENTS,
|
||||
default="NA", blank=True)
|
||||
dpt_option = models.CharField(_("dpt option"), max_length=32, blank=True, default="")
|
||||
semester = models.CharField(_("semester"), max_length=5, blank=True, default="")
|
||||
quote = models.CharField(_("quote"), max_length=256, blank=True, default="")
|
||||
|
@ -282,6 +282,22 @@ SITH_MEMBER_SUFFIX="-membres"
|
||||
SITH_MAIN_BOARD_GROUP=SITH_MAIN_CLUB['unix_name']+SITH_BOARD_SUFFIX
|
||||
SITH_MAIN_MEMBERS_GROUP=SITH_MAIN_CLUB['unix_name']+SITH_MEMBER_SUFFIX
|
||||
|
||||
SITH_PROFILE_DEPARTMENTS = [
|
||||
("TC", _("TC")),
|
||||
("IMSI", _("IMSI")),
|
||||
("IMAP", _("IMAP")),
|
||||
("INFO", _("INFO")),
|
||||
("GI", _("GI")),
|
||||
("E", _("E")),
|
||||
("EE", _("EE")),
|
||||
("GESC", _("GESC")),
|
||||
("GMC", _("GMC")),
|
||||
("MC", _("MC")),
|
||||
("EDIM", _("EDIM")),
|
||||
("HUMA", _("Humanities")),
|
||||
("NA", _("N/A")),
|
||||
]
|
||||
|
||||
SITH_ACCOUNTING_PAYMENT_METHOD = [
|
||||
('CHECK', _('Check')),
|
||||
('CASH', _('Cash')),
|
||||
|
Loading…
Reference in New Issue
Block a user