|
16 | 16 |
|
17 | 17 | from hypha.apply.categories.blocks import CategoryQuestionBlock |
18 | 18 | from hypha.apply.categories.models import MetaTerm, Option |
| 19 | +from hypha.apply.funds.models.submissions import ApplicationSubmissionSkeleton |
19 | 20 | from hypha.apply.funds.reviewers.services import get_all_reviewers |
20 | 21 | from hypha.apply.review.models import Review |
21 | 22 | from hypha.core.tables import RelativeTimeColumn |
@@ -192,24 +193,33 @@ def render_screening_status(self, value): |
192 | 193 |
|
193 | 194 |
|
194 | 195 | def get_used_rounds(request): |
195 | | - return Round.objects.filter(submissions__isnull=False).distinct() |
| 196 | + return Round.objects.filter( |
| 197 | + Q(Q(submissions__isnull=False) | Q(skeleton_submissions__isnull=False)) |
| 198 | + ).distinct() |
196 | 199 |
|
197 | 200 |
|
198 | 201 | def get_used_funds(request): |
199 | 202 | # Use page to pick up on both Labs and Funds |
200 | | - return Page.objects.filter(applicationsubmission__isnull=False).distinct() |
| 203 | + return Page.objects.filter( |
| 204 | + Q( |
| 205 | + Q(applicationsubmission__isnull=False) |
| 206 | + | Q(applicationsubmissionskeleton__isnull=False) |
| 207 | + ) |
| 208 | + ).distinct() |
201 | 209 |
|
202 | 210 |
|
203 | 211 | def get_round_leads(request): |
204 | 212 | return User.objects.filter(submission_lead__isnull=False).distinct() |
205 | 213 |
|
206 | 214 |
|
207 | 215 | def get_screening_statuses(request): |
208 | | - return ScreeningStatus.objects.filter( |
| 216 | + sub_filter = Q( |
209 | 217 | id__in=ApplicationSubmission.objects.all() |
210 | 218 | .values("screening_statuses__id") |
211 | 219 | .distinct("screening_statuses__id") |
212 | 220 | ) |
| 221 | + skele_filter = Q(skeleton_submissions__isnull=False) |
| 222 | + return ScreeningStatus.objects.filter(sub_filter | skele_filter) |
213 | 223 |
|
214 | 224 |
|
215 | 225 | def get_meta_terms(request): |
@@ -355,6 +365,37 @@ def filter_archived(self, queryset, name, value): |
355 | 365 | return queryset |
356 | 366 |
|
357 | 367 |
|
| 368 | +class SubmissionSkeletonFilter(filters.FilterSet): |
| 369 | + fund = ModelMultipleChoiceFilter( |
| 370 | + field_name="page", queryset=get_used_funds, label=_("Funds") |
| 371 | + ) |
| 372 | + round = ModelMultipleChoiceFilter(queryset=get_used_rounds, label=_("Rounds")) |
| 373 | + screening_statuses = ModelMultipleChoiceFilter( |
| 374 | + queryset=get_screening_statuses, label=_("Screening"), null_label=_("No Status") |
| 375 | + ) |
| 376 | + |
| 377 | + class Meta: |
| 378 | + model = ApplicationSubmissionSkeleton |
| 379 | + fields = ("fund", "round") |
| 380 | + |
| 381 | + def __init__(self, *args, exclude=None, limit_statuses=None, **kwargs): |
| 382 | + if exclude is None: |
| 383 | + exclude = [] |
| 384 | + |
| 385 | + super().__init__(*args, **kwargs) |
| 386 | + |
| 387 | + self.filters["status"] = StatusMultipleChoiceFilter(limit_to=limit_statuses) |
| 388 | + # self.filters["category_options"].extra["choices"] = [ |
| 389 | + # (option.id, option.value) |
| 390 | + # for option in Option.objects.filter(category__filter_on_dashboard=True) |
| 391 | + # ] |
| 392 | + self.filters = { |
| 393 | + field: filter |
| 394 | + for field, filter in self.filters.items() |
| 395 | + if field not in exclude |
| 396 | + } |
| 397 | + |
| 398 | + |
358 | 399 | class SubmissionDashboardFilter(filters.FilterSet): |
359 | 400 | round = ModelMultipleChoiceFilter(queryset=get_used_rounds, label=_("Rounds")) |
360 | 401 | fund = ModelMultipleChoiceFilter( |
|
0 commit comments