Skip to content

Commit

Permalink
Fix in previous_years_survey function, now using sigel or matching li…
Browse files Browse the repository at this point in the history
…brary name exactly (ignoring case)
  • Loading branch information
katste committed Feb 29, 2016
1 parent a8775bc commit 5de42b6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions libstat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,12 @@ class Survey(SurveyBase):

def previous_years_survey(self):
previous_year = self.sample_year - 1
if previous_year <= 2013:
previous_surveys = Survey.objects.filter(_status=u"published", sample_year=previous_year,
library__name__icontains=self.library.name)
else:
previous_surveys = Survey.objects.filter(_status=u"published", sample_year=previous_year,
library__sigel=self.library.sigel)
if len(previous_surveys) == 0:
return None
return previous_surveys[0]
previous_survey = Survey.objects.filter(_status=u"published", sample_year=previous_year,
library__sigel=self.library.sigel).first()
if not previous_survey:
previous_survey = Survey.objects.filter(_status=u"published", sample_year=previous_year,
library__name__iexact=self.library.name).first()
return previous_survey

def previous_years_value(self, variable, previous_years_survey=None):
# allow passing previous survey to reduce db lookups
Expand Down

0 comments on commit 5de42b6

Please sign in to comment.