Skip to content

Commit 673959a

Browse files
committed
Implement PROJECTS_TABLE_EXCLUDED_FIELDS.
1 parent ef4bfde commit 673959a

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

hypha/apply/projects/filters.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ class Meta:
7070
fields = ["project_status", "project_lead", "project_fund"]
7171
model = Project
7272

73+
def __init__(self, *args, exclude=None, **kwargs):
74+
if exclude is None:
75+
exclude = []
76+
77+
super().__init__(*args, **kwargs)
78+
79+
self.filters = {
80+
field: filter
81+
for field, filter in self.filters.items()
82+
if field not in exclude
83+
}
84+
7385
def filter_reporting(self, queryset, name, value):
7486
if value == "1":
7587
return queryset.filter(outstanding_reports__gt=0)

hypha/apply/projects/views/project.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,3 +2282,14 @@ class ProjectListView(SingleTableMixin, FilterView):
22822282
queryset = Project.objects.for_table()
22832283
table_class = ProjectsListTable
22842284
template_name = "application_projects/project_list.html"
2285+
2286+
excluded_fields = settings.PROJECTS_TABLE_EXCLUDED_FIELDS
2287+
2288+
def get_filterset_kwargs(self, filterset_class, **kwargs):
2289+
new_kwargs = super().get_filterset_kwargs(filterset_class)
2290+
new_kwargs["exclude"] = self.excluded_fields
2291+
new_kwargs.update(kwargs)
2292+
return new_kwargs
2293+
2294+
def get_table_kwargs(self):
2295+
return {"exclude": self.excluded_fields}

hypha/core/context_processors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def global_vars(request):
2323
"SENTRY_DEBUG": settings.SENTRY_DEBUG,
2424
"SENTRY_PUBLIC_KEY": settings.SENTRY_PUBLIC_KEY,
2525
"SUBMISSIONS_TABLE_EXCLUDED_FIELDS": settings.SUBMISSIONS_TABLE_EXCLUDED_FIELDS,
26+
"PROJECTS_TABLE_EXCLUDED_FIELDS": settings.PROJECTS_TABLE_EXCLUDED_FIELDS,
2627
"HIJACK_ENABLE": settings.HIJACK_ENABLE,
2728
"LANGUAGE_SWITCHER": settings.LANGUAGE_SWITCHER,
2829
"SUBMISSION_ANONYMIZATION_ENABLED": settings.SUBMISSION_ANONYMIZATION_ENABLED,

hypha/settings/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@
176176
"SUBMISSIONS_TABLE_EXCLUDED_FIELDS", ["organization_name"]
177177
)
178178

179+
# Columns/filters to exclude from the project tables.
180+
# Possible values are: project_fund, project_lead, project_status, reporting
181+
PROJECTS_TABLE_EXCLUDED_FIELDS = env.list("PROJECTS_TABLE_EXCLUDED_FIELDS", [])
182+
179183
# No of co-applicants can be added to a submission (default 10)
180184
SUBMISSIONS_COAPPLICANT_INVITES_LIMIT = env.int(
181185
"SUBMISSIONS_COAPPLICANT_INVITES_LIMIT", 10

0 commit comments

Comments
 (0)