<s> from __future__ import absolute_import , unicode_literals <EOL> import json <EOL> from django . template . loader import render_to_string <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from wagtail . wagtailadmin . widgets import AdminChooser <EOL> from wagtail . wagtaildocs . models import get_document_model <EOL> class AdminDocumentChooser ( AdminChooser ) : <EOL> choose_one_text = _ ( '<STR_LIT>' ) <EOL> choose_another_text = _ ( '<STR_LIT>' ) <EOL> link_to_chosen_text = _ ( '<STR_LIT>' ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( AdminDocumentChooser , self ) . __init__ ( ** kwargs ) <EOL> self . document_model = get_document_model ( ) <EOL> def render_html ( self , name , value , attrs ) : <EOL> instance , value = self . get_instance_and_id ( self . document_model , value ) <EOL> original_field_html = super ( AdminDocumentChooser , self ) . render_html ( name , value , attrs ) <EOL> return render_to_string ( "<STR_LIT>" , { <EOL> '<STR_LIT>' : self , <EOL> '<STR_LIT>' : original_field_html , <EOL> '<STR_LIT>' : attrs , <EOL> '<STR_LIT:value>' : value , <EOL> '<STR_LIT>' : instance , <EOL> } ) <EOL> def render_js_init ( self , id_ , name , value ) : <EOL> return "<STR_LIT>" . format ( json . dumps ( id_ ) ) </s>
