Displayed only permanent and max 2 years old finance resolutions
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from django import forms
|
||||
from django.core.validators import ValidationError
|
||||
from django.db.models import Count, Q
|
||||
@@ -406,6 +409,15 @@ class BillAdminForm(forms.ModelForm):
|
||||
self.fields["bill_creator"].widget.can_change_related = False
|
||||
self.fields["bill_creator"].widget.can_delete_related = False
|
||||
|
||||
# Displayed only permanent and max 2 years old finance resolutions.
|
||||
self.fields["resolution"].queryset = self.fields["resolution"].queryset.filter(
|
||||
(
|
||||
Q(option=Resolution.Option.FINANCE)
|
||||
& Q(date__gt=datetime.now().date() - relativedelta(years=2))
|
||||
)
|
||||
| Q(option=Resolution.Option.PERMANENT)
|
||||
)
|
||||
|
||||
# Delete wiref id from list if there are already 10 bills in wiref form.
|
||||
qs = (
|
||||
self.fields["wiref"].queryset.annotate(num_bills=Count("bill")).filter(num_bills__lt=10)
|
||||
|
||||
Reference in New Issue
Block a user