Skip to content

Commit

Permalink
fix(experience): pick valid SEP rating (still wonky...)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyv committed Apr 17, 2024
1 parent 118ce49 commit 5f12a66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion logbook/views/experience.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
)
from .utils import (
AuthenticatedTemplateView,
get_current_sep_rating,
)


Expand All @@ -38,7 +39,7 @@ def get_sep_revalidation_experience(log_entries: QuerySet[LogEntry]) -> Experien
aircraft__type__in={AircraftType.SEP, AircraftType.TMG},
departure_time__gte=make_aware(
datetime.combine(
Certificate.objects.get(name__contains="SEP").valid_until - relativedelta(months=12),
get_current_sep_rating().valid_until - relativedelta(months=12),
time.min,
),
UTC,
Expand Down
5 changes: 5 additions & 0 deletions logbook/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
EXPIRY_WARNING_THRESHOLD = relativedelta(months=3)


def get_current_sep_rating() -> Certificate:
(current_sep_rating,) = filter(lambda item: item.valid, Certificate.objects.filter(name__contains="SEP"))
return current_sep_rating


def check_certificates_expiry(request):
today = datetime.now(tz=UTC).date()
for certificate in Certificate.objects.filter(
Expand Down

0 comments on commit 5f12a66

Please sign in to comment.