<s> from django . contrib import admin <EOL> from django . template . defaultfilters import date as _date , time as _time <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from tickets . models import Ticket , TicketComment <EOL> class TicketCommentInline ( admin . TabularInline ) : <EOL> model = TicketComment <EOL> extra = <NUM_LIT:1> <EOL> raw_id_fields = [ '<STR_LIT>' ] <EOL> readonly_fields = [ '<STR_LIT:date>' ] <EOL> def formfield_for_foreignkey ( self , db_field , request , ** kwargs ) : <EOL> if db_field . name == '<STR_LIT>' : <EOL> kwargs [ '<STR_LIT>' ] = request . user . id <EOL> return super ( TicketCommentInline , self ) . formfield_for_foreignkey ( db_field , request , ** kwargs ) <EOL> class TicketAdmin ( admin . ModelAdmin ) : <EOL> list_display = [ '<STR_LIT:date>' , '<STR_LIT:status>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> list_filter = [ '<STR_LIT:status>' , '<STR_LIT:date>' ] <EOL> search_fields = [ '<STR_LIT>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> raw_id_fields = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> inlines = [ TicketCommentInline , ] <EOL> def latest_activity ( self , obj ) : <EOL> latest = obj . get_latest_comment ( ) <EOL> return "<STR_LIT>" % ( _date ( latest . date ) , _time ( latest . date ) , latest . author ) <EOL> latest_activity . short_description = _ ( "<STR_LIT>" ) <EOL> admin . site . register ( Ticket , TicketAdmin ) </s>
