<s> from __future__ import unicode_literals <EOL> import os <EOL> import tempfile <EOL> from wsgiref . util import FileWrapper <EOL> from django import forms <EOL> from django . conf . urls import url <EOL> from django . contrib import admin <EOL> from django . contrib . admin import BooleanFieldListFilter <EOL> from django . contrib . admin . views . main import ChangeList <EOL> from django . contrib . auth . admin import GroupAdmin , UserAdmin <EOL> from django . contrib . auth . models import Group , User <EOL> from django . core . exceptions import ValidationError <EOL> from django . core . files . storage import FileSystemStorage <EOL> from django . core . mail import EmailMessage <EOL> from django . db import models <EOL> from django . forms . models import BaseModelFormSet <EOL> from django . http import HttpResponse , StreamingHttpResponse <EOL> from django . utils . html import format_html <EOL> from django . utils . safestring import mark_safe <EOL> from django . utils . six import StringIO <EOL> from . models import ( <EOL> Actor , AdminOrderedAdminMethod , AdminOrderedCallable , AdminOrderedField , <EOL> AdminOrderedModelMethod , Album , Answer , Article , BarAccount , Book , <EOL> Bookmark , Category , Chapter , ChapterXtra1 , Child , ChildOfReferer , Choice , <EOL> City , Collector , Color , Color2 , ComplexSortedPerson , CoverLetter , <EOL> CustomArticle , CyclicOne , CyclicTwo , DependentChild , DooHickey , EmptyModel , <EOL> EmptyModelHidden , EmptyModelMixin , EmptyModelVisible , ExplicitlyProvidedPK , <EOL> ExternalSubscriber , Fabric , FancyDoodad , FieldOverridePost , <EOL> FilteredManager , FooAccount , FoodDelivery , FunkyTag , Gadget , Gallery , <EOL> GenRelReference , Grommet , ImplicitlyGeneratedPK , Ingredient , <EOL> InlineReference , InlineReferer , Inquisition , Language , Link , <EOL> MainPrepopulated , ModelWithStringPrimaryKey , NotReferenced , OldSubscriber , <EOL> OtherStory , Paper , Parent , ParentWithDependentChildren , ParentWithUUIDPK , <EOL> Person , Persona , Picture , Pizza , Plot , PlotDetails , PlotProxy , <EOL> PluggableSearchPerson , Podcast , Post , PrePopulatedPost , <EOL> PrePopulatedPostLargeSlug , PrePopulatedSubPost , Promo , Question , Recipe , <EOL> Recommendation , Recommender , ReferencedByGenRel , ReferencedByInline , <EOL> ReferencedByParent , RelatedPrepopulated , RelatedWithUUIDPKModel , Report , <EOL> Reservation , Restaurant , RowLevelChangePermissionModel , Section , <EOL> ShortMessage , Simple , Sketch , State , Story , StumpJoke , Subscriber , <EOL> SuperVillain , Telegram , Thing , Topping , UnchangeableObject , <EOL> UndeletableObject , UnorderedObject , UserMessenger , Villain , Vodcast , <EOL> Whatsit , Widget , Worker , WorkHour , <EOL> ) <EOL> def callable_year ( dt_value ) : <EOL> try : <EOL> return dt_value . year <EOL> except AttributeError : <EOL> return None <EOL> callable_year . admin_order_field = '<STR_LIT:date>' <EOL> class ArticleInline ( admin . TabularInline ) : <EOL> model = Article <EOL> fk_name = '<STR_LIT>' <EOL> prepopulated_fields = { <EOL> '<STR_LIT:title>' : ( '<STR_LIT:content>' , ) <EOL> } <EOL> fieldsets = ( <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:title>' , '<STR_LIT:content>' ) <EOL> } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:date>' , '<STR_LIT>' ) <EOL> } ) <EOL> ) <EOL> class ChapterInline ( admin . TabularInline ) : <EOL> model = Chapter <EOL> class ChapterXtra1Admin ( admin . ModelAdmin ) : <EOL> list_filter = ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ) <EOL> class ArticleAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( <EOL> '<STR_LIT:content>' , '<STR_LIT:date>' , callable_year , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , lambda obj : obj . title , <EOL> ) <EOL> list_editable = ( '<STR_LIT>' , ) <EOL> list_filter = ( '<STR_LIT:date>' , '<STR_LIT>' ) <EOL> view_on_site = False <EOL> fieldsets = ( <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:title>' , '<STR_LIT:content>' ) <EOL> } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:date>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> } ) <EOL> ) <EOL> def changelist_view ( self , request ) : <EOL> "<STR_LIT>" <EOL> return super ( ArticleAdmin , self ) . changelist_view ( <EOL> request , extra_context = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ) <EOL> def modeladmin_year ( self , obj ) : <EOL> return obj . date . year <EOL> modeladmin_year . admin_order_field = '<STR_LIT:date>' <EOL> modeladmin_year . short_description = None <EOL> def delete_model ( self , request , obj ) : <EOL> EmailMessage ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] <EOL> ) . send ( ) <EOL> return super ( ArticleAdmin , self ) . delete_model ( request , obj ) <EOL> def save_model ( self , request , obj , form , change = True ) : <EOL> EmailMessage ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] <EOL> ) . send ( ) <EOL> return super ( ArticleAdmin , self ) . save_model ( request , obj , form , change ) <EOL> class ArticleAdmin2 ( admin . ModelAdmin ) : <EOL> def has_module_permission ( self , request ) : <EOL> return False <EOL> class RowLevelChangePermissionModelAdmin ( admin . ModelAdmin ) : <EOL> def has_change_permission ( self , request , obj = None ) : <EOL> """<STR_LIT>""" <EOL> return request . user . is_staff and ( obj is not None ) and ( obj . id % <NUM_LIT:2> == <NUM_LIT:0> ) <EOL> class CustomArticleAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> change_list_template = '<STR_LIT>' <EOL> change_form_template = '<STR_LIT>' <EOL> add_form_template = '<STR_LIT>' <EOL> object_history_template = '<STR_LIT>' <EOL> delete_confirmation_template = '<STR_LIT>' <EOL> delete_selected_confirmation_template = '<STR_LIT>' <EOL> def changelist_view ( self , request ) : <EOL> "<STR_LIT>" <EOL> return super ( CustomArticleAdmin , self ) . changelist_view ( <EOL> request , extra_context = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ) <EOL> class ThingAdmin ( admin . ModelAdmin ) : <EOL> list_filter = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> class InquisitionAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def sketch ( self , obj ) : <EOL> return '<STR_LIT>' <EOL> class SketchAdmin ( admin . ModelAdmin ) : <EOL> raw_id_fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class FabricAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT>' , ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> class BasePersonModelFormSet ( BaseModelFormSet ) : <EOL> def clean ( self ) : <EOL> for person_dict in self . cleaned_data : <EOL> person = person_dict . get ( '<STR_LIT:id>' ) <EOL> alive = person_dict . get ( '<STR_LIT>' ) <EOL> if person and alive and person . name == "<STR_LIT>" : <EOL> raise forms . ValidationError ( "<STR_LIT>" ) <EOL> class PersonAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_editable = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> search_fields = ( '<STR_LIT>' , ) <EOL> save_as = True <EOL> def get_changelist_formset ( self , request , ** kwargs ) : <EOL> return super ( PersonAdmin , self ) . get_changelist_formset ( request , formset = BasePersonModelFormSet , ** kwargs ) <EOL> def get_queryset ( self , request ) : <EOL> return super ( PersonAdmin , self ) . get_queryset ( request ) . order_by ( '<STR_LIT>' ) <EOL> class FooAccountAdmin ( admin . StackedInline ) : <EOL> model = FooAccount <EOL> extra = <NUM_LIT:1> <EOL> class BarAccountAdmin ( admin . StackedInline ) : <EOL> model = BarAccount <EOL> extra = <NUM_LIT:1> <EOL> class PersonaAdmin ( admin . ModelAdmin ) : <EOL> inlines = ( <EOL> FooAccountAdmin , <EOL> BarAccountAdmin <EOL> ) <EOL> class SubscriberAdmin ( admin . ModelAdmin ) : <EOL> actions = [ '<STR_LIT>' ] <EOL> def mail_admin ( self , request , selected ) : <EOL> EmailMessage ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] <EOL> ) . send ( ) <EOL> def external_mail ( modeladmin , request , selected ) : <EOL> EmailMessage ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] <EOL> ) . send ( ) <EOL> external_mail . short_description = '<STR_LIT>' <EOL> def redirect_to ( modeladmin , request , selected ) : <EOL> from django . http import HttpResponseRedirect <EOL> return HttpResponseRedirect ( '<STR_LIT>' ) <EOL> redirect_to . short_description = '<STR_LIT>' <EOL> def download ( modeladmin , request , selected ) : <EOL> buf = StringIO ( '<STR_LIT>' ) <EOL> return StreamingHttpResponse ( FileWrapper ( buf ) ) <EOL> download . short_description = '<STR_LIT>' <EOL> def no_perm ( modeladmin , request , selected ) : <EOL> return HttpResponse ( content = '<STR_LIT>' , <EOL> status = <NUM_LIT> ) <EOL> no_perm . short_description = '<STR_LIT>' <EOL> class ExternalSubscriberAdmin ( admin . ModelAdmin ) : <EOL> actions = [ redirect_to , external_mail , download , no_perm ] <EOL> class PodcastAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> list_editable = ( '<STR_LIT>' , ) <EOL> date_hierarchy = '<STR_LIT>' <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> class VodcastAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> list_editable = ( '<STR_LIT>' , ) <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> class ChildInline ( admin . StackedInline ) : <EOL> model = Child <EOL> class ParentAdmin ( admin . ModelAdmin ) : <EOL> model = Parent <EOL> inlines = [ ChildInline ] <EOL> save_as = True <EOL> list_editable = ( '<STR_LIT:name>' , ) <EOL> def save_related ( self , request , form , formsets , change ) : <EOL> super ( ParentAdmin , self ) . save_related ( request , form , formsets , change ) <EOL> first_name , last_name = form . instance . name . split ( ) <EOL> for child in form . instance . child_set . all ( ) : <EOL> if len ( child . name . split ( ) ) < <NUM_LIT:2> : <EOL> child . name = child . name + '<STR_LIT:U+0020>' + last_name <EOL> child . save ( ) <EOL> class EmptyModelAdmin ( admin . ModelAdmin ) : <EOL> def get_queryset ( self , request ) : <EOL> return super ( EmptyModelAdmin , self ) . get_queryset ( request ) . filter ( pk__gt = <NUM_LIT:1> ) <EOL> class OldSubscriberAdmin ( admin . ModelAdmin ) : <EOL> actions = None <EOL> temp_storage = FileSystemStorage ( tempfile . mkdtemp ( ) ) <EOL> UPLOAD_TO = os . path . join ( temp_storage . location , '<STR_LIT>' ) <EOL> class PictureInline ( admin . TabularInline ) : <EOL> model = Picture <EOL> extra = <NUM_LIT:1> <EOL> class GalleryAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ PictureInline ] <EOL> class PictureAdmin ( admin . ModelAdmin ) : <EOL> pass <EOL> class LanguageAdmin ( admin . ModelAdmin ) : <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' ] <EOL> list_editable = [ '<STR_LIT>' ] <EOL> class RecommendationAdmin ( admin . ModelAdmin ) : <EOL> show_full_result_count = False <EOL> search_fields = ( '<STR_LIT>' , '<STR_LIT>' , ) <EOL> class WidgetInline ( admin . StackedInline ) : <EOL> model = Widget <EOL> class DooHickeyInline ( admin . StackedInline ) : <EOL> model = DooHickey <EOL> class GrommetInline ( admin . StackedInline ) : <EOL> model = Grommet <EOL> class WhatsitInline ( admin . StackedInline ) : <EOL> model = Whatsit <EOL> class FancyDoodadInline ( admin . StackedInline ) : <EOL> model = FancyDoodad <EOL> class CategoryAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_editable = ( '<STR_LIT>' , ) <EOL> class CategoryInline ( admin . StackedInline ) : <EOL> model = Category <EOL> class CollectorAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ <EOL> WidgetInline , DooHickeyInline , GrommetInline , WhatsitInline , <EOL> FancyDoodadInline , CategoryInline <EOL> ] <EOL> class LinkInline ( admin . TabularInline ) : <EOL> model = Link <EOL> extra = <NUM_LIT:1> <EOL> readonly_fields = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def multiline ( self , instance ) : <EOL> return "<STR_LIT>" <EOL> class SubPostInline ( admin . TabularInline ) : <EOL> model = PrePopulatedSubPost <EOL> prepopulated_fields = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) <EOL> } <EOL> def get_readonly_fields ( self , request , obj = None ) : <EOL> if obj and obj . published : <EOL> return ( '<STR_LIT>' , ) <EOL> return self . readonly_fields <EOL> def get_prepopulated_fields ( self , request , obj = None ) : <EOL> if obj and obj . published : <EOL> return { } <EOL> return self . prepopulated_fields <EOL> class PrePopulatedPostAdmin ( admin . ModelAdmin ) : <EOL> list_display = [ '<STR_LIT:title>' , '<STR_LIT>' ] <EOL> prepopulated_fields = { <EOL> '<STR_LIT>' : ( '<STR_LIT:title>' , ) <EOL> } <EOL> inlines = [ SubPostInline ] <EOL> def get_readonly_fields ( self , request , obj = None ) : <EOL> if obj and obj . published : <EOL> return ( '<STR_LIT>' , ) <EOL> return self . readonly_fields <EOL> def get_prepopulated_fields ( self , request , obj = None ) : <EOL> if obj and obj . published : <EOL> return { } <EOL> return self . prepopulated_fields <EOL> class PostAdmin ( admin . ModelAdmin ) : <EOL> list_display = [ '<STR_LIT:title>' , '<STR_LIT>' ] <EOL> readonly_fields = ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:value>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , lambda obj : "<STR_LIT:foo>" , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> ) <EOL> inlines = [ <EOL> LinkInline <EOL> ] <EOL> def coolness ( self , instance ) : <EOL> if instance . pk : <EOL> return "<STR_LIT>" % instance . pk <EOL> else : <EOL> return "<STR_LIT>" <EOL> def value ( self , instance ) : <EOL> return <NUM_LIT:1000> <EOL> value . short_description = '<STR_LIT>' <EOL> def multiline ( self , instance ) : <EOL> return "<STR_LIT>" <EOL> def multiline_html ( self , instance ) : <EOL> return mark_safe ( "<STR_LIT>" ) <EOL> def multiline_html_allow_tags ( self , instance ) : <EOL> return "<STR_LIT>" <EOL> multiline_html_allow_tags . allow_tags = True <EOL> class FieldOverridePostForm ( forms . ModelForm ) : <EOL> model = FieldOverridePost <EOL> class Meta : <EOL> help_texts = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> labels = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> class FieldOverridePostAdmin ( PostAdmin ) : <EOL> form = FieldOverridePostForm <EOL> class CustomChangeList ( ChangeList ) : <EOL> def get_queryset ( self , request ) : <EOL> return self . root_queryset . filter ( pk = <NUM_LIT> ) <EOL> class GadgetAdmin ( admin . ModelAdmin ) : <EOL> def get_changelist ( self , request , ** kwargs ) : <EOL> return CustomChangeList <EOL> class ToppingAdmin ( admin . ModelAdmin ) : <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class PizzaAdmin ( admin . ModelAdmin ) : <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class WorkHourAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> class FoodDeliveryAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_editable = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class CoverLetterAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> def get_queryset ( self , request ) : <EOL> return super ( CoverLetterAdmin , self ) . get_queryset ( request ) . defer ( '<STR_LIT>' ) <EOL> class PaperAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> def get_queryset ( self , request ) : <EOL> return super ( PaperAdmin , self ) . get_queryset ( request ) . only ( '<STR_LIT:title>' ) <EOL> class ShortMessageAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> def get_queryset ( self , request ) : <EOL> return super ( ShortMessageAdmin , self ) . get_queryset ( request ) . defer ( '<STR_LIT>' ) <EOL> class TelegramAdmin ( admin . ModelAdmin ) : <EOL> """<STR_LIT>""" <EOL> def get_queryset ( self , request ) : <EOL> return super ( TelegramAdmin , self ) . get_queryset ( request ) . only ( '<STR_LIT:title>' ) <EOL> class StoryForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> widgets = { '<STR_LIT:title>' : forms . HiddenInput } <EOL> class StoryAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:id>' , '<STR_LIT:title>' , '<STR_LIT:content>' ) <EOL> list_display_links = ( '<STR_LIT:title>' , ) <EOL> list_editable = ( '<STR_LIT:content>' , ) <EOL> form = StoryForm <EOL> ordering = [ "<STR_LIT>" ] <EOL> class OtherStoryAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:id>' , '<STR_LIT:title>' , '<STR_LIT:content>' ) <EOL> list_display_links = ( '<STR_LIT:title>' , '<STR_LIT:id>' ) <EOL> list_editable = ( '<STR_LIT:content>' , ) <EOL> ordering = [ "<STR_LIT>" ] <EOL> class ComplexSortedPersonAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def colored_name ( self , obj ) : <EOL> return format_html ( '<STR_LIT>' , obj . name ) <EOL> colored_name . admin_order_field = '<STR_LIT:name>' <EOL> class PluggableSearchPersonAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> search_fields = ( '<STR_LIT:name>' , ) <EOL> def get_search_results ( self , request , queryset , search_term ) : <EOL> queryset , use_distinct = super ( PluggableSearchPersonAdmin , self ) . get_search_results ( <EOL> request , queryset , search_term <EOL> ) <EOL> try : <EOL> search_term_as_int = int ( search_term ) <EOL> except ValueError : <EOL> pass <EOL> else : <EOL> queryset |= self . model . objects . filter ( age = search_term_as_int ) <EOL> return queryset , use_distinct <EOL> class AlbumAdmin ( admin . ModelAdmin ) : <EOL> list_filter = [ '<STR_LIT:title>' ] <EOL> class PrePopulatedPostLargeSlugAdmin ( admin . ModelAdmin ) : <EOL> prepopulated_fields = { <EOL> '<STR_LIT>' : ( '<STR_LIT:title>' , ) <EOL> } <EOL> class AdminOrderedFieldAdmin ( admin . ModelAdmin ) : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class AdminOrderedModelMethodAdmin ( admin . ModelAdmin ) : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class AdminOrderedAdminMethodAdmin ( admin . ModelAdmin ) : <EOL> def some_admin_order ( self , obj ) : <EOL> return obj . order <EOL> some_admin_order . admin_order_field = '<STR_LIT>' <EOL> ordering = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def admin_ordered_callable ( obj ) : <EOL> return obj . order <EOL> admin_ordered_callable . admin_order_field = '<STR_LIT>' <EOL> class AdminOrderedCallableAdmin ( admin . ModelAdmin ) : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> list_display = ( '<STR_LIT>' , admin_ordered_callable ) <EOL> class ReportAdmin ( admin . ModelAdmin ) : <EOL> def extra ( self , request ) : <EOL> return HttpResponse ( ) <EOL> def get_urls ( self ) : <EOL> return [ <EOL> url ( r'<STR_LIT>' , <EOL> self . extra , <EOL> name = '<STR_LIT>' ) , <EOL> ] <EOL> class CustomTemplateBooleanFieldListFilter ( BooleanFieldListFilter ) : <EOL> template = '<STR_LIT>' <EOL> class CustomTemplateFilterColorAdmin ( admin . ModelAdmin ) : <EOL> list_filter = ( ( '<STR_LIT>' , CustomTemplateBooleanFieldListFilter ) , ) <EOL> class RelatedPrepopulatedInline1 ( admin . StackedInline ) : <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( ( '<STR_LIT>' , '<STR_LIT:status>' ) , ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , ) , ) <EOL> } ) , <EOL> ) <EOL> formfield_overrides = { models . CharField : { '<STR_LIT>' : False } } <EOL> model = RelatedPrepopulated <EOL> extra = <NUM_LIT:1> <EOL> prepopulated_fields = { '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT:status>' , '<STR_LIT:name>' ] } <EOL> class RelatedPrepopulatedInline2 ( admin . TabularInline ) : <EOL> model = RelatedPrepopulated <EOL> extra = <NUM_LIT:1> <EOL> prepopulated_fields = { '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT:status>' , '<STR_LIT:name>' ] } <EOL> class MainPrepopulatedAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ RelatedPrepopulatedInline1 , RelatedPrepopulatedInline2 ] <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( ( '<STR_LIT>' , '<STR_LIT:status>' ) , ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> } ) , <EOL> ) <EOL> formfield_overrides = { models . CharField : { '<STR_LIT>' : False } } <EOL> prepopulated_fields = { <EOL> '<STR_LIT>' : [ '<STR_LIT:name>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT:status>' , '<STR_LIT:name>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT:name>' ] , <EOL> } <EOL> class UnorderedObjectAdmin ( admin . ModelAdmin ) : <EOL> list_display = [ '<STR_LIT:name>' ] <EOL> list_editable = [ '<STR_LIT:name>' ] <EOL> list_per_page = <NUM_LIT:2> <EOL> class UndeletableObjectAdmin ( admin . ModelAdmin ) : <EOL> def change_view ( self , * args , ** kwargs ) : <EOL> kwargs [ '<STR_LIT>' ] = { '<STR_LIT>' : False } <EOL> return super ( UndeletableObjectAdmin , self ) . change_view ( * args , ** kwargs ) <EOL> class UnchangeableObjectAdmin ( admin . ModelAdmin ) : <EOL> def get_urls ( self ) : <EOL> urlpatterns = super ( UnchangeableObjectAdmin , self ) . get_urls ( ) <EOL> return [ p for p in urlpatterns if p . name and not p . name . endswith ( "<STR_LIT>" ) ] <EOL> def callable_on_unknown ( obj ) : <EOL> return obj . unknown <EOL> class AttributeErrorRaisingAdmin ( admin . ModelAdmin ) : <EOL> list_display = [ callable_on_unknown , ] <EOL> class CustomManagerAdmin ( admin . ModelAdmin ) : <EOL> def get_queryset ( self , request ) : <EOL> return FilteredManager . objects <EOL> class MessageTestingAdmin ( admin . ModelAdmin ) : <EOL> actions = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def message_debug ( self , request , selected ) : <EOL> self . message_user ( request , "<STR_LIT>" , level = "<STR_LIT>" ) <EOL> def message_info ( self , request , selected ) : <EOL> self . message_user ( request , "<STR_LIT>" , level = "<STR_LIT:info>" ) <EOL> def message_success ( self , request , selected ) : <EOL> self . message_user ( request , "<STR_LIT>" , level = "<STR_LIT:success>" ) <EOL> def message_warning ( self , request , selected ) : <EOL> self . message_user ( request , "<STR_LIT>" , level = "<STR_LIT>" ) <EOL> def message_error ( self , request , selected ) : <EOL> self . message_user ( request , "<STR_LIT>" , level = "<STR_LIT:error>" ) <EOL> def message_extra_tags ( self , request , selected ) : <EOL> self . message_user ( request , "<STR_LIT>" , extra_tags = "<STR_LIT>" ) <EOL> class ChoiceList ( admin . ModelAdmin ) : <EOL> list_display = [ '<STR_LIT>' ] <EOL> readonly_fields = [ '<STR_LIT>' ] <EOL> fields = [ '<STR_LIT>' ] <EOL> class DependentChildAdminForm ( forms . ModelForm ) : <EOL> """<STR_LIT>""" <EOL> def clean ( self ) : <EOL> parent = self . cleaned_data . get ( '<STR_LIT>' ) <EOL> if parent . family_name and parent . family_name != self . cleaned_data . get ( '<STR_LIT>' ) : <EOL> raise ValidationError ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> return super ( DependentChildAdminForm , self ) . clean ( ) <EOL> class DependentChildInline ( admin . TabularInline ) : <EOL> model = DependentChild <EOL> form = DependentChildAdminForm <EOL> class ParentWithDependentChildrenAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ DependentChildInline ] <EOL> class FormWithoutHiddenField ( forms . ModelForm ) : <EOL> first = forms . CharField ( ) <EOL> second = forms . CharField ( ) <EOL> class FormWithoutVisibleField ( forms . ModelForm ) : <EOL> first = forms . CharField ( widget = forms . HiddenInput ) <EOL> second = forms . CharField ( widget = forms . HiddenInput ) <EOL> class FormWithVisibleAndHiddenField ( forms . ModelForm ) : <EOL> first = forms . CharField ( widget = forms . HiddenInput ) <EOL> second = forms . CharField ( ) <EOL> class EmptyModelVisibleAdmin ( admin . ModelAdmin ) : <EOL> form = FormWithoutHiddenField <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) , <EOL> } ) , <EOL> ) <EOL> class EmptyModelHiddenAdmin ( admin . ModelAdmin ) : <EOL> form = FormWithoutVisibleField <EOL> fieldsets = EmptyModelVisibleAdmin . fieldsets <EOL> class EmptyModelMixinAdmin ( admin . ModelAdmin ) : <EOL> form = FormWithVisibleAndHiddenField <EOL> fieldsets = EmptyModelVisibleAdmin . fieldsets <EOL> class CityInlineAdmin ( admin . TabularInline ) : <EOL> model = City <EOL> view_on_site = False <EOL> class StateAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ CityInlineAdmin ] <EOL> class RestaurantInlineAdmin ( admin . TabularInline ) : <EOL> model = Restaurant <EOL> view_on_site = True <EOL> class CityAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ RestaurantInlineAdmin ] <EOL> view_on_site = True <EOL> class WorkerAdmin ( admin . ModelAdmin ) : <EOL> def view_on_site ( self , obj ) : <EOL> return '<STR_LIT>' % ( obj . surname , obj . name ) <EOL> class WorkerInlineAdmin ( admin . TabularInline ) : <EOL> model = Worker <EOL> def view_on_site ( self , obj ) : <EOL> return '<STR_LIT>' % ( obj . surname , obj . name ) <EOL> class RestaurantAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ WorkerInlineAdmin ] <EOL> view_on_site = False <EOL> def get_changeform_initial_data ( self , request ) : <EOL> return { '<STR_LIT:name>' : '<STR_LIT>' } <EOL> class FunkyTagAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> class InlineReferenceInline ( admin . TabularInline ) : <EOL> model = InlineReference <EOL> class InlineRefererAdmin ( admin . ModelAdmin ) : <EOL> inlines = [ InlineReferenceInline ] <EOL> class PlotReadonlyAdmin ( admin . ModelAdmin ) : <EOL> readonly_fields = ( '<STR_LIT>' , ) <EOL> class GetFormsetsArgumentCheckingAdmin ( admin . ModelAdmin ) : <EOL> fields = [ '<STR_LIT:name>' ] <EOL> def add_view ( self , request , * args , ** kwargs ) : <EOL> request . is_add_view = True <EOL> return super ( GetFormsetsArgumentCheckingAdmin , self ) . add_view ( request , * args , ** kwargs ) <EOL> def change_view ( self , request , * args , ** kwargs ) : <EOL> request . is_add_view = False <EOL> return super ( GetFormsetsArgumentCheckingAdmin , self ) . change_view ( request , * args , ** kwargs ) <EOL> def get_formsets_with_inlines ( self , request , obj = None ) : <EOL> if request . is_add_view and obj is not None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if not request . is_add_view and obj is None : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return super ( GetFormsetsArgumentCheckingAdmin , self ) . get_formsets_with_inlines ( request , obj ) <EOL> site = admin . AdminSite ( name = "<STR_LIT>" ) <EOL> site . site_url = '<STR_LIT>' <EOL> site . register ( Article , ArticleAdmin ) <EOL> site . register ( CustomArticle , CustomArticleAdmin ) <EOL> site . register ( Section , save_as = True , inlines = [ ArticleInline ] , readonly_fields = [ '<STR_LIT>' ] ) <EOL> site . register ( ModelWithStringPrimaryKey ) <EOL> site . register ( Color ) <EOL> site . register ( Thing , ThingAdmin ) <EOL> site . register ( Actor ) <EOL> site . register ( Inquisition , InquisitionAdmin ) <EOL> site . register ( Sketch , SketchAdmin ) <EOL> site . register ( Person , PersonAdmin ) <EOL> site . register ( Persona , PersonaAdmin ) <EOL> site . register ( Subscriber , SubscriberAdmin ) <EOL> site . register ( ExternalSubscriber , ExternalSubscriberAdmin ) <EOL> site . register ( OldSubscriber , OldSubscriberAdmin ) <EOL> site . register ( Podcast , PodcastAdmin ) <EOL> site . register ( Vodcast , VodcastAdmin ) <EOL> site . register ( Parent , ParentAdmin ) <EOL> site . register ( EmptyModel , EmptyModelAdmin ) <EOL> site . register ( Fabric , FabricAdmin ) <EOL> site . register ( Gallery , GalleryAdmin ) <EOL> site . register ( Picture , PictureAdmin ) <EOL> site . register ( Language , LanguageAdmin ) <EOL> site . register ( Recommendation , RecommendationAdmin ) <EOL> site . register ( Recommender ) <EOL> site . register ( Collector , CollectorAdmin ) <EOL> site . register ( Category , CategoryAdmin ) <EOL> site . register ( Post , PostAdmin ) <EOL> site . register ( FieldOverridePost , FieldOverridePostAdmin ) <EOL> site . register ( Gadget , GadgetAdmin ) <EOL> site . register ( Villain ) <EOL> site . register ( SuperVillain ) <EOL> site . register ( Plot ) <EOL> site . register ( PlotDetails ) <EOL> site . register ( PlotProxy , PlotReadonlyAdmin ) <EOL> site . register ( Bookmark ) <EOL> site . register ( CyclicOne ) <EOL> site . register ( CyclicTwo ) <EOL> site . register ( WorkHour , WorkHourAdmin ) <EOL> site . register ( Reservation ) <EOL> site . register ( FoodDelivery , FoodDeliveryAdmin ) <EOL> site . register ( RowLevelChangePermissionModel , RowLevelChangePermissionModelAdmin ) <EOL> site . register ( Paper , PaperAdmin ) <EOL> site . register ( CoverLetter , CoverLetterAdmin ) <EOL> site . register ( ShortMessage , ShortMessageAdmin ) <EOL> site . register ( Telegram , TelegramAdmin ) <EOL> site . register ( Story , StoryAdmin ) <EOL> site . register ( OtherStory , OtherStoryAdmin ) <EOL> site . register ( Report , ReportAdmin ) <EOL> site . register ( MainPrepopulated , MainPrepopulatedAdmin ) <EOL> site . register ( UnorderedObject , UnorderedObjectAdmin ) <EOL> site . register ( UndeletableObject , UndeletableObjectAdmin ) <EOL> site . register ( UnchangeableObject , UnchangeableObjectAdmin ) <EOL> site . register ( State , StateAdmin ) <EOL> site . register ( City , CityAdmin ) <EOL> site . register ( Restaurant , RestaurantAdmin ) <EOL> site . register ( Worker , WorkerAdmin ) <EOL> site . register ( FunkyTag , FunkyTagAdmin ) <EOL> site . register ( ReferencedByParent ) <EOL> site . register ( ChildOfReferer ) <EOL> site . register ( ReferencedByInline ) <EOL> site . register ( InlineReferer , InlineRefererAdmin ) <EOL> site . register ( ReferencedByGenRel ) <EOL> site . register ( GenRelReference ) <EOL> site . register ( ParentWithUUIDPK ) <EOL> site . register ( RelatedWithUUIDPKModel ) <EOL> site . register ( Book , inlines = [ ChapterInline ] ) <EOL> site . register ( Promo ) <EOL> site . register ( ChapterXtra1 , ChapterXtra1Admin ) <EOL> site . register ( Pizza , PizzaAdmin ) <EOL> site . register ( Topping , ToppingAdmin ) <EOL> site . register ( Album , AlbumAdmin ) <EOL> site . register ( Question ) <EOL> site . register ( Answer ) <EOL> site . register ( PrePopulatedPost , PrePopulatedPostAdmin ) <EOL> site . register ( ComplexSortedPerson , ComplexSortedPersonAdmin ) <EOL> site . register ( FilteredManager , CustomManagerAdmin ) <EOL> site . register ( PluggableSearchPerson , PluggableSearchPersonAdmin ) <EOL> site . register ( PrePopulatedPostLargeSlug , PrePopulatedPostLargeSlugAdmin ) <EOL> site . register ( AdminOrderedField , AdminOrderedFieldAdmin ) <EOL> site . register ( AdminOrderedModelMethod , AdminOrderedModelMethodAdmin ) <EOL> site . register ( AdminOrderedAdminMethod , AdminOrderedAdminMethodAdmin ) <EOL> site . register ( AdminOrderedCallable , AdminOrderedCallableAdmin ) <EOL> site . register ( Color2 , CustomTemplateFilterColorAdmin ) <EOL> site . register ( Simple , AttributeErrorRaisingAdmin ) <EOL> site . register ( UserMessenger , MessageTestingAdmin ) <EOL> site . register ( Choice , ChoiceList ) <EOL> site . register ( ParentWithDependentChildren , ParentWithDependentChildrenAdmin ) <EOL> site . register ( EmptyModelHidden , EmptyModelHiddenAdmin ) <EOL> site . register ( EmptyModelVisible , EmptyModelVisibleAdmin ) <EOL> site . register ( EmptyModelMixin , EmptyModelMixinAdmin ) <EOL> site . register ( StumpJoke ) <EOL> site . register ( Recipe ) <EOL> site . register ( Ingredient ) <EOL> site . register ( NotReferenced ) <EOL> site . register ( ExplicitlyProvidedPK , GetFormsetsArgumentCheckingAdmin ) <EOL> site . register ( ImplicitlyGeneratedPK , GetFormsetsArgumentCheckingAdmin ) <EOL> site . register ( User , UserAdmin ) <EOL> site . register ( Group , GroupAdmin ) <EOL> site2 = admin . AdminSite ( name = "<STR_LIT>" ) <EOL> site2 . register ( User , UserAdmin ) <EOL> site2 . register ( Group , GroupAdmin ) <EOL> site2 . register ( ParentWithUUIDPK ) <EOL> site2 . register ( <EOL> RelatedWithUUIDPKModel , <EOL> list_display = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> list_editable = [ '<STR_LIT>' ] , <EOL> raw_id_fields = [ '<STR_LIT>' ] , <EOL> ) <EOL> site2 . register ( Person , save_as_continue = False ) <EOL> site7 = admin . AdminSite ( name = "<STR_LIT>" ) <EOL> site7 . register ( Article , ArticleAdmin2 ) </s>
