<s> from django . contrib import admin <EOL> from django . contrib . auth . models import User <EOL> from django . contrib . auth . admin import UserAdmin <EOL> from django . contrib . admin . templatetags . admin_static import static <EOL> from tastypie . models import ApiAccess <EOL> from . models import * <EOL> from . forms import UserChangeForm , UserCreationForm <EOL> from . import tasks <EOL> admin . site . register ( ApiAccess ) <EOL> class JournalMissionInline ( admin . StackedInline ) : <EOL> model = JournalMission <EOL> class SectionTitleInline ( admin . StackedInline ) : <EOL> model = SectionTitle <EOL> admin . site . register ( StudyArea ) <EOL> class CollectionAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , ) <EOL> search_fields = ( '<STR_LIT:name>' , ) <EOL> admin . site . register ( Collection , CollectionAdmin ) <EOL> admin . site . register ( Section ) <EOL> class JournalAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:title>' , ) <EOL> search_fields = ( '<STR_LIT:title>' , ) <EOL> filter_horizontal = ( '<STR_LIT>' , ) <EOL> inlines = [ JournalMissionInline ] <EOL> admin . site . register ( Journal , JournalAdmin ) <EOL> class InstitutionAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT:name>' , ) <EOL> search_fields = ( '<STR_LIT:name>' , ) <EOL> admin . site . register ( Institution , InstitutionAdmin ) <EOL> class UserCollectionsInline ( admin . TabularInline ) : <EOL> model = UserCollections <EOL> extra = <NUM_LIT:1> <EOL> can_delete = True <EOL> class UserProfileInline ( admin . StackedInline ) : <EOL> model = UserProfile <EOL> max_num = <NUM_LIT:1> <EOL> can_delete = True <EOL> class UserAdmin ( UserAdmin ) : <EOL> def profile_email_notifications ( self , user ) : <EOL> """<STR_LIT>""" <EOL> if user . get_profile ( ) : <EOL> email_notifications = user . get_profile ( ) . email_notifications <EOL> icon_url = static ( '<STR_LIT>' % { True : '<STR_LIT:yes>' , False : '<STR_LIT>' , None : '<STR_LIT>' } [ email_notifications ] ) <EOL> return '<STR_LIT>' . format ( icon_url , email_notifications ) <EOL> else : <EOL> icon_url = static ( '<STR_LIT>' ) <EOL> return '<STR_LIT>' % icon_url <EOL> profile_email_notifications . short_description = '<STR_LIT>' <EOL> profile_email_notifications . allow_tags = True <EOL> list_display = ( '<STR_LIT:username>' , '<STR_LIT:email>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> inlines = ( UserProfileInline , UserCollectionsInline ) <EOL> form = UserChangeForm <EOL> add_form = UserCreationForm <EOL> add_fieldsets = ( <EOL> ( <EOL> None , <EOL> { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( '<STR_LIT:username>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:email>' ) <EOL> } <EOL> ) , <EOL> ) <EOL> admin . site . unregister ( User ) <EOL> admin . site . register ( User , UserAdmin ) <EOL> class IssueAdmin ( admin . ModelAdmin ) : <EOL> search_fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> admin . site . register ( Issue , IssueAdmin ) <EOL> class SponsorAdmin ( admin . ModelAdmin ) : <EOL> filter_horizontal = ( '<STR_LIT>' , ) <EOL> admin . site . register ( Sponsor , SponsorAdmin ) <EOL> class UseLicenseAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , ) <EOL> admin . site . register ( UseLicense , UseLicenseAdmin ) <EOL> admin . site . register ( Language ) <EOL> admin . site . register ( TranslatedData ) <EOL> admin . site . register ( PressRelease ) <EOL> def is_linked_to_issue ( article ) : <EOL> return bool ( article . issue ) <EOL> is_linked_to_issue . boolean = True <EOL> def is_linked_to_journal ( article ) : <EOL> return bool ( article . journal ) <EOL> is_linked_to_issue . boolean = True <EOL> class ArticleAdmin ( admin . ModelAdmin ) : <EOL> list_display = ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> is_linked_to_issue , is_linked_to_journal , <EOL> ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> date_hierarchy = '<STR_LIT>' <EOL> actions = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_fields = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ) <EOL> def link_to_issue ( self , request , queryset ) : <EOL> for article in queryset : <EOL> tasks . link_article_to_issue . delay ( article . pk ) <EOL> count = queryset . count ( ) <EOL> if count >= <NUM_LIT:2> : <EOL> message = u'<STR_LIT>' % ( count , ) <EOL> else : <EOL> message = u'<STR_LIT>' % ( count , ) <EOL> self . message_user ( request , message ) <EOL> link_to_issue . short_description = u'<STR_LIT>' <EOL> def link_to_journal ( self , request , queryset ) : <EOL> for article in queryset : <EOL> tasks . link_article_to_journal . delay ( article . pk ) <EOL> count = queryset . count ( ) <EOL> if count >= <NUM_LIT:2> : <EOL> message = u'<STR_LIT>' % ( count , ) <EOL> else : <EOL> message = u'<STR_LIT>' % ( count , ) <EOL> self . message_user ( request , message ) <EOL> link_to_journal . short_description = u'<STR_LIT>' <EOL> admin . site . register ( Article , ArticleAdmin ) </s>
