Ejemplo n.º 1
0
def index_import(request):
    
    params = {}

    res = add.delay(1, 2)
    #print(res.get())
    
    if request.POST:
        
        content = request.POST.get('content', '')
        content = content + '\n'
        
        import tempfile
        filepath = tempfile.mktemp()
        with open(filepath, 'wb') as f:
            f.write(content.encode('utf8'))
            f.close()
        g = gedcom.Gedcom(filepath)
        
        individual_list = g.individual_list()
        family_list = g.family_list()
        
        familyTree = FamilyTree()
        familyTree.date = datetime.now()
        familyTree.name = 'random'
        familyTree.slug = 'random-' + str(len(FamilyTree.objects.all()) + 1)
        familyTree.save()
        
        for indv in individual_list:
            id = indv.xref()
            given_name = indv.given_name()
            surname = indv.surname()
            sex = indv.sex()
            
            p = Person()
            p.tree = familyTree
            p.handle = id
            p.first_name = given_name
            p.last_name = surname
            p.save()
            
        for fam in family_list:
            id = fam.xref()
        
            husband = None
            wife = None
            if fam.husband():
                husband = Person.objects.get(tree=familyTree, handle=fam.husband().xref())
            if fam.wife():
                wife = Person.objects.get(tree=familyTree, handle=fam.wife().xref())
        
            f = Family()
            f.tree = familyTree
            f.handle = id
            f.father = husband
            f.mother = wife
            f.save()
        
    
    return render_to_response(request, 'trees/import.html', params)
Ejemplo n.º 2
0
def person_view(request, tree_slug, pid):
    params = {
        'tree_slug': tree_slug,
        'person': Person.objects.get(pk=pid)
        
    }
    
    return render_to_response(request, 'web/person_view.html', params)
Ejemplo n.º 3
0
def person_view(request, tree_slug, pid):
    params = {
        'tree_slug': tree_slug,
        'person': Person.objects.get(pk=pid)
        
    }
    
    return render_to_response(request, 'web/person_view.html', params)
Ejemplo n.º 4
0
def branch_list(request, tree_slug):
    
    # hehe
    
    _persons = Person.objects.all()
    _families = Family.objects.all()
    persons = {}
    families = {}
    for person in _persons:
        persons[person.__dict__['id']] = person.__dict__
        persons[person.__dict__['id']]['families'] = person.families.all()
        
    for family in _families:
        families[family.__dict__['id']] = family.__dict__
    color = 1
    
    print ('digraph G { nodesep=0.6; edge [arrowsize=0.3];')
    for person_id in persons.keys():
       if 'color' not in persons[person_id]:
           color = color + 1
           __branch_dfs(person_id, color, persons, families)
    print ('}')
    
    """
    print '---'
    for person in persons.keys():
        if 'color' in persons[person]:
            print 'kolor %s | %s %s' % (persons[person]['color'], persons[person]['first_name'],persons[person]['last_name'])
        else:
            print 'no color | %s %s' %(persons[person]['first_name'],persons[person]['last_name'])
    print '==='
    """
    
    # old
    params = {'tree_slug': tree_slug}
    persons = Person.objects.all().filter(parent_family=None).filter(last_name='Koperkiewicz')
    params['persons'] = persons
    params['action'] = 'branch_list'
    return render_to_response(request, 'web/branch-list.html', params)
Ejemplo n.º 5
0
def branch_list(request, tree_slug):
    
    # hehe
    
    _persons = Person.objects.all()
    _families = Family.objects.all()
    persons = {}
    families = {}
    for person in _persons:
        persons[person.__dict__['id']] = person.__dict__
        persons[person.__dict__['id']]['families'] = person.families.all()
        
    for family in _families:
        families[family.__dict__['id']] = family.__dict__
    color = 1
    
    print 'digraph G { nodesep=0.6; edge [arrowsize=0.3];'
    for person_id in persons.keys():
       if 'color' not in persons[person_id]:
           color = color + 1
           __branch_dfs(person_id, color, persons, families)
    print '}'
    
    """
    print '---'
    for person in persons.keys():
        if 'color' in persons[person]:
            print 'kolor %s | %s %s' % (persons[person]['color'], persons[person]['first_name'],persons[person]['last_name'])
        else:
            print 'no color | %s %s' %(persons[person]['first_name'],persons[person]['last_name'])
    print '==='
    """
    
    # old
    params = {'tree_slug': tree_slug}
    persons = Person.objects.all().filter(parent_family=None).filter(last_name='Koperkiewicz')
    params['persons'] = persons
    params['action'] = 'branch_list'
    return render_to_response(request, 'web/branch-list.html', params)
Ejemplo n.º 6
0
def index(request):
    params = {}
    
    params['trees'] = FamilyTree.objects.all()
    
    return render_to_response(request, 'trees/index.html', params)
Ejemplo n.º 7
0
def home(request, tree_slug):
    params = {
        'tree_slug': tree_slug,
    }
    return render_to_response(request, 'web/index.html', params)
Ejemplo n.º 8
0
def family_list(request, tree_slug):
    params = {'tree_slug': tree_slug}
    params['family_array'] = Family.objects.all()
    return render_to_response(request, 'web/family-list.html', params)
Ejemplo n.º 9
0
def person_list(request, tree_slug):
    params = {'tree_slug': tree_slug}
    params['person_array'] = Person.objects.all().order_by('last_name', 'first_name')
    return render_to_response(request, 'web/person-list.html', params)
Ejemplo n.º 10
0
def manager(request, tree_slug):
    params = {'tree_slug': tree_slug}
    return render_to_response(request, 'web/manager.phtml', params)
Ejemplo n.º 11
0
def test(request, tree_slug):
    params = {'tree_slug': tree_slug}
    return render_to_response(request, 'web/test.phtml', params)
Ejemplo n.º 12
0
def home(request, tree_slug):
    params = {
        'tree_slug': tree_slug,
    }
    return render_to_response(request, 'web/index.html', params)
Ejemplo n.º 13
0
def family_list(request, tree_slug):
    params = {'tree_slug': tree_slug}
    params['family_array'] = Family.objects.all()
    return render_to_response(request, 'web/family-list.html', params)
Ejemplo n.º 14
0
def person_list(request, tree_slug):
    params = {'tree_slug': tree_slug}
    params['person_array'] = Person.objects.all().order_by('last_name', 'first_name')
    return render_to_response(request, 'web/person-list.html', params)
Ejemplo n.º 15
0
def manager(request, tree_slug):
    params = {'tree_slug': tree_slug}
    return render_to_response(request, 'web/manager.phtml', params)
Ejemplo n.º 16
0
def test(request, tree_slug):
    params = {'tree_slug': tree_slug}
    return render_to_response(request, 'web/test.phtml', params)