Commit 7ebfb895 authored by jocelyn's avatar jocelyn

Permet d'ajouter des emprunts depuis la fiche membre

Ref #189
parent e86bb986
......@@ -164,6 +164,12 @@ 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'
......@@ -293,9 +299,12 @@ class LoanInline(admin.TabularInline):
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(coin.members.admin.MemberAdmin):
inlines = coin.members.admin.MemberAdmin.inlines + [LoanInline]
class MemberAdmin(_MemberAdmin):
inlines = _MemberAdmin.inlines + [LoanInline, AddLoanInlineFromUser]
admin.site.unregister(coin.members.admin.Member)
......
# -*- coding: utf-8 -*-
import autocomplete_light
from models import Item
# This will generate a MemberAutocomplete class
autocomplete_light.register(Item,
# Just like in ModelAdmin.search_fields
search_fields=[
'designation', 'mac_address', 'serial'],
attrs={
# This will set the input placeholder attribute:
'placeholder': "Nom / adresse MAC / n° de série de l'objet",
'data-autocomplete-minimum-characters': 3,
},
)
......@@ -95,9 +95,12 @@ class MaillingListAdmin(admin.ModelAdmin):
admin.site.register(MaillingList, MaillingListAdmin)
# Enrich the MemberAdmin with maillists-related information
_MemberAdmin = admin.site._registry[coin.members.admin.Member].__class__
class MemberAdmin(coin.members.admin.MemberAdmin):
inlines = coin.members.admin.MemberAdmin.inlines + [
class MemberAdmin(_MemberAdmin):
inlines = _MemberAdmin.inlines + [
MaillingListSubscriptionInline,
AddMaillingListSubscriptionInline,
]
......
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