def save_obj(vals):
    # prepare data
    nome = ' '.join([
        get_field(vals, 'S'),
        get_field(vals, 'T').title(),
        get_field(vals, 'U').title()
    ])

    desc = desc_localization(vals)
    desc += desc_atendimento(vals)

    tags = ['Escola', get_field(vals, 'S'), get_field(vals, 'H').title(),
             get_field(vals, 'J').title()]

    contato = desc_contato(vals)
    user = User.objects.get(username='******')
    now = datetime.now()

    # save data
    o = Organization()
    o.name = nome
    o.description = desc
    o.contact = contato
    o.creator = user
    o.creation_date = now
    o.save()

    # save m2m relations
    o.categories.add(category_id)
    for tag in tags:
        o.tags.add(tag)
def save_obj(vals):
    # prepare data
    nome = ' '.join([
        get_field(vals, 'S'),
        get_field(vals, 'T').title(),
        get_field(vals, 'U').title()
    ])

    desc = desc_localization(vals)
    desc += desc_atendimento(vals)

    tags = [
        'Escola',
        get_field(vals, 'S'),
        get_field(vals, 'H').title(),
        get_field(vals, 'J').title()
    ]

    contato = desc_contato(vals)
    user = User.objects.get(username='******')
    now = datetime.now()

    # save data
    o = Organization()
    o.name = nome
    o.description = desc
    o.contact = contato
    o.creator = user
    o.creation_date = now
    o.save()

    # save m2m relations
    o.categories.add(category_id)
    for tag in tags:
        o.tags.add(tag)
def save_obj(vals):
    tipo, name, endereco, contato = vals
    contact = "{}\n{}".format(endereco, contato)

    o = Organization()

    o.name = name.title().replace('Emei', 'EMEI').replace('Emef', 'EMEF'
        ).replace('Ee', 'EE')
    o.contact = contact
    o.description = ''

    o.creator = elaste
    o.creation_date = datetime.now()

    o.save()
    for t in [tipo, 'Jacareí']:
        o.tags.add(t)

    o.community.add(jacarei)
def save_obj(vals):
    tipo, name, endereco, contato = vals
    contact = "{}\n{}".format(endereco, contato)

    o = Organization()

    o.name = name.title().replace('Emei',
                                  'EMEI').replace('Emef',
                                                  'EMEF').replace('Ee', 'EE')
    o.contact = contact
    o.description = ''

    o.creator = elaste
    o.creation_date = datetime.now()

    o.save()
    for t in [tipo, 'Jacareí']:
        o.tags.add(t)

    o.community.add(jacarei)
Exemple #5
0
def save_org(vals):
    e = get_field(vals, 'E').strip()
    d = get_field(vals, 'D').strip()

    if d:
        name = '{} - {}'.format(e, d)
    else:
        name = e

    if not name:
        return

    distrito = get_field(vals, 'M').strip()
    if distrito:
        desc = """
#### Localização

{C} fica {M} {N}, {O} do município {Q}, {R}.
""".format(**format_fields(vals, 'C', 'M', 'N', 'O', 'Q', 'R'))
    else:
        desc = """
#### Localização

{C} fica no bairro {L} do município {Q}, {R}.
""".format(**format_fields(vals, 'C', 'L', 'Q', 'R'))
    desc += """

#### Serviços e Programas

{AM} {AN}

#### Funcionamento

* Horário: {BG}
* Situação: {BJ}

#### Área de abrangência

{BF}

#### Registros e certificações

""".format(**format_fields(vals, 'AM', 'AN', 'BG', 'BJ', 'BF'))

    g = get_field(vals, 'G')
    bm = get_field(vals, 'BM')
    h = get_field(vals, 'H')
    bh = get_field(vals, 'BH')
    z = get_field(vals, 'Z')

    if g:
        desc += """
- Código da Escola (INEP): {G}
""".format(G=g)

    if bm:
        desc += """
- Código Municipal da Escola: {BM}
""".format(BM=bm)

    if h:
        desc += """
- Cadastro Nacional de Estabelecimentos de Saúde (CNES): {H}
""".format(H=h)

    if bh:
        desc += """
- Código do Conselho Tutelar: {BH}
""".format(BH=bh)

    if z:
        desc += """
- CNPJ: {Z}
""".format(Z=z)

    desc += """
#### Órgão superior

- {BO}

#### Pessoas de contato

{W}, {X}

#### Outros contatos

Fax: ({S}) {U}

#### Referências

- [{AE}]({AF} "{AG}"), consultado em {AH}
""".format(**format_fields(vals, 'BO', 'W', 'X', 'S', 'U', 'AE', 'AF', 'AG',
                           'AH'))

    k = get_field(vals, 'K').strip()
    if k:
        k = ', ' + k

    contact = """
Endereço: {I}, {J} {K} | {L}, {P} | {Q}-{R}

Telefone: ({S}) {T}

E-mail: {V}
    """.format(K=k,
               **format_fields(vals, 'I', 'J', 'L', 'P', 'Q', 'R', 'S', 'T',
                               'V'))

    link = get_field(vals, 'Y')

    tags = [
        get_field(vals, f) for f in [
            'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'BN',
            'BO', 'BP', 'BQ'
        ]
    ]
    tags = filter(bool, tags)

    # Público-Alvo
    public = [get_field(vals, f) for f in ['AY', 'AZ', 'BA', 'BB', 'BC', 'BD']]
    public = filter(bool, public)

    now = datetime.now()
    user_id = get_field(vals, 'B').split('/')[-1]
    creator = User.objects.get(pk=user_id)

    categories = [
        get_field(vals, column) for column in ['AA', 'AB', 'AC', 'AD']
    ]
    categories = filter(bool, categories)

    categorias = []
    for cat in categories:
        c = OrganizationCategoryTranslation.objects.filter(name__icontains=cat)
        if c.count():
            categorias.append(c[0].category)

    longitude, latitude = get_field(vals, 'BL'), get_field(vals, 'BK')
    if longitude and latitude:
        x, y = map(float, [
            c.replace(',', '.').replace(' ', '') for c in (longitude, latitude)
        ])
        geom = []
        geom.append('%s,%s' % (x + 0.0005, y + 0.0005))
        geom.append('%s,%s' % (x + 0.0005, y - 0.0005))
        geom.append('%s,%s' % (x - 0.0005, y - 0.0005))
        geom.append('%s,%s' % (x - 0.0005, y + 0.0005))
        geom.append('%s,%s' % (x + 0.0005, y + 0.0005))
        coords = ''
        for i, coord in enumerate(geom):
            coord = coord.split(',')
            coords += '%s %s' % (coord[1], coord[0])
            if not i == len(geom) - 1:
                coords += ', '
        geometry = "GEOMETRYCOLLECTION( POLYGON (( %s )))" % coords
    else:
        geometry = ''

    o = Organization()
    while Organization.objects.filter(name=name).count():
        name += ' '
    o.name = name
    o.description = desc
    o.contact = contact
    o.link = link
    o.creation_date = now
    o.creator = creator
    o.save()
    if geometry:
        OrganizationBranch.objects.create(name='sede',
                                          geometry=geometry,
                                          organization=o)
    for t in tags:
        o.tags.add(t)
    for p in public:
        p, c = TargetAudience.objects.get_or_create(name=p)
        o.target_audiences.add(p)
    for cat in categorias:
        o.categories.add(cat)

    proj_slug = get_field(vals, 'BE').split('/')[-1]
    if proj_slug:
        proj = Project.objects.get(slug=proj_slug)
        ProjectRelatedObject.objects.get_or_create(
            project=proj, content_type=ct_organization, object_id=o.id)

    print 'OK  -  ', name
def save_org(vals):
    name = "{} {}".format(
            get_field(vals, 'D'), get_field(vals, 'E'))

    desc = """
####Localização

{C} fica no distrito {K} da Subprefeitura {L} da capital paulista.

####Horário de Atendimento

{Y}

""".format(
        C=get_field(vals, 'C'),
        K=get_field(vals, 'K'),
        L=get_field(vals, 'L'),
        Y=get_field(vals, 'Y'),
    )

    if get_field(vals, 'G') or get_field(vals, 'S'):
        desc += """
####Registros e Certificações

"""
        if get_field(vals, 'G'):
            desc += """
- Código INEP da Instituição de Ensino: {G}""".format(G=get_field(vals, 'G'))
        if get_field(vals, 'S'):
            desc += """
- Cadastro Nacional de Pessoa Jurídica (CNPJ): {S}""".format(S=get_field(
                                                                vals, 'S'))

    desc += """

####Referência

- [{U}]({V} "{W}"), {X}
    """.format(
        U=get_field(vals, 'U'),
        V=get_field(vals, 'V'),
        W=get_field(vals, 'W'),
        X=get_field(vals, 'X'),
    )

    contact = """
{H}, {I} | {J}
CEP: {M}, São Paulo-SP

Fone: {O} {P}

Email: {Q}
    """.format(
        H=get_field(vals, 'H'),
        I=get_field(vals, 'I'),
        J=get_field(vals, 'J'),
        M=get_field(vals, 'M'),
        O=get_field(vals, 'O'),
        P=get_field(vals, 'P'),
        Q=get_field(vals, 'Q'),
    )

    link = get_field(vals, 'R')

    cat = get_field(vals, 'T')
    if cat == 'Cultura': cat = 'Cultura e Arte'
    categoria = ''
    if cat:
        cat = OrganizationCategoryTranslation.objects.filter(name__icontains=cat)
        if cat.count():
            categoria =cat[0].category


    # Palavras-Chave
    tags = [get_field(vals, f) for f in [ 'Z', 'AA', 'AB', 'AC', 'AD', 'AE'] ]

    # Público-Alvo
    public = [get_field(vals, f) for f in [
        'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP']]

    now = datetime.now()

    o = Organization()
    o.name = name
    o.description = desc
    o.contact = contact
    o.link = link
    o.category = categoria
    o.creation_date = now
    o.creator = mariarita
    o.save()
    for t in tags:
        o.tags.add(t)
    for p in public:
        p, c = TargetAudience.objects.get_or_create(name=p)
        o.target_audiences.add(p)
    print 'OK'
def save_obj(vals):
    imp, transf, comunidade, name, desc, folder, tipo, geom = vals
    geom = eval(geom)
    print 'saving: ', vals

    user = User.objects.get(username='******')
    now = datetime.now()

    # Transform geometry data type
    if transf == 'sim':
        tipo = 'polys'
        x, y, z = map(float, geom[0].split(','))
        geom = []
        geom.append('%s,%s,%s' % (x + 0.0003, y + 0.0003, z))
        geom.append('%s,%s,%s' % (x + 0.0003, y - 0.0003, z))
        geom.append('%s,%s,%s' % (x - 0.0003, y - 0.0003, z))
        geom.append('%s,%s,%s' % (x - 0.0003, y + 0.0003, z))
        geom.append('%s,%s,%s' % (x + 0.0003, y + 0.0003, z))

    # build geomtry info
    if tipo == 'polys':
        coords = ''
        for i, coord in enumerate(geom):
            x, y, z = coord.split(',')
            coords += '%s %s' % (y, x)
            if not i == len(geom) - 1:
                coords += ', '
        geo_ref = 'GEOMETRYCOLLECTION ( POLYGON (( %s )))' % coords
    elif tipo == 'point':
        x, y, z = geom[0].split(',')
        geo_ref = 'GEOMETRYCOLLECTION ( POINT ( %s %s))' % (y, x)

    # save Resource
    if imp == 'R':

        #fix comunidade
        tags = []
        if ',' in comunidade:
            split = [c.strip() for c in comunidade.split(',')]
            comunidade, tags = split[0], split[1:]

        r = Resource()
        r.name = name
        r.description = desc

        # comunity is the firt
        if comunidade:
            c = Community.objects.get(slug=comunidade)
            r.community = c

        r.creator = user
        r.creation_date = now
        r.geometry = geo_ref
        r.save()

        # load remaining comunities as tags
        for tag in tags:
            r.tags.add(tag)

    # save Need
    elif imp == 'N':

        #fix comunidade
        tags = []
        if ',' in comunidade:
            split = [c.strip() for c in comunidade.split(',')]
            comunidade, tags = split[0], split[1:]

        n = Need()
        n.title = name
        n.description = desc

        if comunidade:
            c = Community.objects.get(slug=comunidade)
            n.community = c

        n.creator = user
        n.creation_date = now
        n.geometry = geo_ref
        # n.target_audiences.add(1)
        n.save()

        # load remaining comunities as tags
        for tag in tags:
            n.tags.add(tag)

    # save organization
    elif imp == 'O':
        if name:
            o = Organization()
            o.name = name
            o.description = desc
            o.creation_date = now
            o.creator = user
            o.save()
            for comm in [c.strip() for c in comunidade.split(',')]:
                c = Community.objects.get(slug=comm)
                o.community.add(c)

            b = OrganizationBranch()
            b.name = name + ' - sede'
            b.geometry = geo_ref
            b.organization = o
            b.creator = user
            b.creation_date = now
            b.save()
def save_org(vals):
    name = "{} {}".format(get_field(vals, 'D'), get_field(vals, 'E'))

    desc = """
####Localização

{C} fica no distrito {K} da Subprefeitura {L} da capital paulista.

####Horário de Atendimento

{Y}

""".format(
        C=get_field(vals, 'C'),
        K=get_field(vals, 'K'),
        L=get_field(vals, 'L'),
        Y=get_field(vals, 'Y'),
    )

    if get_field(vals, 'G') or get_field(vals, 'S'):
        desc += """
####Registros e Certificações

"""
        if get_field(vals, 'G'):
            desc += """
- Código INEP da Instituição de Ensino: {G}""".format(G=get_field(vals, 'G'))
        if get_field(vals, 'S'):
            desc += """
- Cadastro Nacional de Pessoa Jurídica (CNPJ): {S}""".format(
                S=get_field(vals, 'S'))

    desc += """

####Referência

- [{U}]({V} "{W}"), {X}
    """.format(
        U=get_field(vals, 'U'),
        V=get_field(vals, 'V'),
        W=get_field(vals, 'W'),
        X=get_field(vals, 'X'),
    )

    contact = """
{H}, {I} | {J}
CEP: {M}, São Paulo-SP

Fone: {O} {P}

Email: {Q}
    """.format(
        H=get_field(vals, 'H'),
        I=get_field(vals, 'I'),
        J=get_field(vals, 'J'),
        M=get_field(vals, 'M'),
        O=get_field(vals, 'O'),
        P=get_field(vals, 'P'),
        Q=get_field(vals, 'Q'),
    )

    link = get_field(vals, 'R')

    cat = get_field(vals, 'T')
    if cat == 'Cultura': cat = 'Cultura e Arte'
    categoria = ''
    if cat:
        cat = OrganizationCategoryTranslation.objects.filter(
            name__icontains=cat)
        if cat.count():
            categoria = cat[0].category

    # Palavras-Chave
    tags = [get_field(vals, f) for f in ['Z', 'AA', 'AB', 'AC', 'AD', 'AE']]

    # Público-Alvo
    public = [
        get_field(vals, f) for f in
        ['AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP']
    ]

    now = datetime.now()

    o = Organization()
    o.name = name
    o.description = desc
    o.contact = contact
    o.link = link
    o.category = categoria
    o.creation_date = now
    o.creator = mariarita
    o.save()
    for t in tags:
        o.tags.add(t)
    for p in public:
        p, c = TargetAudience.objects.get_or_create(name=p)
        o.target_audiences.add(p)
    print 'OK'
def save_org(vals):
    e = get_field(vals, 'E').strip()
    d = get_field(vals, 'D').strip()

    if d:
        name = '{} - {}'.format(e, d)
    else:
        name = e

    if not name:
        return

    distrito = get_field(vals, 'M').strip()
    if distrito:
        desc = """
#### Localização

{C} fica {M} {N}, {O} do município {Q}, {R}.
""".format(**format_fields(vals, 'C', 'M', 'N', 'O', 'Q', 'R'))
    else:
        desc = """
#### Localização

{C} fica no bairro {L} do município {Q}, {R}.
""".format(**format_fields(vals, 'C', 'L', 'Q', 'R'))
    desc += """

#### Serviços e Programas

{AM} {AN}

#### Funcionamento

* Horário: {BG}
* Situação: {BJ}

#### Área de abrangência

{BF}

#### Registros e certificações

""".format(**format_fields(vals, 'AM', 'AN', 'BG', 'BJ', 'BF'))

    g = get_field(vals, 'G')
    bm = get_field(vals, 'BM')
    h = get_field(vals, 'H')
    bh = get_field(vals, 'BH')
    z = get_field(vals, 'Z')

    if g:
        desc += """
- Código da Escola (INEP): {G}
""".format(G=g)

    if bm:
        desc += """
- Código Municipal da Escola: {BM}
""".format(BM=bm)

    if h:
        desc += """
- Cadastro Nacional de Estabelecimentos de Saúde (CNES): {H}
""".format(H=h)

    if bh:
        desc += """
- Código do Conselho Tutelar: {BH}
""".format(BH=bh)

    if z:
        desc += """
- CNPJ: {Z}
""".format(Z=z)

    desc += """
#### Órgão superior

- {BO}

#### Pessoas de contato

{W}, {X}

#### Outros contatos

Fax: ({S}) {U}

#### Referências

- [{AE}]({AF} "{AG}"), consultado em {AH}
""".format(**format_fields(vals, 'BO', 'W', 'X', 'S', 'U', 'AE', 'AF', 'AG',
           'AH'))

    k = get_field(vals, 'K').strip()
    if k:
        k = ', ' + k

    contact = """
Endereço: {I}, {J} {K} | {L}, {P} | {Q}-{R}

Telefone: ({S}) {T}

E-mail: {V}
    """.format(K=k, **format_fields(vals, 'I', 'J', 'L', 'P', 'Q', 'R', 'S',
                'T', 'V'))

    link = get_field(vals, 'Y')

    tags = [get_field(vals, f) for f in
               ['AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX',
                'BN', 'BO', 'BP', 'BQ']]
    tags = filter(bool, tags)

    # Público-Alvo
    public = [get_field(vals, f) for f in ['AY', 'AZ', 'BA', 'BB', 'BC', 'BD']]
    public = filter(bool, public)

    now = datetime.now()
    user_id = get_field(vals, 'B').split('/')[-1]
    creator = User.objects.get(pk=user_id)

    categories = [get_field(vals, column) for column in
                        ['AA', 'AB', 'AC', 'AD']]
    categories = filter(bool, categories)

    categorias = []
    for cat in categories:
        c = OrganizationCategoryTranslation.objects.filter(name__icontains=cat)
        if c.count():
            categorias.append(c[0].category)

    longitude, latitude = get_field(vals, 'BL'), get_field(vals, 'BK')
    if longitude and latitude:
        x, y = map(float, [c.replace(',', '.').replace(' ', '')
                    for c in (longitude, latitude)])
        geom = []
        geom.append('%s,%s' % (x + 0.0005, y + 0.0005))
        geom.append('%s,%s' % (x + 0.0005, y - 0.0005))
        geom.append('%s,%s' % (x - 0.0005, y - 0.0005))
        geom.append('%s,%s' % (x - 0.0005, y + 0.0005))
        geom.append('%s,%s' % (x + 0.0005, y + 0.0005))
        coords = ''
        for i, coord in enumerate(geom):
            coord = coord.split(',')
            coords += '%s %s' % (coord[1], coord[0])
            if not i == len(geom) - 1:
                coords += ', '
        geometry = "GEOMETRYCOLLECTION( POLYGON (( %s )))" % coords
    else:
        geometry = ''

    o = Organization()
    while Organization.objects.filter(name=name).count():
        name += ' '
    o.name = name
    o.description = desc
    o.contact = contact
    o.link = link
    o.creation_date = now
    o.creator = creator
    o.save()
    if geometry:
        OrganizationBranch.objects.create(name='sede', geometry=geometry,
                organization=o)
    for t in tags:
        o.tags.add(t)
    for p in public:
        p, c = TargetAudience.objects.get_or_create(name=p)
        o.target_audiences.add(p)
    for cat in categorias:
        o.categories.add(cat)

    proj_slug = get_field(vals, 'BE').split('/')[-1]
    if proj_slug:
        proj = Project.objects.get(slug=proj_slug)
        ProjectRelatedObject.objects.get_or_create(project=proj,
                content_type=ct_organization, object_id=o.id)

    print 'OK  -  ', name
def save_org(vals):
    if not get_field(vals, 'A') and not get_field(vals, 'B'):
        return

    name = "{} - {}".format(get_field(vals, 'B').title(), get_field(vals, 'A'))
    name = name.strip()

    desc = """
####Atuação

####Localização

A {B} fica localizada em {AJ}, {AW}.


####Estrutura e Dirigentes

- {AZ}


####Registro e Certificações

**CNPJ:** {AX}


####Comunicação

- **Facebook:** [{BD}] ({BE} "{B} no Facebook")
- **Blogue:** [{B}] ({BF} "Blogue da {B}")


####Participações e Representações

""".format(
        **format_fields(vals, 'B', 'AJ', 'AW', 'AZ', 'AX', 'BD', 'BE', 'BF'))

    if get_field(vals, 'P'):
        desc += """
- [{P}] (http://maps.mootiro.org/organization/comite-nacional-de-enfrentamento-a-violencia-sexual-contra-criancas-e-adolescentes "Comitê Nacional no Mootiro Maps"): {BA}, {BB}
""".format(**format_fields(vals, 'P', 'BA', 'BB'))

    if get_field(vals, 'K'):
        desc += """
- [{K}] (http://maps.mootiro.org/organization/rede-andi-brasil "Rede ANDI Brasil no MootiroMaps")
""".format(**format_fields(vals, 'K'))

    if get_field(vals, 'L'):
        desc += """
- [{L}] (http://maps.mootiro.org/organization/rnpi-rede-nacional-primeira-infancia "Rede Nacional Primeira Infância no MootiroMaps")
""".format(**format_fields(vals, 'L'))

    desc += """

#### Referências

- [{BM}] ({BL} "Arquivo no GoogleDocs"), {BN}
- [Site institucional da {B}] ({Y} "")

    """.format(**format_fields(vals, 'BM', 'BN', 'BL', 'B', 'Y'))

    link = get_field(vals, 'Y')

    contact = """
{AE}, {AF}, {AG}
{AH}, CEP: {AI}
{AJ} - {AK}

**Fone:** ({AB}) {AC} - {AA}

**E-mail:** {Z}

    """.format(**format_fields(vals, 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK',
                               'AB', 'AC', 'AA', 'Z'))

    cat = "Promoção de direitos humanos"
    cat = OrganizationCategoryTranslation.objects.filter(name__icontains=cat)
    if cat.count():
        categoria = cat[0].category

    tags = [
        get_field(vals, f) for f in ['AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW']
    ]

    # Público-Alvo
    public = [get_field(vals, f) for f in ['AM', 'AN', 'AO', 'AP']]

    now = datetime.now()

    o = Organization()
    o.name = name
    o.description = desc
    o.contact = contact
    o.link = link
    o.category = categoria
    o.creation_date = now
    o.creator = users[get_field(vals, 'C')]
    o.save()
    for t in tags:
        o.tags.add(t)
    for p in public:
        p, c = TargetAudience.objects.get_or_create(name=p)
        o.target_audiences.add(p)

    ProjectRelatedObject.objects.create(project=projeto, content_object=o)
    print 'OK  -  ', name
def save_org(vals):
    if not get_field(vals, 'A') and not get_field(vals, 'B'):
        return

    name = "{} - {}".format(
            get_field(vals, 'B').title(), get_field(vals, 'A'))
    name = name.strip()

    desc = """
####Atuação

####Localização

A {B} fica localizada em {AJ}, {AW}.


####Estrutura e Dirigentes

- {AZ}


####Registro e Certificações

**CNPJ:** {AX}


####Comunicação

- **Facebook:** [{BD}] ({BE} "{B} no Facebook")
- **Blogue:** [{B}] ({BF} "Blogue da {B}")


####Participações e Representações

""".format(**format_fields(vals, 'B', 'AJ', 'AW', 'AZ', 'AX', 'BD', 'BE', 'BF'))

    if get_field(vals, 'P'):
        desc += """
- [{P}] (http://maps.mootiro.org/organization/comite-nacional-de-enfrentamento-a-violencia-sexual-contra-criancas-e-adolescentes "Comitê Nacional no Mootiro Maps"): {BA}, {BB}
""".format(**format_fields(vals, 'P', 'BA', 'BB'))

    if get_field(vals, 'K'):
        desc += """
- [{K}] (http://maps.mootiro.org/organization/rede-andi-brasil "Rede ANDI Brasil no MootiroMaps")
""".format(**format_fields(vals, 'K'))

    if get_field(vals, 'L'):
        desc += """
- [{L}] (http://maps.mootiro.org/organization/rnpi-rede-nacional-primeira-infancia "Rede Nacional Primeira Infância no MootiroMaps")
""".format(**format_fields(vals, 'L'))

    desc += """

#### Referências

- [{BM}] ({BL} "Arquivo no GoogleDocs"), {BN}
- [Site institucional da {B}] ({Y} "")

    """.format(**format_fields(vals, 'BM', 'BN', 'BL', 'B', 'Y'))

    link = get_field(vals, 'Y')

    contact = """
{AE}, {AF}, {AG}
{AH}, CEP: {AI}
{AJ} - {AK}

**Fone:** ({AB}) {AC} - {AA}

**E-mail:** {Z}

    """.format(**format_fields(vals, 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK',
                             'AB', 'AC', 'AA', 'Z'))

    cat = "Promoção de direitos humanos"
    cat = OrganizationCategoryTranslation.objects.filter(name__icontains=cat)
    if cat.count():
        categoria = cat[0].category

    tags = [get_field(vals, f) for f in
            ['AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW']]

    # Público-Alvo
    public = [get_field(vals, f) for f in ['AM', 'AN', 'AO', 'AP']]

    now = datetime.now()

    o = Organization()
    o.name = name
    o.description = desc
    o.contact = contact
    o.link = link
    o.category = categoria
    o.creation_date = now
    o.creator = users[get_field(vals, 'C')]
    o.save()
    for t in tags:
        o.tags.add(t)
    for p in public:
        p, c = TargetAudience.objects.get_or_create(name=p)
        o.target_audiences.add(p)

    ProjectRelatedObject.objects.create(project=projeto, content_object=o)
    print 'OK  -  ', name