Package: django-easy-report
Django easy reportDjango App for generate easily reports usingCeleryImplments the following functions:Allows permissions by report.Allows multi storage systems.Allows prevalidation before generate.Detect same report params to allows cache it.Allows add requeters to a existing report.Allows customize send flow inside the report code.Allows secrets keys for storage setup based on:django settings,environmentorcryptography.Allows filter for storages and report classes.Action that allows generate report from Admin page.SetUpInstall package frompypi:pipinstalldjango-easy-reportAdd application onsettings.py:# ...INSTALLED_APPS=[# ...'django_easy_report',# ...]Add onurls.pythe namespacedjango_easy_report:# ...urlpatterns=[# ...path('reports/',include(('django_easy_report.urls','django_easy_report'),namespace='django_easy_report')),# ...]ConfigureceleryProtect import dynamic classesIn order to block insecure classes onReportSenderandReportGeneratormodels,
is allowed to define the onsettings.pythe settingSENDER_CLASSESand/orREPORT_CLASSES:# ...SENDER_CLASSES=['django.core.files.storage.FileSystemStorage',]REPORT_CLASSES=['django_easy_report.reports.ReportModelGenerator','django_easy_report.reports.AdminReportGenerator',]# ...That values will be checked when model is saved and loaded,
that means that you will not able to use the reports
who have classes not listed on the proper setting.HowtoCreate your code (see example).CreateFormclass for validate input.Create Report class (extended fromReportBaseGenerator).Overwrite functionget_paramsfor know the users params and the report params.Overwrite functionvalidatecallingsuperto validate the form.Implement functiongeneratefunction usingself.bufferfor write the report.Overwrite functionget_filenameto set report name.Overwrite functionget_messageto return the email body or raiseDoNotSendto omit email send.Create reportSenderon Admin page.CreateReport Generatoron Admin page.Use you report endpoint defined on Admin page.Using SecretsIn order to protect your secrets you could use theSecretKeyModel.
That allows you usedjango settings,environmentorcryptographyto protect your secrets.When you use that secrets you must create the model, on the Admin page.
The information that you enter must be on plain text.
Thekeyfield is only required when crypto is using.Then you must create or edit aReportSendermodel, adding on the key that you want to use.
Thereplace wordwill be used on theStorage init paramsfield to replace with the value of the secret in plain text.
That allow you to replace the value ofStorage init paramsfrom:{"my_secret":"Insecure secret"}to{"my_secret":$my_replace_word}Using Admin ActionIn order to allow generate reports based on admin page,
there is an action localed ondjango_easy_report.actions.generate_report.
You could see an example on:test_web/custom/admin.pyTo allows the generation flow on the standard flow you must
createReport Generatoron Admin page using the classdjango_easy_report.reports.AdminReportGenerator.
In order to work you could only have one report using that class.API workflowSee doc asOpenAPI formator inswaggerExamplesIn both cases, the report is already generated by other user.Notify me when report is doneRegenerate new reportTest it with DockerDocker-composedocker-composeupweb-d
docker-composeexecwebbashDockerdockerbuild.--tag="django_easy_report:latest"dockerrun--publish=8000:8000--name=django_easy_report_webdjango_easy_report:latest-d
dockerexec-tidjango_easy_report_webbashRun tests locallydockerbuild.--tag="django_easy_report:py38dj22"--build-argPY_VERSION=3.8--build-argDJANGO_VERSION=2.2
dockerrun--rm--entrypoint/usr/local/bin/python--name=test_django_easy_report_webdjango_easy_report:py38dj22manage.pytestNote that in that case you need rebuild with any change in the codeMIT LicenseCopyright 2021 Victor TorrePermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.