Skip to content

Commit

Permalink
Fixed up some stuff to get the location questions for phase II part I…
Browse files Browse the repository at this point in the history
…I working.
  • Loading branch information
amarder committed May 2, 2011
1 parent 0424c6a commit d808be6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions nga_districts/location_questions.py
Expand Up @@ -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() + \
Expand Down
4 changes: 2 additions & 2 deletions nga_districts/models.py
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit d808be6

Please sign in to comment.