Skip to content

Commit

Permalink
filter bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Esmat-Farjad committed Dec 28, 2023
1 parent 8db67a1 commit be70c08
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
23 changes: 12 additions & 11 deletions src/project_reports/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@
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()
queryset=Cluster.objects.all(),
widget=forms.SelectMultiple(),
)
organization = django_filters.ModelMultipleChoiceFilter(
queryset = Organization.objects.all(),
queryset=Organization.objects.all(),
widget=forms.SelectMultiple(),
)
activity_domains = django_filters.ModelChoiceFilter(
queryset = ActivityDomain.objects.all(),
queryset=ActivityDomain.objects.all(),
widget=forms.SelectMultiple(),
)
country = django_filters.ModelChoiceFilter(
queryset = Location.objects.filter(type="Country"),
queryset=Location.objects.filter(type="Country"),
widget=forms.Select(),
)
province = django_filters.ModelChoiceFilter(
queryset = Location.objects.filter(type="Province"),
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"),
queryset=Location.objects.filter(type="District"),
widget=forms.Select(),
)

class Meta:
model = ProjectMonthlyReport
fields = "__all__"
fields = "__all__"
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@


class Migration(migrations.Migration):

dependencies = [
('rh', '0012_merge_20231220_0933'),
('project_reports', '0004_activityplanreport_target_achieved'),
("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'),
model_name="activityplanreport",
name="report_types",
field=models.ManyToManyField(blank=True, to="rh.reporttype"),
),
]
7 changes: 5 additions & 2 deletions src/project_reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from django.urls import reverse
from django.utils import timezone
from django.views.decorators.cache import cache_control
from .filter import ReportFilterForm

# from .filter import ReportFilterForm
from rh.models import ImplementationModalityType, Indicator, Location, Project

from .forms import (
Expand All @@ -22,9 +23,11 @@
TargetLocationReportFormSet,
)
from .models import ActivityPlanReport, DisaggregationLocationReport, ProjectMonthlyReport, TargetLocationReport
from django.core.paginator import Paginator

# from django.core.paginator import Paginator
RECORDS_PER_PAGE = 10


@cache_control(no_store=True)
@login_required
def index_project_report_view(request, project):
Expand Down
14 changes: 5 additions & 9 deletions src/rh/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@
class ProjectsFilter(django_filters.FilterSet):
# FIXME: Fix the options issue
clusters = django_filters.ModelMultipleChoiceFilter(
queryset=Cluster.objects.all(),
widget=forms.SelectMultiple(attrs={"class":"input-select"})
queryset=Cluster.objects.all(), widget=forms.SelectMultiple(attrs={"class": "input-select"})
)
implementing_partners = django_filters.ModelMultipleChoiceFilter(
queryset=Organization.objects.all(),
widget=forms.SelectMultiple(attrs={"class":"input-select"})
queryset=Organization.objects.all(), widget=forms.SelectMultiple(attrs={"class": "input-select"})
)
donors = django_filters.ModelMultipleChoiceFilter(
queryset=Donor.objects.all(),
widget=forms.SelectMultiple(attrs={"class":"input-select"}),
widget=forms.SelectMultiple(attrs={"class": "input-select"}),
)
programme_partners = django_filters.ModelMultipleChoiceFilter(
queryset=Organization.objects.all(),
widget=forms.SelectMultiple(attrs={"class":"input-select"})
queryset=Organization.objects.all(), widget=forms.SelectMultiple(attrs={"class": "input-select"})
)
activity_domains = django_filters.ModelMultipleChoiceFilter(
queryset=ActivityDomain.objects.all(),
widget=forms.SelectMultiple(attrs={"class":"input-select"})
queryset=ActivityDomain.objects.all(), widget=forms.SelectMultiple(attrs={"class": "input-select"})
)

class Meta:
Expand Down

0 comments on commit be70c08

Please sign in to comment.