<s> from django . contrib import admin <EOL> from django . contrib . auth import get_user_model <EOL> from django . utils import timezone <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from opps . core . admin import apply_opps_rules <EOL> from opps . core . permissions . admin import AdminViewPermission <EOL> from . models import File <EOL> @ apply_opps_rules ( '<STR_LIT>' ) <EOL> class FileAdmin ( AdminViewPermission ) : <EOL> search_fields = [ '<STR_LIT:title>' , '<STR_LIT>' ] <EOL> raw_id_fields = [ '<STR_LIT:user>' ] <EOL> list_display = [ '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> ordering = ( '<STR_LIT>' , ) <EOL> list_filter = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> prepopulated_fields = { "<STR_LIT>" : [ "<STR_LIT:title>" ] } <EOL> fieldsets = ( <EOL> ( _ ( u'<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT:title>' , '<STR_LIT>' , ) } ) , <EOL> ( _ ( u'<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) } ) , <EOL> ( _ ( u'<STR_LIT>' ) , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , ) } ) , <EOL> ) <EOL> def download_link ( self , obj ) : <EOL> download_url = '<STR_LIT>' <EOL> if obj . archive : <EOL> download_url = obj . archive . url <EOL> elif obj . archive_link : <EOL> download_url = obj . archive_link <EOL> html = '<STR_LIT>' . format ( <EOL> download_url , <EOL> unicode ( _ ( u'<STR_LIT>' ) ) ) <EOL> return html <EOL> download_link . short_description = _ ( u'<STR_LIT>' ) <EOL> download_link . allow_tags = True <EOL> def save_model ( self , request , obj , form , change ) : <EOL> if not change : <EOL> obj . user = get_user_model ( ) . objects . get ( pk = request . user . pk ) <EOL> obj . date_insert = timezone . now ( ) <EOL> obj . date_update = timezone . now ( ) <EOL> obj . save ( ) <EOL> admin . site . register ( File , FileAdmin ) </s>
