From 8db67a1e543a81413de08154e020fbc9dc17e200 Mon Sep 17 00:00:00 2001 From: Esmat-Farjad Date: Wed, 27 Dec 2023 14:57:11 +0430 Subject: [PATCH] project filter fixed --- src/project_reports/filter.py | 36 +++++++++++++++++ ...5_alter_activityplanreport_report_types.py | 19 +++++++++ src/project_reports/models.py | 2 +- .../views/monthly_reports_view_base.html | 40 ++++--------------- src/project_reports/views.py | 17 +++++++- src/rh/filters.py | 10 ++--- .../rh/projects/views/projects_view_base.html | 21 +++++++++- .../project_reports/js/monthly_report.js | 2 + src/static/src/styles/layout/_common.scss | 21 ++++++++++ 9 files changed, 126 insertions(+), 42 deletions(-) create mode 100644 src/project_reports/filter.py create mode 100644 src/project_reports/migrations/0005_alter_activityplanreport_report_types.py diff --git a/src/project_reports/filter.py b/src/project_reports/filter.py new file mode 100644 index 00000000..c2f83653 --- /dev/null +++ b/src/project_reports/filter.py @@ -0,0 +1,36 @@ +import django_filters +from django import forms + +from rh.models import ActivityDomain, Cluster, Location, Organization +from .models import ProjectMonthlyReport + +class ReportFilterForm(django_filters.FilterSet): + clusters = django_filters.ModelMultipleChoiceFilter( + # field_name='test', + # to_field_name='project', + queryset = Cluster.objects.all(), + widget=forms.SelectMultiple() + ) + organization = django_filters.ModelMultipleChoiceFilter( + queryset = Organization.objects.all(), + widget=forms.SelectMultiple(), + ) + activity_domains = django_filters.ModelChoiceFilter( + queryset = ActivityDomain.objects.all(), + widget=forms.SelectMultiple(), + ) + country = django_filters.ModelChoiceFilter( + queryset = Location.objects.filter(type="Country"), + widget=forms.Select(), + ) + province = django_filters.ModelChoiceFilter( + queryset = Location.objects.filter(type="Province"), + widget=forms.Select() + ), + district = django_filters.ModelChoiceFilter( + queryset = Location.objects.filter(type="District"), + widget=forms.Select(), + ) + class Meta: + model = ProjectMonthlyReport + fields = "__all__" \ No newline at end of file diff --git a/src/project_reports/migrations/0005_alter_activityplanreport_report_types.py b/src/project_reports/migrations/0005_alter_activityplanreport_report_types.py new file mode 100644 index 00000000..6fbd0c7c --- /dev/null +++ b/src/project_reports/migrations/0005_alter_activityplanreport_report_types.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0.6 on 2023-12-27 03:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('rh', '0012_merge_20231220_0933'), + ('project_reports', '0004_activityplanreport_target_achieved'), + ] + + operations = [ + migrations.AlterField( + model_name='activityplanreport', + name='report_types', + field=models.ManyToManyField(blank=True, to='rh.reporttype'), + ), + ] diff --git a/src/project_reports/models.py b/src/project_reports/models.py index c4a68ea8..ec1905a2 100644 --- a/src/project_reports/models.py +++ b/src/project_reports/models.py @@ -47,7 +47,7 @@ class ActivityPlanReport(models.Model): activity_plan = models.ForeignKey(ActivityPlan, on_delete=models.CASCADE, null=True, blank=True) indicator = models.ForeignKey(Indicator, on_delete=models.SET_NULL, null=True) - report_types = models.ManyToManyField(ReportType, null=True, blank=True) + report_types = models.ManyToManyField(ReportType, blank=True) target_achieved = models.IntegerField(default=0, null=True, blank=True) class Meta: diff --git a/src/project_reports/templates/project_reports/views/monthly_reports_view_base.html b/src/project_reports/templates/project_reports/views/monthly_reports_view_base.html index 9c16ab18..94be929f 100644 --- a/src/project_reports/templates/project_reports/views/monthly_reports_view_base.html +++ b/src/project_reports/templates/project_reports/views/monthly_reports_view_base.html @@ -36,7 +36,7 @@
- Filter +
@@ -53,28 +53,16 @@
- - + + {{report_filter.form.country}}
- + {{report_filter.form.province}}
- + {{report_filter.form.district}}
@@ -89,27 +77,15 @@
- + {{report_filter.form.clusters}}
- + {{report_filter.form.organization}}
- + {{report_filter.form.activity_domains}}
- Filter + Filter + + + + +
Filter
+
+ + + Get your project data sorted. + + +
+
[hold down the control/command button to select multiple]
{{ project_filter.form.donors }}
+
[hold down the control/command button to select multiple]
{{ project_filter.form.clusters }}
- {{ project_filter.form.activities }} +
[hold down the control/command button to select multiple]
+ {{ project_filter.form.activity_domains }}
@@ -99,10 +114,12 @@
+
[hold down the control/command button to select multiple]
{{ project_filter.form.implementing_partners }}
+
[hold down the control/command button to select multiple]
{{ project_filter.form.programme_partners }}
diff --git a/src/static/project_reports/js/monthly_report.js b/src/static/project_reports/js/monthly_report.js index 47435fde..c78508a2 100644 --- a/src/static/project_reports/js/monthly_report.js +++ b/src/static/project_reports/js/monthly_report.js @@ -3,6 +3,8 @@ **/ $(function () { + $(".js_multiselect").select2(); + $('tr[data-url]').on('click', function() { window.location.href = $(this).data('url'); }); diff --git a/src/static/src/styles/layout/_common.scss b/src/static/src/styles/layout/_common.scss index af95078d..496b01eb 100644 --- a/src/static/src/styles/layout/_common.scss +++ b/src/static/src/styles/layout/_common.scss @@ -95,6 +95,17 @@ ul{ .target-location-container { margin: 8px 0; } +.info-sign{ + border: 1px solid $red-be; + margin-right: 3px; + border-radius: 5px; +} +.filter-heading-text{ + margin-bottom: 10px; + font-size: 14px; + font-weight: 600; + color: #6b6d70; +} .circle-bage{ background-color: #6b6d70; color: white; @@ -147,6 +158,16 @@ ul{ .show-password{ float: inline-end; } +.small-label{ + font-size: 11px; + font-weight: 600; + vertical-align: top; + color: #aaadb1; +} +.input-select{ + width: 100%; + height: 4.5rem; +} //------------------------ // Random added style end //-------------------------