<s> import django <EOL> from django . conf import settings <EOL> from django . contrib . admin import widgets <EOL> from fluent_blogs import appsettings <EOL> from fluent_blogs . admin . abstractbase import AbstractEntryBaseAdmin , AbstractTranslatableEntryBaseAdmin , SeoEntryAdminMixin <EOL> from fluent_blogs . models import get_entry_model <EOL> from parler . models import TranslatableModel <EOL> EntryModel = get_entry_model ( ) <EOL> if django . VERSION >= ( <NUM_LIT:1> , <NUM_LIT:8> ) : <EOL> _model_fields = [ f . name for f in EntryModel . _meta . get_fields ( ) ] <EOL> else : <EOL> _model_fields = EntryModel . _meta . get_all_field_names ( ) <EOL> if issubclass ( EntryModel , TranslatableModel ) : <EOL> _entry_admin_base = AbstractTranslatableEntryBaseAdmin <EOL> _model_fields += EntryModel . _parler_meta . get_all_fields ( ) <EOL> _is_translated = True <EOL> else : <EOL> _entry_admin_base = AbstractEntryBaseAdmin <EOL> _is_translated = False <EOL> class EntryAdmin ( SeoEntryAdminMixin , _entry_admin_base ) : <EOL> """<STR_LIT>""" <EOL> FIELDSET_GENERAL = ( None , { <EOL> '<STR_LIT>' : ( '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT:status>' , ) , <EOL> } ) <EOL> fieldsets = [ <EOL> FIELDSET_GENERAL , <EOL> AbstractEntryBaseAdmin . FIELDSET_PUBLICATION , <EOL> ] <EOL> if '<STR_LIT>' in _model_fields : <EOL> fieldsets . append ( SeoEntryAdminMixin . FIELDSET_SEO ) <EOL> if django . VERSION < ( <NUM_LIT:1> , <NUM_LIT:5> ) : <EOL> declared_fieldsets = fieldsets <EOL> fieldsets = None <EOL> list_filter = [ '<STR_LIT:status>' ] <EOL> html_fields = [ ] <EOL> formfield_overrides = { } <EOL> formfield_overrides . update ( SeoEntryAdminMixin . formfield_overrides ) <EOL> formfield_overrides . update ( { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : widgets . AdminTextareaWidget ( attrs = { '<STR_LIT>' : <NUM_LIT:4> } ) <EOL> } , <EOL> } ) <EOL> def add_view ( self , request , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> extra_context = extra_context or { } <EOL> extra_context [ '<STR_LIT>' ] = self . html_fields <EOL> return super ( EntryAdmin , self ) . add_view ( request , form_url = form_url , extra_context = extra_context ) <EOL> def change_view ( self , request , object_id , form_url = '<STR_LIT>' , extra_context = None ) : <EOL> extra_context = extra_context or { } <EOL> extra_context [ '<STR_LIT>' ] = self . html_fields <EOL> return super ( EntryAdmin , self ) . change_view ( request , object_id , form_url = form_url , extra_context = extra_context ) <EOL> for _f in appsettings . FLUENT_BLOGS_ADMIN_FIELDS : <EOL> if _f in _model_fields : <EOL> EntryAdmin . FIELDSET_GENERAL [ <NUM_LIT:1> ] [ '<STR_LIT>' ] += ( _f , ) <EOL> if '<STR_LIT>' in _model_fields : <EOL> EntryAdmin . list_filter . append ( '<STR_LIT>' ) <EOL> if _is_translated and getattr ( settings , '<STR_LIT>' , None ) : <EOL> EntryAdmin . list_filter . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in _model_fields : <EOL> EntryAdmin . list_filter . append ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in _model_fields : <EOL> EntryAdmin . html_fields . append ( '<STR_LIT>' ) </s>
