<s> import sys <EOL> from django . conf import settings <EOL> from django . contrib import admin <EOL> from django . contrib . admin . widgets import AdminTextInputWidget <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> from django . utils . html import escape <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from fluent_comments import appsettings <EOL> from . compat import get_model as get_comments_model , BASE_APP <EOL> if appsettings . USE_THREADEDCOMMENTS : <EOL> if not hasattr ( settings , '<STR_LIT>' ) or settings . COMMENTS_APP == '<STR_LIT>' : <EOL> raise ImproperlyConfigured ( "<STR_LIT>" ) <EOL> from threadedcomments . admin import ThreadedCommentsAdmin as CommentsAdminBase <EOL> else : <EOL> if BASE_APP == '<STR_LIT>' : <EOL> from django . contrib . comments . admin import CommentsAdmin as CommentsAdminBase <EOL> elif BASE_APP == '<STR_LIT>' : <EOL> from django_comments . admin import CommentsAdmin as CommentsAdminBase <EOL> else : <EOL> raise NotImplementedError ( ) <EOL> class FluentCommentsAdmin ( CommentsAdminBase ) : <EOL> """<STR_LIT>""" <EOL> fieldsets = [ <EOL> ( _ ( '<STR_LIT>' ) , <EOL> { '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) } <EOL> ) , <EOL> ( _ ( '<STR_LIT>' ) , <EOL> { '<STR_LIT>' : ( '<STR_LIT:user>' , '<STR_LIT>' , ) } , <EOL> ) , <EOL> ( _ ( '<STR_LIT>' ) , <EOL> { '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' ) } <EOL> ) , <EOL> ] <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> readonly_fields = ( '<STR_LIT>' , '<STR_LIT:user>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> if appsettings . USE_THREADEDCOMMENTS : <EOL> fieldsets [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] [ '<STR_LIT>' ] = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> fieldsets . insert ( <NUM_LIT:2> , ( _ ( '<STR_LIT>' ) , { '<STR_LIT>' : ( '<STR_LIT>' , ) } ) ) <EOL> raw_id_fields = ( '<STR_LIT>' , ) <EOL> def get_queryset ( self , request ) : <EOL> return super ( FluentCommentsAdmin , self ) . get_queryset ( request ) . select_related ( '<STR_LIT:user>' ) <EOL> def object_link ( self , comment ) : <EOL> try : <EOL> object = comment . content_object <EOL> except AttributeError : <EOL> return '<STR_LIT>' <EOL> if sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> : <EOL> title = str ( object ) <EOL> else : <EOL> title = unicode ( object ) <EOL> if object : <EOL> return u'<STR_LIT>' . format ( escape ( object . get_absolute_url ( ) ) , escape ( title ) ) <EOL> else : <EOL> return u'<STR_LIT>' <EOL> object_link . short_description = _ ( "<STR_LIT>" ) <EOL> object_link . allow_tags = True <EOL> def user_name_col ( self , comment ) : <EOL> if comment . user_name : <EOL> return comment . user_name <EOL> elif comment . user_id : <EOL> if sys . version_info [ <NUM_LIT:0> ] >= <NUM_LIT:3> : <EOL> return str ( comment . user ) <EOL> else : <EOL> return unicode ( comment . user ) <EOL> else : <EOL> return None <EOL> user_name_col . short_description = _ ( "<STR_LIT>" ) <EOL> def has_add_permission ( self , request ) : <EOL> return False <EOL> def formfield_for_dbfield ( self , db_field , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT:title>' : <EOL> kwargs [ '<STR_LIT>' ] = AdminTextInputWidget <EOL> return super ( FluentCommentsAdmin , self ) . formfield_for_dbfield ( db_field , ** kwargs ) <EOL> if appsettings . FLUENT_COMMENTS_REPLACE_ADMIN : <EOL> CommentModel = get_comments_model ( ) <EOL> try : <EOL> admin . site . unregister ( CommentModel ) <EOL> except admin . sites . NotRegistered as e : <EOL> pass <EOL> admin . site . register ( CommentModel , FluentCommentsAdmin ) </s>
