+
\ No newline at end of file
diff --git a/demo_proj/templates/slick_reporting/base.html b/demo_proj/templates/slick_reporting/base.html
index 6932026..1389253 100644
--- a/demo_proj/templates/slick_reporting/base.html
+++ b/demo_proj/templates/slick_reporting/base.html
@@ -1,17 +1,9 @@
{% extends "base.html" %}
-
-{% block page_title %}
- {{ report_title }}
-{% endblock %}
-{% block meta_page_title %}
- {{ report_title }}
-
-{% endblock %}
+{% block meta_page_title %} {{ report_title }}{% endblock %}
+{% block page_title %} {{ report_title }} {% endblock %}
{% block extrajs %}
{{ block.super }}
-
{% include "slick_reporting/js_resources.html" %}
-
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/docs/requirements.txt b/docs/requirements.txt
index f0ffece..cad92e3 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,4 +1,5 @@
-sphinx==4.2.0
-sphinx_rtd_theme==1.0.0
-readthedocs-sphinx-search==0.1.1
-django-slick-reporting==0.6.4
\ No newline at end of file
+-r ../requirements.txt
+crispy_bootstrap4
+sphinx
+sphinx_rtd_theme==1.3.0
+readthedocs-sphinx-search==0.3.1
\ No newline at end of file
diff --git a/docs/source/charts.rst b/docs/source/charts.rst
deleted file mode 100644
index 3dafcef..0000000
--- a/docs/source/charts.rst
+++ /dev/null
@@ -1,114 +0,0 @@
-Charting and Front End Customization
-=====================================
-
-Charts Configuration
----------------------
-
-Charts settings is a list of objects which each object represent a chart configurations.
-
-* type: what kind of chart it is: Possible options are bar, pie, line and others subject of the underlying charting engine.
- Hats off to : `Charts.js `_.
-* engine_name: String, default to ``SLICK_REPORTING_DEFAULT_CHARTS_ENGINE``. Passed to front end in order to use the appropriate chart engine.
- By default supports `highcharts` & `chartsjs`.
-* data_source: Field name containing the numbers we want to plot.
-* title_source: Field name containing labels of the data_source
-* title: the Chart title. Defaults to the `report_title`.
-* plot_total if True the chart will plot the total of the columns. Useful with time series and crosstab reports.
-
-On front end, for each chart needed we pass the whole response to the relevant chart helper function and it handles the rest.
-
-
-
-
-The ajax response structure
----------------------------
-
-Understanding how the response is structured is imperative in order to customize how the report is displayed on the front end
-
-Let's have a look
-
-.. code-block:: python
-
-
- # Ajax response or `report_results` template context variable.
- response = {
- # the report slug, defaults to the class name all lower
- "report_slug": "",
- # a list of objects representing the actual results of the report
- "data": [
- {
- "name": "Product 1",
- "quantity__sum": "1774",
- "value__sum": "8758",
- "field_x": "value_x",
- },
- {
- "name": "Product 2",
- "quantity__sum": "1878",
- "value__sum": "3000",
- "field_x": "value_x",
- },
- # etc .....
- ],
- # A list explaining the columns/keys in the data results.
- # ie: len(response.columns) == len(response.data[i].keys())
- # It contains needed information about verbose name , if summable and hints about the data type.
- "columns": [
- {
- "name": "name",
- "computation_field": "",
- "verbose_name": "Name",
- "visible": True,
- "type": "CharField",
- "is_summable": False,
- },
- {
- "name": "quantity__sum",
- "computation_field": "",
- "verbose_name": "Quantities Sold",
- "visible": True,
- "type": "number",
- "is_summable": True,
- },
- {
- "name": "value__sum",
- "computation_field": "",
- "verbose_name": "Value $",
- "visible": True,
- "type": "number",
- "is_summable": True,
- },
- ],
- # Contains information about the report as whole if it's time series or a a crosstab
- # And what's the actual and verbose names of the time series or crosstab specific columns.
- "metadata": {
- "time_series_pattern": "",
- "time_series_column_names": [],
- "time_series_column_verbose_names": [],
- "crosstab_model": "",
- "crosstab_column_names": [],
- "crosstab_column_verbose_names": [],
- },
- # A mirror of the set charts_settings on the ReportView
- # ``ReportView`` populates the id and the `engine_name' if not set
- "chart_settings": [
- {
- "type": "pie",
- "engine_name": "highcharts",
- "data_source": ["quantity__sum"],
- "title_source": ["name"],
- "title": "Pie Chart (Quantities)",
- "id": "pie-0",
- },
- {
- "type": "bar",
- "engine_name": "chartsjs",
- "data_source": ["value__sum"],
- "title_source": ["name"],
- "title": "Column Chart (Values)",
- "id": "bar-1",
- },
- ],
- }
-
-
diff --git a/docs/source/concept.rst b/docs/source/concept.rst
index 33aa12f..4a3d9f6 100644
--- a/docs/source/concept.rst
+++ b/docs/source/concept.rst
@@ -1,37 +1,42 @@
.. _structure:
-How the documentation is organized
-==================================
+Welcome to Django Slick Reporting documentation!
+==================================================
-:ref:`Tutorial `
---------------------------
+Django Slick Reporting a reporting engine allowing you to create and chart different kind of analytics from your model in a breeze.
+
+Demo site
+---------
-If you are new to Django Slick Reporting, start here. It's a step-by-step guide to building a simple report(s).
+If you haven't yet, please check https://django-slick-reporting.com for a quick walk-though with live code examples..
-:ref:`How-to guides `
------------------------------
-Practical, hands-on guides that show you how to achieve a specific goal with Django Slick Reporting. Like customizing the form, creating a computation field, etc.
+:ref:`Tutorial `
+--------------------------
+
+The tutorial will guide you to what is slick reporting, what kind of reports it can do for you and how to use it in your project.
+
:ref:`Topic Guides `
----------------------------
-Discuss each type of reports you can create with Django Slick Reporting and their options.
+Discuss each type of report main structures you can create with Django Slick Reporting and their options.
- * :ref:`Grouped report `: Similar to what we'd do with a GROUP BY sql statement. We group by a field and do some kind of calculations over the grouped records.
- * :ref:`time_series`: A step up from the grouped report, where the calculations are computed for each time period (day, week, month, etc).
- * :ref:`crosstab_reports`: Where the results shows the relationship between two or more variables. Example: Rows are the clients, columns are the products, and the intersection values are the sum of sales for each client and product combination. This report can be created in time series as well. Example: Rows are the clients, columns are the products, and the intersection values are the sum of sales for each client and product combination, for each month.
- * :ref:`list_reports`: Similar to a django changelist, it's a direct view of the report model records with some extra features like sorting, filtering, pagination, etc.
+ * :ref:`Group By report `: Similar to what we'd do with a GROUP BY sql statement. We group by a field and do some kind of calculations over the grouped records.
+ * :ref:`time_series`: A step further, where the calculations are computed for time periods (day, week, month, custom etc).
+ * :ref:`crosstab_reports`: Where the results shows the relationship between two or more variables. It's a table that shows the distribution of one variable in rows and another in columns.
+ * :ref:`list_reports`: Similar to a django admin's changelist, it's a direct view of the report model records
* And other topics like how to customize the form, and extend the exporting options.
:ref:`Reference `
----------------------------
-Detailed information about main on Django Slick Reporting's main components, such as the :ref:`Report View `, :ref:`Generator `, :ref:`Computation Field `, etc.
+Detailed information about main on Django Slick Reporting's main components
+ #. :ref:`Settings `: The settings you can use to customize the behavior of Django Slick Reporting.
#. :ref:`Report View `: A ``FormView`` CBV subclass with reporting capabilities allowing you to create different types of reports in the view.
It provide a default :ref:`Filter Form ` to filter the report on.
It mimics the Generator API interface, so knowing one is enough to work with the other.
@@ -46,8 +51,3 @@ Detailed information about main on Django Slick Reporting's main components, suc
-
-Demo site
----------
-
-If you haven't yet, please check https://django-slick-reporting.com for a quick walk-though with live code examples..
diff --git a/docs/source/howto/override_filter_form.rst b/docs/source/howto/override_filter_form.rst
deleted file mode 100644
index e69de29..0000000
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 49882cc..37a577f 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -90,8 +90,6 @@ Next step :ref:`tutorial`
concept
tutorial
topics/index
- howto/index
- charts
ref/index
diff --git a/docs/source/ref/index.rst b/docs/source/ref/index.rst
index 8d5f939..f81e27b 100644
--- a/docs/source/ref/index.rst
+++ b/docs/source/ref/index.rst
@@ -9,6 +9,7 @@ Below are links to the reference documentation for the various components of the
:maxdepth: 2
:caption: Components:
+ settings
computation_field
report_generator
view_options
diff --git a/docs/source/ref/settings.rst b/docs/source/ref/settings.rst
index 20396bd..f3036be 100644
--- a/docs/source/ref/settings.rst
+++ b/docs/source/ref/settings.rst
@@ -1,7 +1,73 @@
+.. _ settings:
Settings
========
+.. note::
+
+ Settings are changed in version 1.1.1 to being a dictionary instead of individual variables.
+ Variables will continue to work till next major release.
+
+
+Below are the default settings for django-slick-reporting. You can override them in your settings file.
+
+.. code-block:: python
+
+ SLICK_REPORTING_SETTINGS = {
+ "JQUERY_URL": "https://code.jquery.com/jquery-3.7.0.min.js",
+ "DEFAULT_START_DATE_TIME": datetime(
+ datetime.now().year, 1, 1, 0, 0, 0, tzinfo=timezone.utc
+ ), # Default: 1st Jan of current year
+ "DEFAULT_END_DATE_TIME": datetime.datetime.today(), # Default to today
+ "FONT_AWESOME": {
+ "CSS_URL": "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css",
+ "ICONS": {
+ "pie": "fas fa-chart-pie",
+ "bar": "fas fa-chart-bar",
+ "line": "fas fa-chart-line",
+ "area": "fas fa-chart-area",
+ "column": "fas fa-chart-column",
+ },
+ },
+ "CHARTS": {
+ "highcharts": "$.slick_reporting.highcharts.displayChart",
+ "chartjs": "$.slick_reporting.chartjs.displayChart",
+ },
+ "MESSAGES": {
+ "total": _("Total"),
+ },
+ }
+
+* JQUERY_URL:
+
+ Link to the jquery file, You can use set it to False and manage the jQuery addition to your liking
+
+* DEFAULT_START_DATE_TIME
+
+ Default date time that would appear on the filter form in the start date
+
+* DEFAULT_END_DATE_TIME
+
+ Default date time that would appear on the filter form in the end date
+
+* FONT_AWESOME:
+
+ Font awesome is used to display the icon next to the chart title. You can override the following settings:
+
+ 1. ``CSS_URL``: URL to the font-awesome css file
+ 2. ``ICONS``: Icons used for different chart types.
+
+* CHARTS:
+
+ The entry points for displaying charts on the front end.
+ You can add your own chart engine by adding an entry to this dictionary.
+
+* MESSAGES:
+
+ The strings used in the front end. You can override them here, it also gives a chance to set and translate them per your requirements.
+
+
+Old versions settings:
1. ``SLICK_REPORTING_DEFAULT_START_DATE``: Default: the beginning of the current year
2. ``SLICK_REPORTING_DEFAULT_END_DATE``: Default: the end of the current year.
diff --git a/docs/source/topics/filter_form.rst b/docs/source/topics/filter_form.rst
index 2e540ef..a68e737 100644
--- a/docs/source/topics/filter_form.rst
+++ b/docs/source/topics/filter_form.rst
@@ -120,4 +120,4 @@ Example a full example of a custom form:
class RequestCountByPath(ReportView):
form_class = RequestLogForm
-You can view this code snippet in action on the demo project https://my-shop.django-erp-framework.com/requests-dashboard/reports/request_analytics/requestlog/
+You can view this code snippet in action on the demo project https://django-slick-reporting.com/total-product-sales-with-custom-form/
diff --git a/docs/source/topics/index.rst b/docs/source/topics/index.rst
index 5b2f26f..3cfc7e2 100644
--- a/docs/source/topics/index.rst
+++ b/docs/source/topics/index.rst
@@ -31,6 +31,6 @@ You saw how to use the ReportView class in the tutorial and you identified the t
crosstab_options
list_report_options
filter_form
+ widgets
+ integrating_slick_reporting
exporting
-
-
diff --git a/docs/source/topics/integrating_slick_reporting.rst b/docs/source/topics/integrating_slick_reporting.rst
new file mode 100644
index 0000000..a14b370
--- /dev/null
+++ b/docs/source/topics/integrating_slick_reporting.rst
@@ -0,0 +1,82 @@
+Integrating reports into your front end
+=======================================
+
+To integrate Slick Reporting into your application, you need to do override "slick_reporting/base.html" template,
+and/or, for more fine control over the report layout, override "slick_reporting/report.html" template.
+
+Example 1: Override base.html
+
+.. code-block:: html+django
+
+ {% extends "base.html" %}
+
+ {% block meta_page_title %} {{ report_title }}{% endblock %}
+ {% block page_title %} {{ report_title }} {% endblock %}
+
+ {% block extrajs %}
+ {{ block.super }}
+ {% include "slick_reporting/js_resources.html" %}
+ {% endblock %}
+
+
+
+Let's see what we did there
+1. We made our slick_reporting/base.html extend the main base.html
+2. We added the ``report_title`` context variable (which hold the current report title) to the meta_page_title and page_title blocks.
+ Use your version of these blocks, you might have them named differently.
+3. We added the slick_reporting/js_resources.html template to the extrajs block. This template contains the javascript resources needed for slick_reporting to work.
+ Also, use your version of the extrajs block. You might have it named differently.
+
+And that's it ! You can now use slick_reporting in your application.
+
+
+Example 2: Override report.html
+
+Maybe you want to add some extra information to the report, or change the layout of the report.
+You can do this by overriding the slick_reporting/report.html template.
+
+Here is how it looks like:
+
+.. code-block:: html+django
+
+ {% extends 'slick_reporting/base.html' %}
+ {% load crispy_forms_tags i18n %}
+
+ {% block content %}
+
+ {% if form %}
+
+ {% endif %}
+
+
+
+
{% trans "Results" %}
+
+
+
+
+
+
+
+
+
+
+
+ {% endblock %}
diff --git a/docs/source/topics/list_report_options.rst b/docs/source/topics/list_report_options.rst
index f424f23..c4ac74c 100644
--- a/docs/source/topics/list_report_options.rst
+++ b/docs/source/topics/list_report_options.rst
@@ -7,25 +7,42 @@ List Reports
It's a simple ListView / admin changelist like report to display data in a model.
It's quite similar to ReportView except there is no calculation by default.
-Options:
---------
+Here is the options you can use to customize the report:
-filters: a list of report_model fields to be used as filters.
+#. ``columns``: a list of report_model fields to be displayed in the report, which support traversing
.. code-block:: python
class RequestLog(ListReportView):
- report_model = Request
+ report_model = SalesTransaction
+ columns = [
+ "id",
+ "date",
+ "client__name",
+ "product__name",
+ "quantity",
+ "price",
+ "value",
+ ]
- filters = ["method", "path", "user_agent", "user", "referer", "response"]
+#. ``filters``: a list of report_model fields to be used as filters.
-Would yield a form like this
+.. code-block:: python
+
+ class RequestLog(ListReportView):
+ report_model = SalesTransaction
+ columns = [
+ "id",
+ "date",
+ "client__name",
+ "product__name",
+ "quantity",
+ "price",
+ "value",
+ ]
+
+ filters = ["product", "client"]
-.. image:: _static/list_view_form.png
- :width: 800
- :alt: ListReportView form
- :align: center
-Check :ref:`filter_form_customization` To customize the form as you wish.
diff --git a/docs/source/topics/widgets.rst b/docs/source/topics/widgets.rst
index 66f3312..fac5f80 100644
--- a/docs/source/topics/widgets.rst
+++ b/docs/source/topics/widgets.rst
@@ -34,13 +34,15 @@ You can pass arguments to the ``get_widget`` function to control aspects of its
* success_callback: string, the name of a javascript function that will be called after the report data is retrieved.
* failure_callback: string, the name of a javascript function that will be called if the report data retrieval fails.
* template_name: string, the template name used to render the widget. Default to `slick_reporting/widget_template.html`
+* extra_params: string, extra parameters to pass to the report.
+* report_form_selector: string, a jquery selector that will be used to find the form that will be used to pass extra parameters to the report.
This code above will be actually rendered as this in the html page:
.. code-block:: html+django
-
+
-
+
+
-
@@ -65,49 +67,10 @@ This code above will be actually rendered as this in the html page:
The ``data-report-widget`` attribute is used by the javascript to find the
widget and render the report.
-you can add [data-no-auto-load] to the widget to prevent the widget from loading automatically.
-
-The ``data-report-url`` attribute is the url that will be used to fetch the data.
-The ``data-extra-params`` attribute is used to pass extra parameters to the report.
-The ``data-success-callback`` attribute is used to pass a javascript function that will be called after
-the report data is retrieved.
-The ``data-fail-callback`` attribute is used to pass a javascript function
-that will be called if the report data retrieval fails.
-The ``report-form-selector`` attribute is used to pass a jquery selector
-that will be used to find the form that will be used to pass extra parameters
-to the report.
-The ``data-chart-id`` attribute is used to pass the id of the chart that will
-be rendered. The ``data-display-chart-selector`` attribute is used to pass
-if the report loader should display the chart selectors links.
-
-
-The ``data-report-chart`` attribute is used by the javascript to find the
-container for the chart. The ``data-report-table`` attribute is used by the
-javascript to find the container for the table.
-
-
-``get_widget`` Tag can accept a ``template_name`` parameter to render the
-report using a custom template. By default it renders the
-``erp_reporting/report_widget.html`` template.
-
-Default Arguments
------------------
-
-extra_params
-success_callback
-failure_callback
-display_chart
-display_table
-chart_id
-display_title
-title (default to report report title)
-
-
-
-
+you can add [data-no-auto-load] to the widget to prevent report loader to get the widget data automatically.
-Customization
--------------
+Customization Example
+---------------------
You You can customize how the widget is loading by defining your own success call-back
and fail call-back functions.
@@ -117,12 +80,9 @@ The success call-back function will receive the report data as a parameter
.. code-block:: html+django
- {% load i18n static erp_reporting_tags %}
+ {% load i18n static slick_reporting_tags %}
-