From 5b0c8932c043a308fce1d60483ccd62f63f48e76 Mon Sep 17 00:00:00 2001 From: naath Date: Sun, 6 Apr 2014 18:14:36 +0100 Subject: [PATCH] Added listing by age at birth of child to web --- cgiFiles/ancestors.py | 0 cgiFiles/countNames.py | 0 cgiFiles/everyPage.py | 3 +++ cgiFiles/listPeople.py | 0 cgiFiles/listTerr.py | 0 cgiFiles/person.py | 0 cgiFiles/territory.py | 0 familyTree/askQuestion.py | 22 +++++++++++++++++++--- 8 files changed, 22 insertions(+), 3 deletions(-) mode change 100755 => 100644 cgiFiles/ancestors.py mode change 100755 => 100644 cgiFiles/countNames.py mode change 100755 => 100644 cgiFiles/everyPage.py mode change 100755 => 100644 cgiFiles/listPeople.py mode change 100755 => 100644 cgiFiles/listTerr.py mode change 100755 => 100644 cgiFiles/person.py mode change 100755 => 100644 cgiFiles/territory.py diff --git a/cgiFiles/ancestors.py b/cgiFiles/ancestors.py old mode 100755 new mode 100644 diff --git a/cgiFiles/countNames.py b/cgiFiles/countNames.py old mode 100755 new mode 100644 diff --git a/cgiFiles/everyPage.py b/cgiFiles/everyPage.py old mode 100755 new mode 100644 index 08e2d2e..d202b61 --- a/cgiFiles/everyPage.py +++ b/cgiFiles/everyPage.py @@ -17,6 +17,9 @@ def links(): print ' list of territories' print '
' print ' count how many times first names are use' + print '
' + print ' At what age did people have children' + print '
' def footer(): diff --git a/cgiFiles/listPeople.py b/cgiFiles/listPeople.py old mode 100755 new mode 100644 diff --git a/cgiFiles/listTerr.py b/cgiFiles/listTerr.py old mode 100755 new mode 100644 diff --git a/cgiFiles/person.py b/cgiFiles/person.py old mode 100755 new mode 100644 diff --git a/cgiFiles/territory.py b/cgiFiles/territory.py old mode 100755 new mode 100644 diff --git a/familyTree/askQuestion.py b/familyTree/askQuestion.py index 6e96426..179888c 100755 --- a/familyTree/askQuestion.py +++ b/familyTree/askQuestion.py @@ -63,10 +63,22 @@ def name_html(row,html): if html==1: script = "person.py?ID=" + str(row[1]) name = row[0] - return link_Template.substitute(script = script, text = name) + return link_Template.substitute(script = script\ + , text = name) else: return row[0] + "," +str(row[1]) +def print_age_count(row,newLine): + if newLine == '
': + script = "age.py?age="+str(row[0]) + link = link_Template.substitute(script = \ + script, text = row[0]) + return str(row[1]) + ' people had children at age '\ + + link + newLine + else: + return print_row(row,newLine) + + def print_tagged_name(relationship,row,newLine): if row[0]==None: out = relationship + " not yet entered: " + row[1] @@ -134,6 +146,7 @@ def list_territories(newLine): out =out + terr_html(row[0],newLine) +newLine return out + def list_people(newLine): s = "SELECT name,id,bornyear"\ +" FROM people"\ @@ -268,7 +281,10 @@ def count_age_at_child(newLine): +" WHERE p1.bornYear <> 0 and p2.bornYear<>0"\ +" GROUP BY age;" - out = print_query(s,(),newLine) + out = '' + for row in run_query(s,()): + out = out + print_age_count(row,newLine) + return out def people_had_child_at_age(age,newLine): @@ -279,7 +295,7 @@ def people_had_child_at_age(age,newLine): +" ON parents.ID = p1.ID"\ +" INNER JOIN people p2"\ +" ON parents.parentID = p2.ID"\ - +" WHERE age = ?" + +" WHERE age = ? AND p1.bornYear<>0 AND p2.bornYear<>0" t = (int(age),) -- 2.30.2