Commit 4da67e01 authored by jocelyn's avatar jocelyn

Amélioration de la vue des emprunts sur la fiche membre

- séparation de l'historique (passé) des emprunts et des emprunts en
  cours (avec un bouton rendre)
- nommage des classes plus cohérent
parent baacb4db
......@@ -164,12 +164,6 @@ class AddLoanInline(admin.StackedInline):
return False
class AddLoanInlineFromUser(AddLoanInline):
extra = 0
max_num = 10
verbose_name_plural = "Déclarer un nouveau prêt d'objet à ce membre"
class BorrowerFilter(admin.SimpleListFilter):
title = 'détenteur actuel'
parameter_name = 'user'
......@@ -281,30 +275,31 @@ class StorageAdmin(admin.ModelAdmin):
return obj.notes
truncated_notes.short_description = 'notes'
class LoanInline(admin.TabularInline):
model = Loan
extra = 0
exclude = ('notes',)
readonly_fields = ('item', 'get_mac_and_serial', 'loan_date', 'loan_date_end', 'is_running')
show_change_link = True
class MemberLoanHistoryInline(LoanHistoryInline):
verbose_name_plural = "Historique de prêt de matériel"
def get_queryset(self, request):
qs = super(LoanInline, self).get_queryset(request)
return qs.order_by('-loan_date_end')
def has_add_permission(self, request, obj=None):
return False
class MemberCurrentLoanInline(CurrentLoanInline):
verbose_name_plural = "Prêts de matériel en cours"
class MemberAddLoanInline(AddLoanInline):
extra = 0
max_num = 10
verbose_name_plural = "Déclarer un prêt de matériel"
def has_delete_permission(self, request, obj=None):
return False
# Enrich the MemberAdmin with hardware-related information
_MemberAdmin = admin.site._registry[coin.members.admin.Member].__class__
class MemberAdmin(_MemberAdmin):
inlines = _MemberAdmin.inlines + [LoanInline, AddLoanInlineFromUser]
inlines = _MemberAdmin.inlines + [
MemberCurrentLoanInline,
MemberAddLoanInline,
MemberLoanHistoryInline,
]
admin.site.unregister(coin.members.admin.Member)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment