Projet

Général

Profil

0001-misc-use-a-more-readable-conversion-of-python-to-css.patch

Frédéric Péters, 27 janvier 2020 19:06

Télécharger (2,99 ko)

Voir les différences:

Subject: [PATCH] misc: use a more readable conversion of python to css class
 name (#39314)

 combo/data/models.py                     | 11 +++++++++--
 combo/manager/static/js/combo.manager.js |  6 +++---
 tests/test_cells.py                      |  2 +-
 3 files changed, 13 insertions(+), 6 deletions(-)
combo/data/models.py
571 571
        return ''
572 572

  
573 573
    @property
574
    def class_name(self):
574
    def legacy_class_name(self):
575
        # legacy class name used in some themes
575 576
        return self.__class__.__name__.lower()
576 577

  
578
    @property
579
    def class_name(self):
580
        # convert CamelCase Python class name into a lower and dashed version
581
        # appropriate for CSS
582
        return re.sub('([A-Z]+)', r'-\1', self.__class__.__name__).lower()[1:]
583

  
577 584
    @property
578 585
    def css_class_names(self):
579
        return self.class_name + ' ' + self.extra_css_class
586
        return ' '.join([self.class_name, self.legacy_class_name, self.extra_css_class])
580 587

  
581 588
    @classmethod
582 589
    def get_cell_classes(cls, class_filter=lambda x: True):
combo/manager/static/js/combo.manager.js
254 254
    }
255 255
  }
256 256

  
257
  $('.cell.tipipaymentformcell select').on('change', function() {
257
  $('.cell.tipi-payment-form-cell select').on('change', function() {
258 258
      handle_tipi_form($(this));
259 259
      compute_max_height($(this).parents('div.cell'));
260 260
  });
261
  $('.cell.tipipaymentformcell select').trigger('change');
261
  $('.cell.tipi-payment-form-cell select').trigger('change');
262 262

  
263
  $('.cell.tipipaymentformcell').on('combo:cellform-reloaded', function() {
263
  $('.cell.tipi-payment-form-cell').on('combo:cellform-reloaded', function() {
264 264
      var $select = $(this).find('select');
265 265
      $select.on('change', function() {
266 266
          handle_tipi_form($select);
tests/test_cells.py
399 399
        assert cell.get_label() == 'Foobar'
400 400
        assert cell.url == 'http://test/'
401 401
        assert cell.template_name == 'combo/json/foobar.html'
402
        assert cell.css_class_names.split() == ['configjsoncell', 'foobar']
402
        assert cell.css_class_names.split() == ['config-json-cell', 'configjsoncell', 'foobar']
403 403

  
404 404
        with mock.patch('combo.utils.requests.get') as requests_get:
405 405
            requests_get.return_value = mock_json_response(content=json.dumps({'hello': 'world'}), status_code=200)
406
-