|
@@ -8,6 +8,7 @@ from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
|
|
|
from .forms import AdhesionForm
|
|
|
from .models import ProxyUser, Corporation, Adhesion
|
|
|
from accounts.models import Profile
|
|
|
+from services.models import Service
|
|
|
from banking.admin import PaymentInline
|
|
|
|
|
|
|
|
@@ -25,7 +26,7 @@ class AdhesionInline(GenericTabularInline):
|
|
|
return False
|
|
|
|
|
|
|
|
|
-class ProfileInlineDjango(admin.StackedInline):
|
|
|
+class ProfileInline(admin.StackedInline):
|
|
|
model = Profile
|
|
|
|
|
|
def has_add_permission(self, request):
|
|
@@ -35,6 +36,20 @@ class ProfileInlineDjango(admin.StackedInline):
|
|
|
return False
|
|
|
|
|
|
|
|
|
+class ServiceInline(admin.StackedInline):
|
|
|
+ model = Service
|
|
|
+ extra = 0
|
|
|
+ show_change_link = True
|
|
|
+ fields = ('service_type', 'label',)
|
|
|
+ readonly_fields = ('service_type', 'label',)
|
|
|
+
|
|
|
+ def has_add_permission(self, request):
|
|
|
+ return False
|
|
|
+
|
|
|
+ def has_delete_permission(self, request, obj=None):
|
|
|
+ return False
|
|
|
+
|
|
|
+
|
|
|
class UserIsAdherentFilter(admin.SimpleListFilter):
|
|
|
title = 'status adhérent'
|
|
|
parameter_name = 'adherent'
|
|
@@ -56,7 +71,7 @@ class UserIsAdherentFilter(admin.SimpleListFilter):
|
|
|
class UserAdmin(AuthUserAdmin):
|
|
|
list_display = AuthUserAdmin.list_display + ('adherent_id',)
|
|
|
list_filter = (AuthUserAdmin.list_filter[2], UserIsAdherentFilter) # [2] = actif
|
|
|
- inlines = (ProfileInlineDjango, AdhesionInline,)
|
|
|
+ inlines = (ProfileInline, AdhesionInline,)
|
|
|
|
|
|
def adherent_id(self, user):
|
|
|
adherent = user.profile.adhesion
|
|
@@ -110,10 +125,10 @@ class AdherentTypeFilter(admin.SimpleListFilter):
|
|
|
class AdhesionAdmin(admin.ModelAdmin):
|
|
|
list_display = ('get_id', 'get_adherent_link', 'type',)
|
|
|
list_filter = (AdherentTypeFilter,)
|
|
|
- fields = ('id',)
|
|
|
- readonly_fields = ('id',)
|
|
|
+ fields = ('id', 'type', 'get_adherent_link',)
|
|
|
+ readonly_fields = ('id', 'type', 'get_adherent_link',)
|
|
|
search_fields = ('id',)
|
|
|
- #inlines = (PaymentInline,)
|
|
|
+ inlines = (ServiceInline,)#PaymentInline,)
|
|
|
|
|
|
def get_id(self, obj):
|
|
|
return 'ADT%d' % obj.id
|