From 2f8a305dfe4e81741d2fedb278f3a197eb82a7d5 Mon Sep 17 00:00:00 2001 From: Ramez Issac Date: Thu, 22 Oct 2020 11:25:40 +0200 Subject: [PATCH] V0.2.9 - Fix report demo page filter btn - Fix issue with getting the correct verbose_name of a db field. --- CHANGELOG.md | 5 +++++ slick_reporting/__init__.py | 4 ++-- slick_reporting/form_factory.py | 2 +- slick_reporting/generator.py | 2 +- tests/models.py | 2 +- tests/report_generators.py | 2 +- tests/test_generator.py | 7 ++++++- 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0fdcf3..add6752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All notable changes to this project will be documented in this file. +## [0.2.9] - 2020-10-22 +### Updated +- Fixed an issue getting a db field verbose column name +- Fixed an issue with the report demo page's filter button not working correctly. + ## [0.2.8] - 2020-10-05 ### Updated - Fixed an error with ManyToOne Relation not being able to diff --git a/slick_reporting/__init__.py b/slick_reporting/__init__.py index 8c1c532..3026dce 100644 --- a/slick_reporting/__init__.py +++ b/slick_reporting/__init__.py @@ -1,6 +1,6 @@ default_app_config = 'slick_reporting.apps.ReportAppConfig' -VERSION = (0, 2, 8) +VERSION = (0, 2, 9) -__version__ = '0.2.8' +__version__ = '0.2.9' diff --git a/slick_reporting/form_factory.py b/slick_reporting/form_factory.py index e285721..a6026aa 100644 --- a/slick_reporting/form_factory.py +++ b/slick_reporting/form_factory.py @@ -58,7 +58,7 @@ def get_crispy_helper(self, foreign_keys_map=None, crosstab_model=None, **kwargs helper.form_class = 'form-horizontal' helper.label_class = 'col-sm-2 col-md-2 col-lg-2' helper.field_class = 'col-sm-10 col-md-10 col-lg-10' - helper.form_tag = True + helper.form_tag = False helper.disable_csrf = True helper.render_unmentioned_fields = True diff --git a/slick_reporting/generator.py b/slick_reporting/generator.py index e10f400..edd1d0f 100644 --- a/slick_reporting/generator.py +++ b/slick_reporting/generator.py @@ -416,7 +416,7 @@ def _parse(self): f'Field "{col}" not found as an attribute to the generator class, nor as computation field, nor as a database column for the model "{model_to_use._meta.model_name}"') col_data = {'name': col, - 'verbose_name': getattr(attr, 'verbose_name', col), + 'verbose_name': getattr(field, 'verbose_name', col), 'source': 'database', 'ref': field, 'type': field.get_internal_type() diff --git a/tests/models.py b/tests/models.py index 9fbb03b..42bbd43 100644 --- a/tests/models.py +++ b/tests/models.py @@ -16,7 +16,7 @@ class Meta: class Client(models.Model): - slug = models.CharField(max_length=200, verbose_name=_('Slug')) + slug = models.CharField(max_length=200, verbose_name=_('Client Slug')) name = models.CharField(max_length=200, verbose_name=_('Name')) email = models.EmailField(blank=True) diff --git a/tests/report_generators.py b/tests/report_generators.py index 21b3ca3..8c88bf7 100644 --- a/tests/report_generators.py +++ b/tests/report_generators.py @@ -13,7 +13,7 @@ class GenericGenerator(ReportGenerator): # we group the sales per client , we display columns slug and title (of the `base_model` defied above # and we add the magic field `__balance__` we compute the client balance. group_by = 'client' - columns = ['slug', 'name', '__balance__'] + columns = ['slug', 'name'] class GeneratorWithAttrAsColumn(GenericGenerator): diff --git a/tests/test_generator.py b/tests/test_generator.py index ae0d8bd..90a521c 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -8,7 +8,7 @@ from slick_reporting.helpers import get_foreign_keys from .models import OrderLine -from .report_generators import GeneratorWithAttrAsColumn, CrosstabOnClient +from .report_generators import GeneratorWithAttrAsColumn, CrosstabOnClient, GenericGenerator from .tests import BaseTestData from .models import SimpleSales @@ -90,6 +90,11 @@ def test_gather_dependencies_for_time_series(self): self.assertTrue(report._report_fields_dependencies) + def test_db_field_column_verbose_name(self): + report = GenericGenerator() + field_list = report.get_list_display_columns() + self.assertEqual(field_list[0]['verbose_name'], 'Client Slug') + # test that columns are a straight forward list class TestReportFields(TestCase):