From b66f88bb414b72d80d1c8efe3a1bb9879348d587 Mon Sep 17 00:00:00 2001 From: Chriford Siame Date: Fri, 25 Mar 2022 10:43:04 +0200 Subject: [PATCH 1/4] enable report builder functionalities in the ui --- config/settings/base.py | 23 ++++++++++++++++------- config/urls.py | 2 +- itez/beneficiary/urls.py | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 97f11994..22028b94 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -55,7 +55,12 @@ "PORT": env("DATABASE_PORT"), } } - +# REPORT_BUILDER_THEME = True +# REPORT_BUILDER_ASYNC_REPORT = True +# REPORT_BUILDER_MODEL_MANAGER = 'on_site' +# REPORT_BUILDER_INCLUDE = [ +# "itez.beneficiary", +# ] # URLS # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf @@ -94,8 +99,15 @@ # "notifications_rest", "mapwidgets", "django_celery_results", + "report_builder", ] + +REPORT_BUILDER_INCLUDE = [ + "beneficiary", + "agent", + "beneficiaryparent", +] LOCAL_APPS = [ "itez.users.apps.UsersConfig", "itez.authentication.apps.AuthenticationConfig", @@ -209,11 +221,12 @@ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.template.context_processors.i18n", - "django.template.context_processors.media", - "django.template.context_processors.static", + "django.template.context_processors.tz", "django.contrib.messages.context_processors.messages", "itez.utils.context_processors.settings_context", + "django.template.context_processors.static", + "django.template.context_processors.media", ], }, } @@ -342,16 +355,12 @@ # ------------------------------------------------------------------------------- # django-rest-framework - https://www.django-rest-framework.org/api-guide/settings/ REST_FRAMEWORK = { - "DEFAULT_AUTHENTICATION_CLASSES": ( - "itez.authentication.backends.ActiveSessionAuthentication", - ), "DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",), "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", "PAGE_SIZE": 10, } - CORS_ORIGIN_ALLOW_ALL = True # CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_HEADERS = ["*"] diff --git a/config/urls.py b/config/urls.py index 48e622ec..4d85f41c 100644 --- a/config/urls.py +++ b/config/urls.py @@ -24,12 +24,12 @@ ) urlpatterns = [ - path(settings.ADMIN_URL, admin.site.urls), path("", include("itez.beneficiary.urls", namespace="beneficiary")), path("", include("itez.authentication.urls")), path("", include("itez.users.urls", namespace="user")), path('inbox/notifications/', include(notifications.urls, namespace='notifications')), # path('^notifications/', include('notifications_rest.urls')), + path("report/builder", include("report_builder.urls")), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) admin.site.site_header = "ITEZ Administration" diff --git a/itez/beneficiary/urls.py b/itez/beneficiary/urls.py index aac021f0..a88baea4 100644 --- a/itez/beneficiary/urls.py +++ b/itez/beneficiary/urls.py @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- -from django.urls import path, re_path +from django.urls import path, re_path, include from itez.beneficiary import views app_name = "beneficiary" From 15051fdc30823ec23bb086867d6d1810fee43f39 Mon Sep 17 00:00:00 2001 From: Chriford Siame Date: Fri, 25 Mar 2022 10:45:02 +0200 Subject: [PATCH 2/4] restore report builder functionalities in the ui --- config/settings/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/settings/base.py b/config/settings/base.py index 22028b94..6e24df2a 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -360,7 +360,7 @@ "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", "PAGE_SIZE": 10, } - + CORS_ORIGIN_ALLOW_ALL = True # CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_HEADERS = ["*"] From 7f2586824360b10597b086986bbbe924df820738 Mon Sep 17 00:00:00 2001 From: Chriford Siame Date: Fri, 25 Mar 2022 11:03:35 +0200 Subject: [PATCH 3/4] add model names in a list --- config/settings/base.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/config/settings/base.py b/config/settings/base.py index 6e24df2a..bae595a6 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -104,9 +104,21 @@ REPORT_BUILDER_INCLUDE = [ - "beneficiary", - "agent", - "beneficiaryparent", + "beneficiary" + ,"agent" + ,"beneficiaryparent" + ,"province" + ,"district" + ,"servicearea" + ,"workdetail" + ,"implementingpartner" + ,"facilitytype" + ,"facility" + ,"serviceproviderpersonelqualification" + ,"serviceproviderpersonel" + ,"drug" + ,"service" + ,"medicalrecord" ] LOCAL_APPS = [ "itez.users.apps.UsersConfig", @@ -360,7 +372,7 @@ "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination", "PAGE_SIZE": 10, } - + CORS_ORIGIN_ALLOW_ALL = True # CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_HEADERS = ["*"] From 6f318e47924cf05514a66babbd4149ce52e29382 Mon Sep 17 00:00:00 2001 From: Chriford Siame Date: Fri, 25 Mar 2022 12:19:23 +0200 Subject: [PATCH 4/4] inherit base --- config/urls.py | 2 +- itez/templates/layouts/base.html | 1 + itez/templates/report_builder/base.html | 42 ++++++++++++++ .../report_builder/export_to_report.html | 56 +++++++++++++++++++ itez/templates/report_builder/spa.html | 25 +++++++++ 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 itez/templates/report_builder/base.html create mode 100644 itez/templates/report_builder/export_to_report.html create mode 100644 itez/templates/report_builder/spa.html diff --git a/config/urls.py b/config/urls.py index 4d85f41c..e91cf09c 100644 --- a/config/urls.py +++ b/config/urls.py @@ -29,7 +29,7 @@ path("", include("itez.authentication.urls")), path("", include("itez.users.urls", namespace="user")), path('inbox/notifications/', include(notifications.urls, namespace='notifications')), # path('^notifications/', include('notifications_rest.urls')), - path("report/builder", include("report_builder.urls")), + path("report/builder/", include("report_builder.urls")), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) admin.site.site_header = "ITEZ Administration" diff --git a/itez/templates/layouts/base.html b/itez/templates/layouts/base.html index a2dc4435..9f8f8885 100644 --- a/itez/templates/layouts/base.html +++ b/itez/templates/layouts/base.html @@ -5,6 +5,7 @@ + {% block rb_head %} {% endblock %} diff --git a/itez/templates/report_builder/base.html b/itez/templates/report_builder/base.html new file mode 100644 index 00000000..1a8d456d --- /dev/null +++ b/itez/templates/report_builder/base.html @@ -0,0 +1,42 @@ +{% extends 'layouts/base.html' %} +{% block rb_head %} + + {% block angular_app %} + {% block report_header %} + {% endblock %} + {% endblock %} +{% endblock %} + +{% block content %} +
+
+ +
+ +
+
+ {% block report_builder_content %} + {% block nav %} + {{ block.super }} + +
+ {% endblock %} + + {% endblock report_builder_content %} + +
+
+ + + {% block javascripts %} + + {% endblock javascripts %} + +{% endblock %} + diff --git a/itez/templates/report_builder/export_to_report.html b/itez/templates/report_builder/export_to_report.html new file mode 100644 index 00000000..3fed924b --- /dev/null +++ b/itez/templates/report_builder/export_to_report.html @@ -0,0 +1,56 @@ +{% extends "report_builder/base.html" %} +{% load i18n %} +{% block content %} + + +

+ {% trans "Select the report you wish to use. Report filters will be ignored and only your checked off items will be reported." %} +

+

+ {% trans "Create and manage reports" %} {% trans "here" %}. +

+

+ {% blocktrans with number_objects=number_objects model=model plur=number_objects|pluralize admin_url=admin_url %} + You have selected {{ number_objects }} {{ model }} record{{ plur }}. Click here to go back. + {% endblocktrans %} +

+

{{ model|capfirst }} {% trans "Reports" %}

+ + + + + + + + + + + + {% for report in object_list %} + + + + + + + + {% endfor %} + +
{% trans "Name" %}{% trans "Description" %}{% trans "Created" %}{% trans "Modified" %}{% trans "Select and Download" %}
+ {{ report.name }} + + {{ report.description }} + + {% blocktrans with created=report.created user=report.user_created %} + {{ created }} by {{ user }} + {% endblocktrans %} + + {% blocktrans with modified=report.modified user=report.user_modified %} + {{ modified }} by {{ user }} + {% endblocktrans %} + + + + +
+{% endblock %} diff --git a/itez/templates/report_builder/spa.html b/itez/templates/report_builder/spa.html new file mode 100644 index 00000000..bc11d357 --- /dev/null +++ b/itez/templates/report_builder/spa.html @@ -0,0 +1,25 @@ +{% extends "report_builder/base.html" %} +{% load static %} + +{% block report_header %} + + PPRC-TRALARD | THINK2044 + + +{% endblock %} + +{% block report_builder_content %} + {% if not STATIC_URL %} +

Please add 'django.core.context_processors.static' to context_processors in settings.py

+ {% endif %} + + + + + + + + + + +{% endblock %}