Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions hypha/apply/projects/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ class Meta:
fields = ["project_status", "project_lead", "project_fund"]
model = Project

def __init__(self, *args, exclude=None, **kwargs):
if exclude is None:
exclude = []

super().__init__(*args, **kwargs)

self.filters = {
field: filter
for field, filter in self.filters.items()
if field not in exclude
}

def filter_reporting(self, queryset, name, value):
if value == "1":
return queryset.filter(outstanding_reports__gt=0)
Expand Down
11 changes: 11 additions & 0 deletions hypha/apply/projects/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2282,3 +2282,14 @@ class ProjectListView(SingleTableMixin, FilterView):
queryset = Project.objects.for_table()
table_class = ProjectsListTable
template_name = "application_projects/project_list.html"

excluded_fields = settings.PROJECTS_TABLE_EXCLUDED_FIELDS

def get_filterset_kwargs(self, filterset_class, **kwargs):
new_kwargs = super().get_filterset_kwargs(filterset_class)
new_kwargs["exclude"] = self.excluded_fields
new_kwargs.update(kwargs)
return new_kwargs

def get_table_kwargs(self):
return {"exclude": self.excluded_fields}
1 change: 1 addition & 0 deletions hypha/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def global_vars(request):
"SENTRY_DEBUG": settings.SENTRY_DEBUG,
"SENTRY_PUBLIC_KEY": settings.SENTRY_PUBLIC_KEY,
"SUBMISSIONS_TABLE_EXCLUDED_FIELDS": settings.SUBMISSIONS_TABLE_EXCLUDED_FIELDS,
"PROJECTS_TABLE_EXCLUDED_FIELDS": settings.PROJECTS_TABLE_EXCLUDED_FIELDS,
"HIJACK_ENABLE": settings.HIJACK_ENABLE,
"LANGUAGE_SWITCHER": settings.LANGUAGE_SWITCHER,
"SUBMISSION_ANONYMIZATION_ENABLED": settings.SUBMISSION_ANONYMIZATION_ENABLED,
Expand Down
4 changes: 4 additions & 0 deletions hypha/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
"SUBMISSIONS_TABLE_EXCLUDED_FIELDS", ["organization_name"]
)

# Columns/filters to exclude from the project tables.
# Possible values are: project_fund, project_lead, project_status, reporting
PROJECTS_TABLE_EXCLUDED_FIELDS = env.list("PROJECTS_TABLE_EXCLUDED_FIELDS", [])

# No of co-applicants can be added to a submission (default 10)
SUBMISSIONS_COAPPLICANT_INVITES_LIMIT = env.int(
"SUBMISSIONS_COAPPLICANT_INVITES_LIMIT", 10
Expand Down