<s> from django . conf import settings <EOL> from portfolio . models import * <EOL> from portfolio . forms import * <EOL> from mcbv . detail import DetailView <EOL> from mcbv . list import ListView <EOL> from mcbv . list_custom import ListRelated , DetailListFormSetView <EOL> from mcbv . edit_custom import FormSetView , UpdateView <EOL> from shared . utils import * <EOL> class Main ( ListView ) : <EOL> list_model = Group <EOL> paginate_by = <NUM_LIT:10> <EOL> template_name = "<STR_LIT>" <EOL> class SlideshowView ( ListRelated ) : <EOL> list_model = Image <EOL> detail_model = Group <EOL> related_name = "<STR_LIT>" <EOL> template_name = "<STR_LIT>" <EOL> class GroupView ( DetailListFormSetView ) : <EOL> """<STR_LIT>""" <EOL> detail_model = Group <EOL> formset_model = Image <EOL> formset_form_class = ImageForm <EOL> related_name = "<STR_LIT>" <EOL> paginate_by = <NUM_LIT> <EOL> template_name = "<STR_LIT>" <EOL> def add_context ( self ) : <EOL> return dict ( show = self . kwargs . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def process_form ( self , form ) : <EOL> if self . user . is_authenticated ( ) : form . save ( ) <EOL> def get_success_url ( self ) : <EOL> return "<STR_LIT>" % ( self . detail_absolute_url ( ) , self . request . GET . urlencode ( ) ) <EOL> class AddImages ( DetailView , FormSetView ) : <EOL> """<STR_LIT>""" <EOL> detail_model = Group <EOL> formset_model = Image <EOL> formset_form_class = AddImageForm <EOL> template_name = "<STR_LIT>" <EOL> extra = <NUM_LIT:10> <EOL> def process_form ( self , form ) : <EOL> form . instance . update ( group = self . get_detail_object ( ) ) <EOL> def get_success_url ( self ) : <EOL> return self . detail_absolute_url ( ) <EOL> class ImageView ( UpdateView ) : <EOL> form_model = Image <EOL> modelform_class = ImageForm <EOL> template_name = "<STR_LIT>" <EOL> def form_valid ( self , form ) : <EOL> if self . user . is_authenticated ( ) : form . save ( ) <EOL> def edit ( self ) : <EOL> return self . user . is_authenticated ( ) and self . request . GET . get ( "<STR_LIT>" ) <EOL> def portfolio_context ( request ) : <EOL> return dict ( user = request . user , media_url = settings . MEDIA_URL ) </s>
