Changeset e953372 in tailbone


Ignore:
Timestamp:
01/23/20 10:48:21 (4 weeks ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
35875b7
Parents:
842882e7
Message:

Allow populate of new pricing batch from products w/ "SRP breach"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone/views/batch/pricing.py

    r842882e7 re953372  
    5454        'min_diff_threshold': "Min $ Diff",
    5555        'min_diff_percent': "Min % Diff",
     56        'auto_generate_from_srp_breach': "Automatic (from SRP Breach)",
    5657    }
    5758
     
    7576        'min_diff_percent',
    7677        'calculate_for_manual',
     78        'auto_generate_from_srp_breach',
    7779        'notes',
    7880        'created',
     
    154156            f.set_renderer('input_filename', self.render_downloadable_file)
    155157
     158        # auto_generate_from_srp_breach
     159        if self.creating:
     160            f.set_type('auto_generate_from_srp_breach', 'boolean')
     161        else:
     162            f.remove_field('auto_generate_from_srp_breach')
     163
     164        # note, the input file is normally required, but should *not* be if the
     165        # user wants to auto-generate the new batch
     166        if self.request.method == 'POST':
     167            if self.request.POST.get('auto_generate_from_srp_breach') == 'true':
     168                f.set_required('input_filename', False)
     169
    156170    def get_batch_kwargs(self, batch, mobile=False):
    157171        kwargs = super(PricingBatchView, self).get_batch_kwargs(batch, mobile=mobile)
     
    159173        kwargs['min_diff_percent'] = batch.min_diff_percent
    160174        kwargs['calculate_for_manual'] = batch.calculate_for_manual
     175
     176        # are we auto-generating from SRP breach?
     177        if self.request.POST.get('auto_generate_from_srp_breach') == 'true':
     178
     179            # assign batch param
     180            params = kwargs.get('params', {})
     181            params['auto_generate_from_srp_breach'] = True
     182            kwargs['params'] = params
     183
     184            # provide default description
     185            if not kwargs.get('description'):
     186                kwargs['description'] = "auto-generated from SRP breach"
     187
    161188        return kwargs
    162189
Note: See TracChangeset for help on using the changeset viewer.