|
@@ -1,6 +1,8 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
+from datetime import date
|
|
|
+
|
|
|
from django.shortcuts import get_object_or_404
|
|
|
from django.contrib import admin
|
|
|
from django.contrib import messages
|
|
@@ -11,6 +13,7 @@ from django.http import HttpResponseRedirect
|
|
|
from django.conf.urls import url
|
|
|
from django.conf import settings
|
|
|
from django.core.urlresolvers import reverse
|
|
|
+from django.utils.safestring import mark_safe
|
|
|
|
|
|
from coin.members.models import (
|
|
|
Member, CryptoKey, LdapUser, MembershipFee, Offer, OfferSubscription, RowLevelPermission)
|
|
@@ -85,7 +88,7 @@ class MemberAdmin(UserAdmin):
|
|
|
list_display = ('id', 'status', 'username', 'first_name',
|
|
|
'name_or_organization_name',
|
|
|
'nickname', 'email',
|
|
|
- 'end_date_of_membership')
|
|
|
+ 'enhanced_end_date_of_membership')
|
|
|
list_display_links = ('id', 'username', 'first_name', 'name_or_organization_name')
|
|
|
list_filter = ('status', MembershipFeeFilter)
|
|
|
search_fields = ['username', 'first_name', 'last_name', 'email', 'nickname']
|
|
@@ -101,6 +104,32 @@ class MemberAdmin(UserAdmin):
|
|
|
return obj.organization_name or obj.last_name
|
|
|
name_or_organization_name.short_description = 'Nom'
|
|
|
|
|
|
+ def enhanced_end_date_of_membership(self, obj):
|
|
|
+ membership_end = obj.end_date_of_membership()
|
|
|
+ active_subscriptions = obj.get_active_subscriptions()
|
|
|
+ recent_inactive_subscriptions = obj.get_recent_inactive_subscriptions()
|
|
|
+
|
|
|
+ note = ''
|
|
|
+ tooltip = ''
|
|
|
+
|
|
|
+ if (membership_end is not None and membership_end < date.today()
|
|
|
+ and recent_inactive_subscriptions.exists() and not active_subscriptions.exists()):
|
|
|
+ note = ' <i class="fa fa-question-circle" style="color: #cccc40"></i>'
|
|
|
+ tooltip = (
|
|
|
+ "Cet·te ancien·ne adhérent·e a un service résilié depuis moins d'un an. "
|
|
|
+ "Légalement, il faut conserver sa fiche un an après la résiliation du service."
|
|
|
+ )
|
|
|
+
|
|
|
+ out = '{}{}'.format(
|
|
|
+ obj.end_date_of_membership() or "pas de cotisation", note)
|
|
|
+
|
|
|
+ if note:
|
|
|
+ return mark_safe('<span style="cursor: help;" title="{}">{}</span>'.format(tooltip, out))
|
|
|
+ else:
|
|
|
+ return mark_safe(out)
|
|
|
+ return mark_safe()
|
|
|
+ enhanced_end_date_of_membership.short_description = "Date de fin d'adhésion"
|
|
|
+
|
|
|
def get_fieldsets(self, request, obj=None):
|
|
|
coord_fieldset = ('Coordonnées', {'fields': (
|
|
|
('email', 'send_membership_fees_email'),
|