Skip to content

Commit 0d7b3a6

Browse files
author
Ramez Ashraf
committed
Merge branch 'release/v0.7'
2 parents b8b1750 + 8659568 commit 0d7b3a6

25 files changed

+2141
-1115
lines changed

CHANGELOG.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,50 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.7.0]
6+
7+
- Added SlickReportingListView: a Report Class to display content of the model (like a ModelAdmin ChangeList)
8+
- Added `show_time_series_selector` capability to SlickReportView allowing User to change the time series pattern from
9+
the UI.
10+
- Added ability to export to CSV from UI, using `ExportToStreamingCSV` & `ExportToCSV`
11+
- Now you can have a custom column defined on the SlickReportView (and not needing to customise the report generator).
12+
- You don't need to set date_field if you don't have calculations on the report
13+
- Easier customization of the crispy form layout
14+
- Enhance weekly time series default column name
15+
- Add `Chart` data class to hold chart data
16+
517
## [0.6.8]
618

7-
- Add report_title to context
19+
- Add report_title to context
820
- Enhance SearchForm to be easier to override. Still needs more enhancements.
921

10-
1122
## [0.6.7]
1223

13-
- Fix issue with `ReportField` when it has a `requires` in time series and crosstab reports
24+
- Fix issue with `ReportField` when it has a `requires` in time series and crosstab reports
1425

1526
## [0.6.6]
1627

1728
- Now a method on a generator can be effectively used as column
1829
- Use correct model when traversing on group by
1930

20-
2131
## [0.6.5]
22-
- Fix Issue with group_by field pointing to model with custom primary key Issue #58
2332

33+
- Fix Issue with group_by field pointing to model with custom primary key Issue #58
2434

2535
## [0.6.4]
36+
2637
- Fix highchart cache to target the specific chart
2738
- Added initial and required to report_form_factory
2839
- Added base_q_filters and base_kwargs_filters to SlickReportField to control the base queryset
29-
- Add ability to customize ReportField on the fly
30-
- Adds `prevent_group_by` option to SlickReportField Will prevent group by calculation for this specific field, serves when you want to compute overall results.
40+
- Add ability to customize ReportField on the fly
41+
- Adds `prevent_group_by` option to SlickReportField Will prevent group by calculation for this specific field, serves
42+
when you want to compute overall results.
3143
- Support reference to SlickReportField class directly in `requires` instead of its "registered" name.
32-
- Adds PercentageToBalance report field
44+
- Adds PercentageToBalance report field
3345

3446
## [0.6.3]
3547

36-
- Change the deprecated in Django 4 `request.is_ajax` .
48+
- Change the deprecated in Django 4 `request.is_ajax` .
3749

3850
## [0.6.2]
3951

@@ -47,14 +59,13 @@ All notable changes to this project will be documented in this file.
4759

4860
- Breaking [ONLY] if you have overridden ReportView.get_report_results()
4961
- Moved the collecting of total report data to the report generator to make easier low level usage.
50-
- Fixed an issue with Charts.js `get_row_data`
62+
- Fixed an issue with Charts.js `get_row_data`
5163
- Added ChartsOption 'time_series_support',in both chart.js and highcharts
52-
- Fixed `SlickReportField.create` to use the issuing class not the vanilla one.
53-
64+
- Fixed `SlickReportField.create` to use the issuing class not the vanilla one.
5465

5566
## [0.5.8]
5667

57-
- Fix compatibility with Django 3.2
68+
- Fix compatibility with Django 3.2
5869

5970
## [0.5.7]
6071

@@ -63,22 +74,21 @@ All notable changes to this project will be documented in this file.
6374
## [0.5.6]
6475

6576
- Add exclude_field to report_form_factory (@gr4n0t4)
66-
- Added support for group by Many To Many field (@gr4n0t4)
77+
- Added support for group by Many To Many field (@gr4n0t4)
6778

6879
## [0.5.5]
6980

7081
- Add datepicker initialization function call (@squio)
7182
- Fixed an issue with default dates not being functional.
7283

73-
7484
## [0.5.4]
7585

7686
- Added missing prefix on integrity hash (@squio)
7787

7888
## [0.5.3]
7989

8090
- Enhanced Field prepare flow
81-
- Add traversing for group_by
91+
- Add traversing for group_by
8292
- Allowed tests to run specific tests instead of the whole suit
8393
- Enhanced templates structure for easier override/customization
8494

@@ -88,7 +98,6 @@ All notable changes to this project will be documented in this file.
8898
- Enhanced the default verbose names of time series.
8999
- Expanding test coverage
90100

91-
92101
## [0.5.1]
93102

94103
- Allow for time series to operate on a non-group by report

docs/source/index.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ To install django-slick-reporting:
1111

1212
1. Install with pip: `pip install django-slick-reporting`.
1313
2. Add ``slick_reporting`` to ``INSTALLED_APPS``.
14-
3. For the shipped in View, add ``'crispy_forms'`` to ``INSTALLED_APPS`` and add ``CRISPY_TEMPLATE_PACK = 'bootstrap4'``
15-
to your ``settings.py``
14+
3. For the shipped in View, add ``'crispy_forms'`` to ``INSTALLED_APPS`` and add ``CRISPY_TEMPLATE_PACK = 'bootstrap4'`` to your ``settings.py``
1615
4. Execute `python manage.py collectstatic` so the JS helpers are collected and served.
1716

1817
Demo site
1918
----------
2019

2120
https://django-slick-reporting.com is a quick walk-though with live code examples
2221

22+
Options
23+
-------
24+
* Compute different types of fields (Sum, Avg, Count, Min, Max, StdDev, Variance) on a model
25+
* Group by a foreign key, date, or any other field
26+
* Display the results in a table
27+
* Display the results in a chart (Highcharts or Charts.js)
28+
* Export the results to CSV , extendable easily
29+
2330

2431
Quickstart
2532
----------

docs/source/the_view.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,40 @@ What is SlickReportView?
77
-----------------------
88

99
SlickReportView is a CBV that inherits form ``FromView`` and expose the report generator needed attributes.
10-
it also
10+
Also
1111

1212
* Auto generate the search form
1313
* return the results as a json response if ajax request
1414
* Works on GET and POST
15+
* Export to CSV (extendable to apply other exporting method)
16+
1517

1618
How the search form is generated ?
1719
-----------------------------------
1820
Behind the scene, Sample report calls ``slick_reporting.form_factory.report_form_factory``
1921
a helper method which generates a form containing start date and end date, as well as all foreign keys on the report_model.
2022

23+
24+
Export to CSV
25+
--------------
26+
To trigger an export to CSV, just add ``?_export=csv`` to the url.
27+
This will call the export_csv on the view class, engaging a `ExportToStreamingCSV`
28+
29+
You can extend the functionality, say you want to export to pdf.
30+
Add a ``export_pdf`` method to the view class, accepting the report_data json response and return the response you want.
31+
This ``export_pdf` will be called automatically when url parameter contain ``?_export=pdf``
32+
33+
Having an `_export` parameter not implemented, to say the view class do not implement ``export_{parameter_name}``, will be ignored.
34+
35+
SlickReportingListView
36+
-----------------------
37+
This is a simple ListView to display data in a model, like you would with an admin ChangeList view.
38+
It's a simple ListView with a few extra features:
39+
40+
filters: a list of report_model fields to be used as filters.
41+
42+
43+
2144
Override the Form
2245
------------------
2346

slick_reporting/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
default_app_config = 'slick_reporting.apps.ReportAppConfig'
1+
default_app_config = "slick_reporting.apps.ReportAppConfig"
22

3-
VERSION = (0, 6, 8)
3+
VERSION = (0, 7, 0)
44

5-
__version__ = '0.6.8'
5+
__version__ = "0.7.8"

slick_reporting/app_settings.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import datetime
66

7+
from django.utils.timezone import now
8+
79

810
def get_first_of_this_year():
911
d = datetime.datetime.today()
@@ -16,33 +18,37 @@ def get_end_of_this_year():
1618

1719

1820
def get_start_date():
19-
start_date = getattr(settings, 'SLICK_REPORTING_DEFAULT_START_DATE', False)
21+
start_date = getattr(settings, "SLICK_REPORTING_DEFAULT_START_DATE", False)
2022
return start_date or get_first_of_this_year()
2123

2224

2325
def get_end_date():
24-
start_date = getattr(settings, 'SLICK_REPORTING_DEFAULT_END_DATE', False)
25-
return start_date or get_end_of_this_year()
26+
end_date = getattr(settings, "SLICK_REPORTING_DEFAULT_END_DATE", False)
27+
return end_date or datetime.datetime.today()
2628

2729

2830
SLICK_REPORTING_DEFAULT_START_DATE = lazy(get_start_date, datetime.datetime)()
2931
SLICK_REPORTING_DEFAULT_END_DATE = lazy(get_end_date, datetime.datetime)()
3032

3133
SLICK_REPORTING_FORM_MEDIA_DEFAULT = {
32-
'css': {
33-
'all': (
34-
'https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css',
35-
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css',
34+
"css": {
35+
"all": (
36+
"https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css",
37+
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css",
3638
)
3739
},
38-
'js': (
39-
'https://code.jquery.com/jquery-3.3.1.slim.min.js',
40-
'https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js',
41-
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js',
42-
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js',
43-
'https://code.highcharts.com/highcharts.js',
44-
)
40+
"js": (
41+
"https://code.jquery.com/jquery-3.3.1.slim.min.js",
42+
"https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js",
43+
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js",
44+
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js",
45+
"https://code.highcharts.com/highcharts.js",
46+
),
4547
}
4648

47-
SLICK_REPORTING_FORM_MEDIA = getattr(settings, 'SLICK_REPORTING_FORM_MEDIA', SLICK_REPORTING_FORM_MEDIA_DEFAULT)
48-
SLICK_REPORTING_DEFAULT_CHARTS_ENGINE = getattr(settings, 'SLICK_REPORTING_DEFAULT_CHARTS_ENGINE', 'highcharts')
49+
SLICK_REPORTING_FORM_MEDIA = getattr(
50+
settings, "SLICK_REPORTING_FORM_MEDIA", SLICK_REPORTING_FORM_MEDIA_DEFAULT
51+
)
52+
SLICK_REPORTING_DEFAULT_CHARTS_ENGINE = getattr(
53+
settings, "SLICK_REPORTING_DEFAULT_CHARTS_ENGINE", "highcharts"
54+
)

slick_reporting/apps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from django import apps
22

33

4-
54
class ReportAppConfig(apps.AppConfig):
6-
verbose_name = 'Slick Reporting'
7-
name = 'slick_reporting'
5+
verbose_name = "Slick Reporting"
6+
name = "slick_reporting"
87

98
def ready(self):
109
super().ready()

slick_reporting/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AuthorAdmin(admin.ModelAdmin):
1515

1616
def _model_admin_wrapper(admin_class):
1717
if not issubclass(admin_class, SlickReportField):
18-
raise ValueError('Wrapped class must subclass SlickReportField.')
18+
raise ValueError("Wrapped class must subclass SlickReportField.")
1919

2020
field_registry.register(report_field)
2121

0 commit comments

Comments
 (0)