Browse Source

page « mon adhésion »

Élie Bouttier 8 years ago
parent
commit
05785c369f
5 changed files with 78 additions and 1 deletions
  1. 50 0
      adhesions/templates/adhesions/adhesion.html
  2. 8 0
      adhesions/urls.py
  3. 5 1
      adhesions/views.py
  4. 14 0
      banking/models.py
  5. 1 0
      djadhere/urls.py

+ 50 - 0
adhesions/templates/adhesions/adhesion.html

@@ -0,0 +1,50 @@
+{% extends 'base.html' %}
+
+{% block adhesiontab %} class="active"{% endblock %}
+
+{% block content %}
+{% if adhesion %}
+
+<div class="panel panel-default">
+    <div class="panel-heading"><h4>À propos de votre adhésion</h4></div>
+    <div class="panel-body">
+        <p>Votre numéro d’adhérent : ADT{{ adhesion.id }}</p>
+        {% if adhesion.contribution.count == 0 %}
+        <p>Pas de cotisation.</p>
+        {% elif adhesion.contribution.count == 1 %}
+        {% with contribution=adhesion.contribution.first %}
+        <p>Montant de votre cotisation : {{ contribution }}</p>
+        {% if contribution.date %}
+        <p>Date d’adhésion : {{ contribution.date }}</p>
+        {% endif %}
+        {% endwith %}
+        {% endif %}
+    </div>
+</div>
+
+{% if adhesion.contribution.count > 1 %}
+<div class="panel panel-default">
+    <div class="panel-heading"><h4>Vos cotisations</h4></div>
+    <table class="table">
+        <tr>
+            <th>Montant</th>
+            <th>Période</th>
+            <th>Méthode de paiement</th>
+            <th>Premier paiement</th>
+        </tr>
+        {% for c in adhesion.contribution.all %}
+        <tr>
+            <td>{{ c.amount }} €</td>
+            <td>{{ c.period_verbose }}</td>
+            <td>{{ c.get_payment_method_display }}</td>
+            <td>{{ c.date }}</td>
+        </tr>
+        {% endfor %}
+    </table>
+</div>
+{% endif %}
+
+{% else %}
+<p>Vous n’êtes pas adhérent.</p>
+{% endif %}
+{% endblock %}

+ 8 - 0
adhesions/urls.py

@@ -0,0 +1,8 @@
+from django.conf.urls import url
+
+from . import views
+
+
+urlpatterns = [
+    url(r'^$', views.adhesion, name='adhesion'),
+]

+ 5 - 1
adhesions/views.py

@@ -1,3 +1,7 @@
 from django.shortcuts import render
 
-# Create your views here.
+
+def adhesion(request):
+    return render(request, 'adhesions/adhesion.html', {
+        'adhesion': request.user.profile.adhesion,
+    })

+ 14 - 0
banking/models.py

@@ -41,6 +41,20 @@ class Payment(models.Model):
             return 'Service (%s)' % self.reason.service_type
     payment_type_verbose.short_description = 'Type'
 
+    def period_verbose(self):
+        if self.period == 0:
+            return 'non récurrent'
+        elif self.period == 1:
+            return 'mensuel'
+        elif self.period == 3:
+            return 'trimestriel'
+        elif self.period == 6:
+            return 'biannuel'
+        elif self.period == 12:
+            return 'annuel'
+        else:
+            return '%d mois' % self.period
+
     # Note: 'adherent' is already used as the related_query_name
     #        of the GenericRelation on Adherent
     def get_adherent(self):

+ 1 - 0
djadhere/urls.py

@@ -23,6 +23,7 @@ urlpatterns = [
     url(r'^$', views.home, name='home'),
     url(r'^accounts/', include('accounts.urls')),
     url(r'^services/', include('services.urls')),
+    url(r'^adhesion/', include('adhesions.urls')),
     url(r'^admin/', admin.site.urls),
 ]