1- # Copyright The IETF Trust 2010-2019 , All Rights Reserved
1+ # Copyright The IETF Trust 2010-2020 , All Rights Reserved
22# -*- coding: utf-8 -*-
33
44
55from __future__ import absolute_import , print_function , unicode_literals
66
77from django .contrib import admin
8+ from django .db import models
89from django import forms
910
1011from .models import (StateType , State , RelatedDocument , DocumentAuthor , Document , RelatedDocHistory ,
@@ -43,6 +44,14 @@ def this(self, instance):
4344 raw_id_fields = ['target' ]
4445 extra = 1
4546
47+ class AdditionalUrlInLine (admin .TabularInline ):
48+ model = DocumentURL
49+ fields = ['tag' ,'desc' ,'url' ,]
50+ extra = 1
51+ formfield_overrides = {
52+ models .CharField : {'widget' : forms .TextInput (attrs = {'size' :'50' })},
53+ }
54+
4655class DocumentForm (forms .ModelForm ):
4756 comment_about_changes = forms .CharField (
4857 widget = forms .Textarea (attrs = {'rows' :10 ,'cols' :40 ,'class' :'vLargeTextField' }), strip = False ,
@@ -64,7 +73,7 @@ class DocumentAdmin(admin.ModelAdmin):
6473 search_fields = ['name' ]
6574 list_filter = ['type' ]
6675 raw_id_fields = ['group' , 'shepherd' , 'ad' ]
67- inlines = [DocAuthorInline , RelatedDocumentInline , ]
76+ inlines = [DocAuthorInline , RelatedDocumentInline , AdditionalUrlInLine ]
6877 form = DocumentForm
6978
7079 def save_model (self , request , obj , form , change ):
@@ -173,5 +182,6 @@ class IRSGBallotDocEventAdmin(DocEventAdmin):
173182
174183class DocumentUrlAdmin (admin .ModelAdmin ):
175184 list_display = ['id' , 'doc' , 'tag' , 'url' , 'desc' , ]
185+ search_fields = ['doc__name' , 'url' , ]
176186 raw_id_fields = ['doc' , ]
177187admin .site .register (DocumentURL , DocumentUrlAdmin )
0 commit comments