Skip to content

Commit

Permalink
Merge branch 'release/v0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramez Ashraf committed May 15, 2023
2 parents b8b1750 + 8659568 commit 0d7b3a6
Show file tree
Hide file tree
Showing 25 changed files with 2,141 additions and 1,115 deletions.
43 changes: 26 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,50 @@

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

## [0.7.0]

- Added SlickReportingListView: a Report Class to display content of the model (like a ModelAdmin ChangeList)
- Added `show_time_series_selector` capability to SlickReportView allowing User to change the time series pattern from
the UI.
- Added ability to export to CSV from UI, using `ExportToStreamingCSV` & `ExportToCSV`
- Now you can have a custom column defined on the SlickReportView (and not needing to customise the report generator).
- You don't need to set date_field if you don't have calculations on the report
- Easier customization of the crispy form layout
- Enhance weekly time series default column name
- Add `Chart` data class to hold chart data

## [0.6.8]

- Add report_title to context
- Add report_title to context
- Enhance SearchForm to be easier to override. Still needs more enhancements.


## [0.6.7]

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

## [0.6.6]

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


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

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

## [0.6.4]

- Fix highchart cache to target the specific chart
- Added initial and required to report_form_factory
- Added base_q_filters and base_kwargs_filters to SlickReportField to control the base queryset
- Add ability to customize ReportField on the fly
- Adds `prevent_group_by` option to SlickReportField Will prevent group by calculation for this specific field, serves when you want to compute overall results.
- Add ability to customize ReportField on the fly
- Adds `prevent_group_by` option to SlickReportField Will prevent group by calculation for this specific field, serves
when you want to compute overall results.
- Support reference to SlickReportField class directly in `requires` instead of its "registered" name.
- Adds PercentageToBalance report field
- Adds PercentageToBalance report field

## [0.6.3]

- Change the deprecated in Django 4 `request.is_ajax` .
- Change the deprecated in Django 4 `request.is_ajax` .

## [0.6.2]

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

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

- Fixed `SlickReportField.create` to use the issuing class not the vanilla one.

## [0.5.8]

- Fix compatibility with Django 3.2
- Fix compatibility with Django 3.2

## [0.5.7]

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

- Add exclude_field to report_form_factory (@gr4n0t4)
- Added support for group by Many To Many field (@gr4n0t4)
- Added support for group by Many To Many field (@gr4n0t4)

## [0.5.5]

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


## [0.5.4]

- Added missing prefix on integrity hash (@squio)

## [0.5.3]

- Enhanced Field prepare flow
- Add traversing for group_by
- Add traversing for group_by
- Allowed tests to run specific tests instead of the whole suit
- Enhanced templates structure for easier override/customization

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


## [0.5.1]

- Allow for time series to operate on a non-group by report
Expand Down
11 changes: 9 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ To install django-slick-reporting:

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

Demo site
----------

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

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


Quickstart
----------
Expand Down
25 changes: 24 additions & 1 deletion docs/source/the_view.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,40 @@ What is SlickReportView?
-----------------------

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

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


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


Export to CSV
--------------
To trigger an export to CSV, just add ``?_export=csv`` to the url.
This will call the export_csv on the view class, engaging a `ExportToStreamingCSV`

You can extend the functionality, say you want to export to pdf.
Add a ``export_pdf`` method to the view class, accepting the report_data json response and return the response you want.
This ``export_pdf` will be called automatically when url parameter contain ``?_export=pdf``

Having an `_export` parameter not implemented, to say the view class do not implement ``export_{parameter_name}``, will be ignored.

SlickReportingListView
-----------------------
This is a simple ListView to display data in a model, like you would with an admin ChangeList view.
It's a simple ListView with a few extra features:

filters: a list of report_model fields to be used as filters.



Override the Form
------------------

Expand Down
6 changes: 3 additions & 3 deletions slick_reporting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_app_config = 'slick_reporting.apps.ReportAppConfig'
default_app_config = "slick_reporting.apps.ReportAppConfig"

VERSION = (0, 6, 8)
VERSION = (0, 7, 0)

__version__ = '0.6.8'
__version__ = "0.7.8"
38 changes: 22 additions & 16 deletions slick_reporting/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import datetime

from django.utils.timezone import now


def get_first_of_this_year():
d = datetime.datetime.today()
Expand All @@ -16,33 +18,37 @@ def get_end_of_this_year():


def get_start_date():
start_date = getattr(settings, 'SLICK_REPORTING_DEFAULT_START_DATE', False)
start_date = getattr(settings, "SLICK_REPORTING_DEFAULT_START_DATE", False)
return start_date or get_first_of_this_year()


def get_end_date():
start_date = getattr(settings, 'SLICK_REPORTING_DEFAULT_END_DATE', False)
return start_date or get_end_of_this_year()
end_date = getattr(settings, "SLICK_REPORTING_DEFAULT_END_DATE", False)
return end_date or datetime.datetime.today()


SLICK_REPORTING_DEFAULT_START_DATE = lazy(get_start_date, datetime.datetime)()
SLICK_REPORTING_DEFAULT_END_DATE = lazy(get_end_date, datetime.datetime)()

SLICK_REPORTING_FORM_MEDIA_DEFAULT = {
'css': {
'all': (
'https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css',
"css": {
"all": (
"https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css",
)
},
'js': (
'https://code.jquery.com/jquery-3.3.1.slim.min.js',
'https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js',
'https://code.highcharts.com/highcharts.js',
)
"js": (
"https://code.jquery.com/jquery-3.3.1.slim.min.js",
"https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js",
"https://code.highcharts.com/highcharts.js",
),
}

SLICK_REPORTING_FORM_MEDIA = getattr(settings, 'SLICK_REPORTING_FORM_MEDIA', SLICK_REPORTING_FORM_MEDIA_DEFAULT)
SLICK_REPORTING_DEFAULT_CHARTS_ENGINE = getattr(settings, 'SLICK_REPORTING_DEFAULT_CHARTS_ENGINE', 'highcharts')
SLICK_REPORTING_FORM_MEDIA = getattr(
settings, "SLICK_REPORTING_FORM_MEDIA", SLICK_REPORTING_FORM_MEDIA_DEFAULT
)
SLICK_REPORTING_DEFAULT_CHARTS_ENGINE = getattr(
settings, "SLICK_REPORTING_DEFAULT_CHARTS_ENGINE", "highcharts"
)
5 changes: 2 additions & 3 deletions slick_reporting/apps.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from django import apps



class ReportAppConfig(apps.AppConfig):
verbose_name = 'Slick Reporting'
name = 'slick_reporting'
verbose_name = "Slick Reporting"
name = "slick_reporting"

def ready(self):
super().ready()
Expand Down
2 changes: 1 addition & 1 deletion slick_reporting/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AuthorAdmin(admin.ModelAdmin):

def _model_admin_wrapper(admin_class):
if not issubclass(admin_class, SlickReportField):
raise ValueError('Wrapped class must subclass SlickReportField.')
raise ValueError("Wrapped class must subclass SlickReportField.")

field_registry.register(report_field)

Expand Down
Loading

0 comments on commit 0d7b3a6

Please sign in to comment.