diff --git a/coldfront/core/project/forms.py b/coldfront/core/project/forms.py index beeea24e9..039b17d8c 100644 --- a/coldfront/core/project/forms.py +++ b/coldfront/core/project/forms.py @@ -7,7 +7,7 @@ from django.db.models.functions import Lower from cProfile import label -from coldfront.core.project.models import (Project, ProjectAttribute, ProjectAttributeType, ProjectReview, +from coldfront.core.project.models import (Project, ProjectAttribute, ProjectAttributeType, ProjectReview, ProjectStatusChoice, ProjectUserRoleChoice) from coldfront.core.utils.common import import_from_settings @@ -25,11 +25,17 @@ class ProjectSearchForm(forms.Form): USERNAME = 'Username' FIELD_OF_SCIENCE = 'Field of Science' + title = forms.CharField(label='Title', + max_length=100, required=False) last_name = forms.CharField( label=LAST_NAME, max_length=100, required=False) username = forms.CharField(label=USERNAME, max_length=100, required=False) field_of_science = forms.CharField( label=FIELD_OF_SCIENCE, max_length=100, required=False) + status = forms.ModelMultipleChoiceField( + widget=forms.CheckboxSelectMultiple, + queryset=ProjectStatusChoice.objects.all().order_by(Lower("name")), + required=False) show_all_projects = forms.BooleanField(initial=False, required=False) diff --git a/coldfront/core/project/views.py b/coldfront/core/project/views.py index a71dda349..a2824c75e 100644 --- a/coldfront/core/project/views.py +++ b/coldfront/core/project/views.py @@ -218,6 +218,11 @@ def get_queryset(self): Q(projectuser__status__name='Active') ).order_by(order_by) + # Project Title + if data.get('title'): + projects = projects.filter( + title__icontains=data.get('title')) + # Last Name if data.get('last_name'): projects = projects.filter( @@ -236,6 +241,11 @@ def get_queryset(self): projects = projects.filter( field_of_science__description__icontains=data.get('field_of_science')) + # Status + if data.get('status'): + projects = projects.filter( + status__in=data.get('status')) + else: projects = Project.objects.prefetch_related('pi', 'field_of_science', 'status',).filter( Q(status__name__in=['New', 'Active', ]) &