<s> from django import shortcuts <EOL> from django . contrib import messages <EOL> from django . core . urlresolvers import reverse <EOL> from django . template . loader import render_to_string <EOL> from django . views import generic <EOL> from oscar . core . loading import get_classes , get_model <EOL> WeightBandForm , WeightBasedForm = get_classes ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> WeightBased = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> WeightBand = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class WeightBasedListView ( generic . ListView ) : <EOL> model = WeightBased <EOL> template_name = "<STR_LIT>" <EOL> context_object_name = "<STR_LIT>" <EOL> class WeightBasedCreateView ( generic . CreateView ) : <EOL> model = WeightBased <EOL> form_class = WeightBasedForm <EOL> template_name = "<STR_LIT>" <EOL> def get_success_url ( self ) : <EOL> msg = render_to_string ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : self . object } ) <EOL> messages . success ( self . request , msg , extra_tags = '<STR_LIT>' ) <EOL> return reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . object . pk } ) <EOL> class WeightBasedDetailView ( generic . CreateView ) : <EOL> model = WeightBand <EOL> form_class = WeightBandForm <EOL> template_name = "<STR_LIT>" <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> self . method = shortcuts . get_object_or_404 ( <EOL> WeightBased , pk = kwargs [ '<STR_LIT>' ] ) <EOL> return super ( WeightBasedDetailView , self ) . dispatch ( <EOL> request , * args , ** kwargs ) <EOL> def get_form_kwargs ( self , ** kwargs ) : <EOL> kwargs = super ( WeightBasedDetailView , self ) . get_form_kwargs ( ** kwargs ) <EOL> kwargs [ '<STR_LIT>' ] = self . method <EOL> return kwargs <EOL> def get_context_data ( self , ** kwargs ) : <EOL> ctx = super ( WeightBasedDetailView , self ) . get_context_data ( ** kwargs ) <EOL> ctx [ '<STR_LIT>' ] = self . method <EOL> return ctx <EOL> def get_success_url ( self ) : <EOL> msg = render_to_string ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : self . object } ) <EOL> messages . success ( self . request , msg , extra_tags = '<STR_LIT>' ) <EOL> return reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . method . pk } ) <EOL> class WeightBasedUpdateView ( generic . UpdateView ) : <EOL> model = WeightBased <EOL> form_class = WeightBasedForm <EOL> template_name = "<STR_LIT>" <EOL> context_object_name = "<STR_LIT>" <EOL> def get_success_url ( self ) : <EOL> msg = render_to_string ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : self . object } ) <EOL> messages . success ( self . request , msg , extra_tags = '<STR_LIT>' ) <EOL> return reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . object . pk } ) <EOL> class WeightBandUpdateView ( generic . UpdateView ) : <EOL> model = WeightBand <EOL> form_class = WeightBandForm <EOL> template_name = "<STR_LIT>" <EOL> context_object_name = "<STR_LIT>" <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> self . method = shortcuts . get_object_or_404 ( <EOL> WeightBased , pk = kwargs [ '<STR_LIT>' ] ) <EOL> return super ( WeightBandUpdateView , self ) . dispatch ( <EOL> request , * args , ** kwargs ) <EOL> def get_queryset ( self ) : <EOL> return self . method . bands . all ( ) <EOL> def get_form_kwargs ( self , ** kwargs ) : <EOL> kwargs = super ( WeightBandUpdateView , self ) . get_form_kwargs ( ** kwargs ) <EOL> kwargs [ '<STR_LIT>' ] = self . method <EOL> return kwargs <EOL> def get_success_url ( self ) : <EOL> msg = render_to_string ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : self . object } ) <EOL> messages . success ( self . request , msg , extra_tags = '<STR_LIT>' ) <EOL> return reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . method . pk } ) <EOL> class WeightBandDeleteView ( generic . DeleteView ) : <EOL> model = WeightBased <EOL> template_name = "<STR_LIT>" <EOL> context_object_name = "<STR_LIT>" <EOL> def dispatch ( self , request , * args , ** kwargs ) : <EOL> self . method = shortcuts . get_object_or_404 ( <EOL> WeightBased , pk = kwargs [ '<STR_LIT>' ] ) <EOL> return super ( WeightBandDeleteView , self ) . dispatch ( <EOL> request , * args , ** kwargs ) <EOL> def get_queryset ( self ) : <EOL> return self . method . bands . all ( ) <EOL> def get_success_url ( self ) : <EOL> msg = render_to_string ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : self . object } ) <EOL> messages . success ( self . request , msg , extra_tags = '<STR_LIT>' ) <EOL> return reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : self . method . pk } ) <EOL> class WeightBasedDeleteView ( generic . DeleteView ) : <EOL> model = WeightBased <EOL> template_name = "<STR_LIT>" <EOL> context_object_name = "<STR_LIT>" <EOL> def get_success_url ( self ) : <EOL> msg = render_to_string ( <EOL> '<STR_LIT>' , <EOL> { '<STR_LIT>' : self . object } ) <EOL> messages . success ( self . request , msg , extra_tags = '<STR_LIT>' ) <EOL> return reverse ( '<STR_LIT>' ) </s>
