Permalink
Browse files

Simplify the filtering done on the forecast

  • Loading branch information...
1 parent d82b5f6 commit 3a5aef9f030146444b2835ec21125768b504f2d6 @tuxella tuxella committed Jan 9, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 staffing/forms.py
View
@@ -25,13 +25,13 @@ def get_queryset(self):
if not hasattr(self, '_queryset'):
qs = super(ConsultantStaffingInlineFormset, self).get_queryset()
if date.today().day > 5:
- qs = qs.filter(mission__active=True, # Remove archived mission
- staffing_date__gte=date.today().replace(day=1)) # Remove past missions
+ lowerDayBound = date.today().replace(day=1)
else:
- lastDayOfPreviousMonth = date.today().replace(day=1).toordinal() - 1
- firstDayOfPreviousMonth = date.fromordinal(lastDayOfPreviousMonth).replace(day=1)
- qs = qs.filter(mission__active=True, # Remove archived mission
- staffing_date__gte=firstDayOfPreviousMonth) # Remove past missions
+ lastDayOfPreviousMonth = date.today().replace(day=1) + timedelta(-1)
+ lowerDayBound = lastDayOfPreviousMonth.replace(day=1)
+
+ qs = qs.filter(mission__active=True, # Remove archived mission
+ staffing_date__gte=lowerDayBound) # Remove past missions
self._queryset = qs
return self._queryset

0 comments on commit 3a5aef9

Please sign in to comment.