From d808be6978aa38b2202443a4ce5b77804053fc5d Mon Sep 17 00:00:00 2001 From: Andrew Marder Date: Mon, 2 May 2011 19:32:36 -0400 Subject: [PATCH] Fixed up some stuff to get the location questions for phase II part II working. --- nga_districts/location_questions.py | 18 +++++++++--------- nga_districts/models.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nga_districts/location_questions.py b/nga_districts/location_questions.py index 24cac6f..c92e4f2 100644 --- a/nga_districts/location_questions.py +++ b/nga_districts/location_questions.py @@ -9,35 +9,35 @@ def select_zone(): result = SelectOneQuestion(label=u"Zone", name=u"zone") - qs = Zone.get_phase2_query_set().order_by("name") + qs = Zone.get_query_set_for_round(3).order_by("name") for zone in qs: - result.add_choice(label=zone.name, value=zone.slug) + result.add_choice(label=zone.name, name=zone.slug) return result def select_state(zone): result = SelectOneQuestion(label=u"State", name=u"state_in_%s" % zone.slug) result.set(Question.BIND, {u"relevant" : u"${zone}='%s'" % zone.slug}) - qs = State.get_phase2_query_set().filter(zone=zone).order_by("name") + qs = State.get_query_set_for_round(3).filter(zone=zone).order_by("name") for state in qs: - result.add_choice(label=state.name, value=state.slug) + result.add_choice(label=state.name, name=state.slug) return result def select_state_questions(): - return [select_state(zone) for zone in Zone.get_phase2_query_set()] + return [select_state(zone) for zone in Zone.get_query_set_for_round(3)] def select_lga(state): result = SelectOneQuestion(label=u"LGA", name=u"lga_in_%s" % state.slug) result.set(Question.BIND, {u"relevant" : u"${state_in_%(zone)s}='%(state)s'" % {u"zone" : state.zone.slug, u"state" : state.slug}}) - qs = LGA.get_phase2_query_set().filter(state=state).order_by("name") + qs = LGA.get_query_set_for_round(3).filter(state=state).order_by("name") for lga in qs: - result.add_choice(label=lga.name, value=lga.slug) + result.add_choice(label=lga.name, name=lga.slug) return result def select_lga_questions(): - return [select_lga(state) for state in State.get_phase2_query_set()] + return [select_lga(state) for state in State.get_query_set_for_round(3)] def select_zone_state_lga(): - survey = Survey() + survey = Survey(name=u"need_xml_tag") survey.set(u"type", u"survey") questions = [select_zone()] + \ select_state_questions() + \ diff --git a/nga_districts/models.py b/nga_districts/models.py index eb06d68..db1f773 100644 --- a/nga_districts/models.py +++ b/nga_districts/models.py @@ -24,7 +24,7 @@ def get_phase2_query_set(cls): @classmethod def get_query_set_for_round(cls, r): - return cls.objects.filter(states__lgas__survey_round=r).distint().order_by("name") + return cls.objects.filter(states__lgas__survey_round=r).distinct().order_by("name") class State(NamedModel): @@ -36,7 +36,7 @@ def get_phase2_query_set(cls): @classmethod def get_query_set_for_round(cls, r): - return cls.objects.filter(lgas__survey_round=r).distint().order_by("name") + return cls.objects.filter(lgas__survey_round=r).distinct().order_by("name") class LGA(NamedModel):