<s> from __future__ import unicode_literals <EOL> from django . contrib import admin <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from cms . admin . placeholderadmin import ( <EOL> FrontendEditableAdminMixin , <EOL> ) <EOL> from parler . forms import TranslatableModelForm <EOL> from parler . admin import TranslatableAdmin <EOL> from aldryn_apphooks_config . admin import BaseAppHookConfig , ModelAppHookConfig <EOL> from aldryn_people . models import Person <EOL> from aldryn_reversion . admin import VersionedPlaceholderAdminMixin <EOL> from aldryn_translation_tools . admin import AllTranslationsMixin <EOL> from . import models <EOL> def make_published ( modeladmin , request , queryset ) : <EOL> queryset . update ( is_published = True ) <EOL> make_published . short_description = _ ( <EOL> "<STR_LIT>" ) <EOL> def make_unpublished ( modeladmin , request , queryset ) : <EOL> queryset . update ( is_published = False ) <EOL> make_unpublished . short_description = _ ( <EOL> "<STR_LIT>" ) <EOL> def make_featured ( modeladmin , request , queryset ) : <EOL> queryset . update ( is_featured = True ) <EOL> make_featured . short_description = _ ( <EOL> "<STR_LIT>" ) <EOL> def make_not_featured ( modeladmin , request , queryset ) : <EOL> queryset . update ( is_featured = False ) <EOL> make_not_featured . short_description = _ ( <EOL> "<STR_LIT>" ) <EOL> class ArticleAdminForm ( TranslatableModelForm ) : <EOL> class Meta : <EOL> model = models . Article <EOL> fields = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:title>' , <EOL> ] <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ArticleAdminForm , self ) . __init__ ( * args , ** kwargs ) <EOL> qs = models . Article . objects <EOL> if self . instance . app_config_id : <EOL> qs = models . Article . objects . filter ( <EOL> app_config = self . instance . app_config ) <EOL> elif '<STR_LIT>' in kwargs and '<STR_LIT>' in kwargs [ '<STR_LIT>' ] : <EOL> qs = models . Article . objects . filter ( <EOL> app_config = kwargs [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> if self . instance . pk : <EOL> qs = qs . exclude ( pk = self . instance . pk ) <EOL> if '<STR_LIT>' in self . fields : <EOL> self . fields [ '<STR_LIT>' ] . queryset = qs <EOL> self . fields [ '<STR_LIT>' ] . widget . can_add_related = False <EOL> if ( '<STR_LIT>' in self . fields and <EOL> hasattr ( self . fields [ '<STR_LIT>' ] , '<STR_LIT>' ) ) : <EOL> self . fields [ '<STR_LIT>' ] . widget . can_add_related = False <EOL> class ArticleAdmin ( <EOL> AllTranslationsMixin , <EOL> VersionedPlaceholderAdminMixin , <EOL> FrontendEditableAdminMixin , <EOL> ModelAppHookConfig , <EOL> TranslatableAdmin <EOL> ) : <EOL> form = ArticleAdminForm <EOL> list_display = ( '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> list_filter = [ '<STR_LIT>' , ] <EOL> actions = ( <EOL> make_featured , make_not_featured , <EOL> make_published , make_unpublished , <EOL> ) <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT:title>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> } ) , <EOL> ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , ) , <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> } ) , <EOL> ) <EOL> app_config_values = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> def add_view ( self , request , * args , ** kwargs ) : <EOL> data = request . GET . copy ( ) <EOL> try : <EOL> person = Person . objects . get ( user = request . user ) <EOL> data [ '<STR_LIT>' ] = person . pk <EOL> request . GET = data <EOL> except Person . DoesNotExist : <EOL> pass <EOL> data [ '<STR_LIT>' ] = request . user . pk <EOL> request . GET = data <EOL> return super ( ArticleAdmin , self ) . add_view ( request , * args , ** kwargs ) <EOL> admin . site . register ( models . Article , ArticleAdmin ) <EOL> class NewsBlogConfigAdmin ( <EOL> AllTranslationsMixin , <EOL> VersionedPlaceholderAdminMixin , <EOL> BaseAppHookConfig , <EOL> TranslatableAdmin <EOL> ) : <EOL> def get_config_fields ( self ) : <EOL> return ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ) <EOL> admin . site . register ( models . NewsBlogConfig , NewsBlogConfigAdmin ) </s>
