<s> from django import forms <EOL> from django . contrib import admin <EOL> from etc import cache <EOL> from entity_items . admin import MediaItemInline , ActionInline , AdvocateInline , TimelineInline , CenterContentItemInline , LeftContentItemInline <EOL> from issue . models import Issue <EOL> from org . models import Org , RelatedOrg , OrgIssueRelationship , Alias <EOL> from users . models import User , Location <EOL> from cust_admin . views . main import ExtChangeList <EOL> from cust_admin . widgets import ForeignKeyToObjWidget <EOL> class AliasInline ( admin . TabularInline ) : <EOL> model = Alias <EOL> extra = <NUM_LIT:0> <EOL> classes = ( '<STR_LIT>' , ) <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> class AdminsInline ( admin . TabularInline ) : <EOL> model = Org . admins . through <EOL> extra = <NUM_LIT:0> <EOL> classes = ( '<STR_LIT>' , ) <EOL> related_field_lookups = { <EOL> '<STR_LIT>' : [ '<STR_LIT:user>' ] <EOL> } <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> def formfield_for_dbfield ( self , db_field , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT:user>' : <EOL> kwargs [ '<STR_LIT>' ] = ForeignKeyToObjWidget ( rel = Org . admins . through . _meta . get_field ( '<STR_LIT:user>' ) . rel ) <EOL> return super ( AdminsInline , self ) . formfield_for_dbfield ( db_field , ** kwargs ) <EOL> class IssuesInlineForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Org . issues . through <EOL> widgets = { '<STR_LIT>' : forms . HiddenInput } <EOL> class IssuesInline ( admin . TabularInline ) : <EOL> model = Org . issues . through <EOL> extra = <NUM_LIT:0> <EOL> form = IssuesInlineForm <EOL> classes = ( '<STR_LIT>' , ) <EOL> sortable_field_name = "<STR_LIT>" <EOL> related_field_lookups = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> verbose_name = "<STR_LIT>" <EOL> verbose_name_plural = "<STR_LIT>" <EOL> def formfield_for_dbfield ( self , db_field , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = ForeignKeyToObjWidget ( rel = Org . issues . through . _meta . get_field ( '<STR_LIT>' ) . rel ) <EOL> return super ( IssuesInline , self ) . formfield_for_dbfield ( db_field , ** kwargs ) <EOL> class LocationsInline ( admin . TabularInline ) : <EOL> model = Org . working_locations . through <EOL> extra = <NUM_LIT:0> <EOL> classes = ( '<STR_LIT>' , ) <EOL> related_field_lookups = { <EOL> '<STR_LIT>' : [ '<STR_LIT:location>' ] <EOL> } <EOL> verbose_name = '<STR_LIT>' <EOL> verbose_name_plural = '<STR_LIT>' <EOL> def formfield_for_dbfield ( self , db_field , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT:location>' : <EOL> kwargs [ '<STR_LIT>' ] = ForeignKeyToObjWidget ( rel = Org . working_locations . through . _meta . get_field ( '<STR_LIT:location>' ) . rel ) <EOL> return super ( LocationsInline , self ) . formfield_for_dbfield ( db_field , ** kwargs ) <EOL> class OrgForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Org <EOL> widgets = { <EOL> '<STR_LIT:location>' : ForeignKeyToObjWidget ( rel = Org . _meta . get_field ( '<STR_LIT:location>' ) . rel ) , <EOL> '<STR_LIT>' : forms . TextInput ( attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) , <EOL> '<STR_LIT>' : forms . Textarea ( ) , <EOL> } <EOL> class Media : <EOL> js = [ '<STR_LIT>' ] <EOL> css = { '<STR_LIT:all>' : ( '<STR_LIT>' , ) } <EOL> class OrgAdmin ( admin . ModelAdmin ) : <EOL> form = OrgForm <EOL> search_fields = [ '<STR_LIT:name>' , '<STR_LIT:email>' , '<STR_LIT>' ] <EOL> search_fields_verbose = [ '<STR_LIT:Name>' , '<STR_LIT>' ] <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> change_list_template = "<STR_LIT>" <EOL> def get_changelist ( self , request , ** kwargs ) : <EOL> return ExtChangeList <EOL> fieldsets = ( <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( ( '<STR_LIT:name>' , '<STR_LIT>' , ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:email>' , '<STR_LIT>' , ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:size>' , ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:location>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) , ) <EOL> } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ) , <EOL> ) <EOL> } ) , <EOL> ( "<STR_LIT>" , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> } ) , <EOL> ) <EOL> readonly_fields = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> inlines = [ CenterContentItemInline , LeftContentItemInline , MediaItemInline , TimelineInline , ActionInline , AdvocateInline , AliasInline , AdminsInline , IssuesInline , LocationsInline , ] <EOL> def save_model ( self , request , obj , form , change ) : <EOL> cache . bust ( obj , update = False ) <EOL> super ( self . __class__ , self ) . save_model ( request , obj , form , change ) <EOL> admin . site . register ( Org , OrgAdmin ) </s>
