AC-430. Add project status and last_updated as database fields for filtering/sorting.

This commit is contained in:
Chris Church
2013-09-10 02:06:17 -04:00
parent 27948a8dd9
commit eff8a6426a
4 changed files with 416 additions and 34 deletions

View File

@@ -245,6 +245,15 @@ class ProjectList(ListCreateAPIView):
model = Project
serializer_class = ProjectSerializer
def get(self, request, *args, **kwargs):
# Not optimal, but make sure the project status and last_updated fields
# are up to date here...
projects_qs = Project.objects.filter(active=True)
projects_qs = projects_qs.select_related('current_update', 'last_updated')
for project in projects_qs:
project.set_status_and_last_updated()
return super(ProjectList, self).get(request, *args, **kwargs)
class ProjectDetail(RetrieveUpdateDestroyAPIView):
model = Project