def caso_organizacion():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('default','index'))

    organizacion=db.Organizacion(_id)
    if organizacion:
        if organizacion.tipoOrg==2:
            redirect(URL('empresas','conexiones',args=convert_latin_chars(organizacion.alias)))
        else:
            redirect(URL('organizaciones','conexiones',args=convert_latin_chars(organizacion.alias)))
    else:
        redirect(URL('error','error404'))

    db.Organizacion.id.readable=False
    db.Organizacion.haslogo.readable=False
    db.Organizacion.depiction.readable=False
    db.Organizacion.documentSource.readable=False
    db.Organizacion.shortBio.readable=False
    db.Organizacion.longBio.readable=False
    db.Organizacion.documentCloud.readable=False

    for fields in db.Organizacion:
        if (organizacion[fields]==None) | (organizacion[fields]=='') | (organizacion[fields]==False) | (organizacion[fields]==[])\
           | (organizacion[fields]=='NULL'):
            fields.readable=False
        fields.writable=False
    form=SQLFORM(db.Organizacion,organizacion)
    form['_class']='form-horizontal'
    submit = form.element('input',_type='submit')
    submit['_style'] = 'display:none;'

    borrar=auth.has_membership('administrator')

    return dict(Organizacion=organizacion, _id=_id, form=form, borrar=borrar, url=url )
Пример #2
0
def relation_documentos():
    if request.cid == None:
        redirect(URL("error", "error404"))
    from conversion import convert_latin_chars

    _id = request.args(0)
    target = request.vars["target"] or redirect(URL("error", "error404", extension=False))
    page = 0
    sort = "false"
    letter = " "
    if len(request.args) > 1:
        page = int(request.args[1])
    if len(request.args) > 2:
        sort = request.args(2)
    if len(request.args) > 3:
        letter = request.args(3)

    documentCloud = ""
    lista = []

    if target == "persona":
        documentList = db((db.persona.id == _id) & (db.persona.is_active == True)).select(cache=(cache.ram, 10)).first()
        if documentList == None:
            redirect(URL("error", "error404"))
        controller = "personas"
        alias = convert_latin_chars(documentList.alias)
    elif target == "organizacion":
        documentList = (
            db((db.Organizacion.id == _id) & (db.Organizacion.is_active == True)).select(cache=(cache.ram, 10)).first()
        )
        if documentList == None:
            redirect(URL("error", "error404"))
        controller = "organizaciones"
        alias = convert_latin_chars(documentList.alias)
        if documentList.tipoOrg == 2:
            controller = "empresas"

    if documentList != None:
        if documentList.documentCloud != None:
            for relation in documentList.documentCloud:
                lista.append(relation)

    if lista != []:
        doctmp = set(lista)
        documentCloud = db((db.documentCloud.id.belongs(doctmp)) & (db.documentCloud.is_active == True)).select(
            cache=(cache.ram, 3600)
        )
        # documentCloud = db((db.documentCloud.is_active==True)).select(cache=(cache.ram,3600))

    return dict(
        documentCloud=documentCloud,
        sort=sort,
        page=page,
        letter=letter,
        _id=_id,
        target=target,
        alias=alias,
        controller=controller,
    )
Пример #3
0
def documentos():
    from gluon.storage import Storage
    from conversion import convert_latin_chars

    response.view = 'default/documentos.html'

    alias = request.args(0) or redirect(URL('default', 'index'))
    alias = alias.decode('utf-8').replace('_', ' ')

    dc_title = request.args(1) or redirect(URL('default', 'index'))
    dc_title = dc_title.decode('utf-8').replace('_', ' ').replace('-', '.')

    imagen = IMG(_alt=alias,
                 _src=URL('static', 'img/default-pic-profile-person.png'))
    href = ''

    person = db.persona(alias=alias, is_active=True)
    if person:
        controller = 'personas'
        href = 'conexiones'
        imagen = IMG(_alt=person.alias,
                     _src=URL('static', 'img/default-pic-profile-person.png'),
                     _height=44)
        _id = person.id
        if person.depiction != None:
            imagen = IMG(_alt=person.alias,
                         _src=URL('default',
                                  'fast_download',
                                  args=person.depiction),
                         _height=44)
        args = convert_latin_chars(person.alias)
    else:
        redirect(URL('error', 'error404'))

    dc_document = db.documentCloud(title=dc_title, is_active=True)
    if dc_document:
        title = dc_document.title
        dc_args_title = convert_latin_chars(title)
        dc_id = dc_document.dc_id
    else:
        redirect(URL('error', 'error404'))

    response.title = person.alias + '|' + title + ' Poderopedia'
    entity = Storage({
        'id': _id,
        'alias': alias,
        'logo': imagen,
        'controller': controller,
        'target': href,
        'args': args,
        'dc_args': dc_args_title
    })

    return dict(dc_id=dc_id,
                _id=_id,
                page=0,
                sort='false',
                entity=entity,
                title=title)
Пример #4
0
def documentos():
    from gluon.storage import Storage
    from conversion import convert_latin_chars

    url = request.env.http_host + request.env.request_uri
    response.view = 'default/documentos.html'

    alias = request.args(0) or redirect(URL('default', 'index'))
    alias = alias.decode('utf-8').replace('_', ' ').replace('-', '.')

    dc_title = request.args(1) or redirect(URL('default', 'index'))
    dc_title = dc_title.decode('utf-8').replace('_', ' ').replace('-', '.')

    imagen = IMG(_alt=alias,
                 _src=URL('static', 'icono-empresas.png'),
                 _height=44)
    href = ''

    org = db.Organizacion(alias=alias, tipoOrg=2)
    if org:
        controller = 'empresas'
        href = 'conexiones'
        _id = org.id
        if org.haslogo != None:
            imagen = IMG(_alt=org.alias,
                         _src=URL('default', 'fast_download',
                                  args=org.haslogo),
                         _height=44)
        args = convert_latin_chars(org.alias)
    else:
        redirect(URL('error', 'error404'))

    dc_document = db.documentCloud(title=dc_title, is_active=True)
    if dc_document:
        title = dc_document.title
        dc_args_title = convert_latin_chars(title)
        dc_id = dc_document.dc_id
    else:
        redirect(URL('error', 'error404'))

    entity = Storage({
        'id': _id,
        'alias': alias,
        'logo': imagen,
        'controller': controller,
        'target': href,
        'args': args,
        'dc_args': dc_args_title
    })

    response.title = org.alias + ' | ' + title + ' | Poderopedia'

    return dict(dc_id=dc_id,
                _id=_id,
                page=0,
                sort='false',
                entity=entity,
                title=title,
                url=url)
Пример #5
0
def mas_popular_rss():
    from conversion import convert_latin_chars


    entradas=[]
    resultados=dict(
        title="Más Popular Hoy | Poderopedia",
        link="http://www.poderopedia.org",
        description="Poderopedia | Más Popular",
        created_on=str(request.now)
    )
    query=(db.plugin_stats.month==int(request.now.strftime('%m')))& (db.plugin_stats.year==request.now.strftime('%Y'))
    sum = db.plugin_stats.hits.sum()
    popular=db(db.plugin_stats.page_key.like('%conexiones%') & query).select(db.plugin_stats.hits,db.plugin_stats.page_key,sum,
                             orderby=~sum,limitby=(0,2),groupby=db.plugin_stats.page_key,cache=(cache.ram,3600))

    for most in popular:
        page=most.plugin_stats.page_key.split('/')
        page_key=most.plugin_stats.page_key
        largo=len(page)
        if 'personas' in page_key:
            if page[largo-1]:
                alias= page[largo-1].decode('utf-8').replace('_',' ')
                entity=db.persona(alias=alias, is_active=True)
                if entity!=None:
                    imagen=URL('static','tmp/imagen-face.gif')
                    if (entity.depiction!=None) & (entity.depiction!=''):
                        imagen=URL('default','fast_download',args=entity.depiction)

                    args=convert_latin_chars(entity.alias)
                    alias=entity.alias
                controller='personas';
        elif ('organizaciones' in page_key) | ('empresas' in page_key):
            alias= page[largo-1].decode('utf-8').replace('_',' ').replace('-','.')
            entity=db.Organizacion(alias=alias,is_active=True)
            if entity!=None:
                imagen=URL('static','tmp/avatar-organizacion45.gif')

                controller='organizaciones'
                alias=entity.alias
                if entity.tipoOrg==2:
                    controller='empresas'
                    imagen=URL('static','tmp/avatar-empresa.png')
                if (entity.haslogo!=None) & (entity.haslogo!=''):
                    imagen=URL('default','fast_download',args=entity.haslogo)

                args=convert_latin_chars(entity.alias)

        media=dict(url='http://'+request.env.http_host + imagen,medium='image',width='140')
        results=dict(title=alias,link=URL(controller,'conexiones',args=args, extension=False),
                     description=entity.shortBio[:184], created_on=entity.modified_on)
        results['media:content']=media
        entradas.append(results)
    resultados['entries']=entradas
    response.headers['Content-Type']='application/rss+xml'

    return dict(resultados=resultados,title='Más Popular Ahora',desc='Lo más popular en Poderopedia')
Пример #6
0
def mas_popular_rss():
    from conversion import convert_latin_chars


    entradas=[]
    resultados=dict(
        title="Más Popular Hoy | Poderopedia",
        link="http://www.poderopedia.org",
        description="Poderopedia | Más Popular",
        created_on=str(request.now)
    )
    query=(db.plugin_stats.month==int(request.now.strftime('%m')))& (db.plugin_stats.year==request.now.strftime('%Y'))
    sum = db.plugin_stats.hits.sum()
    popular=db(db.plugin_stats.page_key.like('%conexiones%') & query).select(db.plugin_stats.hits,db.plugin_stats.page_key,sum,
                             orderby=~sum,limitby=(0,2),groupby=db.plugin_stats.page_key,cache=(cache.ram,3600))

    for most in popular:
        page=most.plugin_stats.page_key.split('/')
        page_key=most.plugin_stats.page_key
        largo=len(page)
        if 'personas' in page_key:
            if page[largo-1]:
                alias= page[largo-1].decode('utf-8').replace('_',' ')
                entity=db.persona(alias=alias, is_active=True)
                if entity!=None:
                    imagen=URL('static','tmp/imagen-face.gif')
                    if (entity.depiction!=None) & (entity.depiction!=''):
                        imagen=URL('default','fast_download',args=entity.depiction)

                    args=convert_latin_chars(entity.alias)
                    alias=entity.alias
                controller='personas';
        elif ('organizaciones' in page_key) | ('empresas' in page_key):
            alias= page[largo-1].decode('utf-8').replace('_',' ').replace('-','.')
            entity=db.Organizacion(alias=alias,is_active=True)
            if entity!=None:
                imagen=URL('static','tmp/avatar-organizacion45.gif')

                controller='organizaciones'
                alias=entity.alias
                if entity.tipoOrg==2:
                    controller='empresas'
                    imagen=URL('static','tmp/avatar-empresa.png')
                if (entity.haslogo!=None) & (entity.haslogo!=''):
                    imagen=URL('default','fast_download',args=entity.haslogo)

                args=convert_latin_chars(entity.alias)

        media=dict(url='http://'+request.env.http_host + imagen,medium='image',width='140')
        results=dict(title=alias,link=URL(controller,'conexiones',args=args, extension=False),
                     description=entity.shortBio[:184], created_on=entity.modified_on)
        results['media:content']=media
        entradas.append(results)
    resultados['entries']=entradas
    response.headers['Content-Type']='application/rss+xml'

    return dict(resultados=resultados,title='Más Popular Ahora',desc='Lo más popular en Poderopedia')
Пример #7
0
def lo_ultimo():
    from conversion import convert_latin_chars
    entradas = []
    resultados = dict(title="Poderopedia",
                      link="http://www.poderopedia.org",
                      description="Poderopedia Lo Ultimo",
                      created_on=str(request.now))
    personas = db((db.persona.is_active == True)
                  & (db.persona.shortBio != None) & (db.persona.shortBio != '')
                  & (db.persona.depiction != None)
                  & (db.persona.depiction != '')).select(
                      db.persona.alias,
                      db.persona.shortBio,
                      db.persona.depiction,
                      db.persona.modified_on,
                      orderby=[~db.persona.modified_on],
                      limitby=(0, 2))

    for persona in personas:
        results = dict(title=persona.alias.decode('utf-8'),
                       link=URL('personas',
                                'conexiones',
                                args=convert_latin_chars(persona.alias)),
                       description=persona.shortBio.decode('utf-8'),
                       created_on=str(persona.modified_on))
        entradas.append(results)

    organizacion = db((db.Organizacion.is_active == True)
                      & (db.Organizacion.shortBio != None)
                      & (db.Organizacion.shortBio != '')
                      & (db.Organizacion.haslogo != None)
                      & (db.Organizacion.haslogo != '')).select(
                          db.Organizacion.id,
                          db.Organizacion.tipoOrg,
                          db.Organizacion.alias,
                          db.Organizacion.shortBio,
                          db.Organizacion.haslogo,
                          db.Organizacion.modified_on,
                          orderby=[~db.Organizacion.modified_on],
                          limitby=(0, 2))

    for org in organizacion:
        args = convert_latin_chars(org.alias)
        link = URL('organizaciones', 'conexiones', args=args)
        if org.tipoOrg == 2:
            link = URL('empresas', 'conexiones', args=args)
        results = dict(title=org.alias.decode('utf-8'),
                       link=link,
                       description=org.shortBio.decode('utf-8'),
                       created_on=str(org.modified_on))
        entradas.append(results)
    entradas = sorted(entradas, key=lambda k: k['created_on'], reverse=True)
    resultados['entries'] = entradas
    response.headers['Content-Type'] = 'application/rss+xml'
    return resultados
Пример #8
0
def relation_documentos():
    if request.cid == None: redirect(URL('error', 'error404'))
    from conversion import convert_latin_chars
    _id = request.args(0)
    target = request.vars['target'] or redirect(
        URL('error', 'error404', extension=False))
    page = 0
    sort = 'false'
    letter = ' '
    if len(request.args) > 1: page = int(request.args[1])
    if len(request.args) > 2: sort = request.args(2)
    if len(request.args) > 3: letter = request.args(3)

    documentCloud = ""
    lista = []

    if (target == 'persona'):
        documentList = db((db.persona.id == _id)
                          & (db.persona.is_active == True)).select(
                              cache=(cache.ram, 10)).first()
        if documentList == None: redirect(URL('error', 'error404'))
        controller = 'personas'
        alias = convert_latin_chars(documentList.alias)
    elif target == 'organizacion':
        documentList = db((db.Organizacion.id == _id)
                          & (db.Organizacion.is_active == True)).select(
                              cache=(cache.ram, 10)).first()
        if documentList == None: redirect(URL('error', 'error404'))
        controller = 'organizaciones'
        alias = convert_latin_chars(documentList.alias)
        if documentList.tipoOrg == 2:
            controller = 'empresas'

    if documentList != None:
        if documentList.documentCloud != None:
            for relation in documentList.documentCloud:
                lista.append(relation)

    if lista != []:
        doctmp = set(lista)
        documentCloud = db((db.documentCloud.id.belongs(doctmp))
                           & (db.documentCloud.is_active == True)).select(
                               cache=(cache.ram, 3600))
        #documentCloud = db((db.documentCloud.is_active==True)).select(cache=(cache.ram,3600))

    return dict(documentCloud=documentCloud,
                sort=sort,
                page=page,
                letter=letter,
                _id=_id,
                target=target,
                alias=alias,
                controller=controller)
Пример #9
0
def documentos():
    from conversion import convert_latin_chars
    from gluon.storage import Storage
    url = request.env.http_host + request.env.request_uri
    dc_id = request.args(0) or redirect(URL('default', 'index'))
    _id = request.args(1) or redirect(URL('default', 'index'))
    target = request.args(2) or redirect(URL('default', 'index'))

    alias = ''
    imagen = IMG(_alt=alias,
                 _src=URL('static', 'img/default-pic-profile-person.png'))
    href = ''

    docs = db.documentCloud(dc_id=dc_id, is_active=True)

    if (target == 'persona'):
        person = db(db.persona.id == _id).select(db.persona.alias,
                                                 db.persona.depiction).first()
        alias = convert_latin_chars(person.alias)

        if docs:
            redirect(
                URL('personas',
                    'documentos',
                    args=[alias, convert_latin_chars(docs.title)]))

    elif target == 'organizacion':
        org = db(db.Organizacion.id == _id).select(
            db.Organizacion.alias, db.Organizacion.haslogo,
            db.Organizacion.tipoOrg).first()
        alias = convert_latin_chars(org.alias)
        href = 'caso_organizacion'
        if (org.haslogo != None) & (org.haslogo != ''):
            imagen = IMG(_alt=org.alias,
                         _src=URL('default', 'fast_download',
                                  args=org.haslogo),
                         _height=44)
        if org.tipoOrg == 2:
            if docs:
                redirect(
                    URL('empresas',
                        'documentos',
                        args=[alias, convert_latin_chars(docs.title)]))
        else:
            if docs:
                redirect(
                    URL('organizaciones',
                        'documentos',
                        args=[alias, convert_latin_chars(docs.title)]))

    redirect(URL('error', 'error404'))

    return locals()
Пример #10
0
def empresasrelacionadas():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('error','error404'))
    organizacion=db.Organizacion(_id)
    if organizacion:
        if organizacion.tipoOrg==2:
            redirect(URL('empresas','personasrelacionadas',args=convert_latin_chars(organizacion.alias)))
        else:
            redirect(URL('organizaciones','personasrelacionadas',args=convert_latin_chars(organizacion.alias)))
    else:
        redirect(URL('error','error404'))
    return dict(_id=_id, organizacion=organizacion,url=url)
Пример #11
0
def documentos():
    from gluon.storage import Storage
    from conversion import convert_latin_chars

    url = request.env.http_host + request.env.request_uri
    response.view = "default/documentos.html"

    alias = request.args(0) or redirect(URL("default", "index"))
    alias = alias.decode("utf-8").replace("_", " ").replace("-", ".")

    dc_title = request.args(1) or redirect(URL("default", "index"))
    dc_title = dc_title.decode("utf-8").replace("_", " ").replace("-", ".")

    imagen = IMG(_alt=alias, _src=URL("static", "img/icono-organizaciones.png"), _height=44)
    href = ""

    org = db.Organizacion(alias=alias, is_active=True)
    if org:
        controller = "organizaciones"
        href = "conexiones"
        _id = org.id
        if org.haslogo != None:
            imagen = IMG(_alt=org.alias, _src=URL("default", "fast_download", args=org.haslogo), _height=44)
        args = convert_latin_chars(org.alias)
    else:
        redirect(URL("error", "error404"))

    dc_document = db.documentCloud(title=dc_title, is_active=True)
    if dc_document:
        title = dc_document.title
        dc_args_title = convert_latin_chars(title)
        dc_id = dc_document.dc_id
    else:
        redirect(URL("error", "error404"))

    response.title = org.alias + " | " + title + " | Poderopedia"

    entity = Storage(
        {
            "id": _id,
            "alias": alias,
            "logo": imagen,
            "controller": controller,
            "target": href,
            "args": args,
            "dc_args": dc_args_title,
        }
    )

    return dict(dc_id=dc_id, _id=_id, page=0, sort="false", entity=entity, title=title, url=url)
Пример #12
0
def lo_ultimo_rss():
    from conversion import convert_latin_chars
    response.view='services/mas_popular_rss.html'
    entradas=[]
    resultados=dict(
        title="Poderopedia ",
        link="http://www.poderopedia.org",
        description="Poderopedia | Lo último",
        created_on=request.now
    )
    personas = db((db.persona.is_active==True) & (db.persona.shortBio!=None) & (db.persona.shortBio!='')
                  & (db.persona.depiction!=None) & (db.persona.depiction!='')).select(
        db.persona.alias,db.persona.shortBio,db.persona.depiction,db.persona.modified_on,
        orderby=[~db.persona.modified_on],limitby=(0,2))

    for persona in personas:
        imagen=URL('static','tmp/imagen-face.gif')
        if persona.depiction!='':
            imagen=URL('default','fast_download',args=persona.depiction)
        media=dict(url='http://'+request.env.http_host + imagen,medium='image',width='140')
        results=dict(title=persona.alias,link=URL('personas','conexiones',args=convert_latin_chars(persona.alias)),
                     description=persona.shortBio[:184],created_on=persona.modified_on)
        results['media:content']=media
        entradas.append(results)

    organizacion = db((db.Organizacion.is_active==True) & (db.Organizacion.shortBio!=None) & (db.Organizacion.shortBio!='')
                      & (db.Organizacion.haslogo!=None) & (db.Organizacion.haslogo!='')).select(
        db.Organizacion.id,db.Organizacion.tipoOrg,
        db.Organizacion.alias,db.Organizacion.shortBio,db.Organizacion.haslogo,db.Organizacion.modified_on,
        orderby=[~db.Organizacion.modified_on],limitby=(0,2))

    for org in organizacion:
        args=convert_latin_chars(org.alias)
        imagen=URL('static','tmp/avatar-organizacion45.gif')
        link=URL('organizaciones','conexiones',args=args)
        if org.tipoOrg==2:
            imagen=URL('static','tmp/avatar-empresa.png')
            link=URL('empresas','conexiones',args=args)
        if org.haslogo!='':
            imagen=URL('default','fast_download',args=org.haslogo)
        media=dict(url='http://'+request.env.http_host + imagen,medium='image',width='140')
        results=dict(title=org.alias,link=link,description=org.shortBio[:184],created_on=org.modified_on)
        results['media:content']=media
    entradas.append(results)
    entradas=sorted(entradas, key=lambda k: k['created_on'], reverse=True)
    resultados['entries']=entradas
    response.headers['Content-Type']='application/rss+xml'
    return dict(resultados=resultados,title='Lo ültimo',desc='Últimas actualizaciones en Poderopedia')
Пример #13
0
def lo_ultimo_rss():
    from conversion import convert_latin_chars
    response.view='services/mas_popular_rss.html'
    entradas=[]
    resultados=dict(
        title="Poderopedia ",
        link="http://www.poderopedia.org",
        description="Poderopedia | Lo último",
        created_on=request.now
    )
    personas = db((db.persona.is_active==True) & (db.persona.shortBio!=None) & (db.persona.shortBio!='')
                  & (db.persona.depiction!=None) & (db.persona.depiction!='')).select(
        db.persona.alias,db.persona.shortBio,db.persona.depiction,db.persona.modified_on,
        orderby=[~db.persona.modified_on],limitby=(0,2))

    for persona in personas:
        imagen=URL('static','tmp/imagen-face.gif')
        if persona.depiction!='':
            imagen=URL('default','fast_download',args=persona.depiction)
        media=dict(url='http://'+request.env.http_host + imagen,medium='image',width='140')
        results=dict(title=persona.alias,link=URL('personas','conexiones',args=convert_latin_chars(persona.alias)),
                     description=persona.shortBio[:184],created_on=persona.modified_on)
        results['media:content']=media
        entradas.append(results)

    organizacion = db((db.Organizacion.is_active==True) & (db.Organizacion.shortBio!=None) & (db.Organizacion.shortBio!='')
                      & (db.Organizacion.haslogo!=None) & (db.Organizacion.haslogo!='')).select(
        db.Organizacion.id,db.Organizacion.tipoOrg,
        db.Organizacion.alias,db.Organizacion.shortBio,db.Organizacion.haslogo,db.Organizacion.modified_on,
        orderby=[~db.Organizacion.modified_on],limitby=(0,2))

    for org in organizacion:
        args=convert_latin_chars(org.alias)
        imagen=URL('static','tmp/avatar-organizacion45.gif')
        link=URL('organizaciones','conexiones',args=args)
        if org.tipoOrg==2:
            imagen=URL('static','tmp/avatar-empresa.png')
            link=URL('empresas','conexiones',args=args)
        if org.haslogo!='':
            imagen=URL('default','fast_download',args=org.haslogo)
        media=dict(url='http://'+request.env.http_host + imagen,medium='image',width='140')
        results=dict(title=org.alias,link=link,description=org.shortBio[:184],created_on=org.modified_on)
        results['media:content']=media
    entradas.append(results)
    entradas=sorted(entradas, key=lambda k: k['created_on'], reverse=True)
    resultados['entries']=entradas
    response.headers['Content-Type']='application/rss+xml'
    return dict(resultados=resultados,title='Lo ültimo',desc='Últimas actualizaciones en Poderopedia')
Пример #14
0
def organizacionesrelacionadas():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('default','index'))
    persona=db.persona(_id)
    redirect(URL('personas','organizacionesrelacionadas',args=convert_latin_chars(persona.alias)))
    return dict(_id=_id, persona=persona,url=url)
Пример #15
0
def caso_perfil():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    person=db.persona(request.args(0)) or redirect(URL('error','error404'))

    redirect(URL('personas','conexiones',args=convert_latin_chars(person.alias)))

    _id=request.args(0)
    db.persona.id.readable=False
    db.persona.ICN.readable=False
    db.persona.shortBio.readable=False
    db.persona.longBio.readable=False
    db.persona.depiction.readable=False
    db.persona.documentSource.readable=False
    db.persona.documentCloud.readable=False
    for fields in db.persona:
        if (person[fields]==None) | (person[fields]=='') | (person[fields]==False) | (person[fields]==[])\
           | (person[fields]=='NULL'):
            fields.readable=False
        fields.writable=False
    form=SQLFORM(db.persona,person)
    form['_class']='form-horizontal'
    submit = form.element('input',_type='submit')
    submit['_style'] = 'display:none;'


    borrar=auth.has_membership('administrator')


    return dict(persona=person, _id=request.args(0), form=form, borrar=borrar, url=url )
Пример #16
0
def personasrelacionadas():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('error','error404'))
    persona=db.persona(_id)
    redirect(URL('personas','personasrelacionadas',args=convert_latin_chars(persona.alias)))
    return dict(_id=_id, persona=persona,url=url)
Пример #17
0
def MapasAllOrgs():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('error','error404'))
    org=None
    imagen=IMG(_src=URL('static','tmp/avatar-36.gif'))

    org=db.Organizacion(_id)
    if (org!=None):
        if org.tipoOrg==2:
            redirect(URL('empresas','mapa_relaciones',args=convert_latin_chars(org.alias)))
        else:
            redirect(URL('organizaciones','mapa_relaciones',args=convert_latin_chars(org.alias)))

    redirect(URL('error','error404'))

    return dict(_id=_id,org=org,imagen=imagen,url=url)
Пример #18
0
def MapasAllOrgs():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('error','error404'))
    org=None
    imagen=IMG(_src=URL('static','tmp/avatar-36.gif'))

    org=db.Organizacion(_id)
    if (org!=None):
        if org.tipoOrg==2:
            redirect(URL('empresas','mapa_relaciones',args=convert_latin_chars(org.alias)))
        else:
            redirect(URL('organizaciones','mapa_relaciones',args=convert_latin_chars(org.alias)))

    redirect(URL('error','error404'))

    return dict(_id=_id,org=org,imagen=imagen,url=url)
Пример #19
0
def relation_privateOrg():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    target=request.cid
    if (target==None) | (target==''):
        redirect(URL('error','error404'))

    persona=db.persona(_id)
    if persona:
        alias=convert_latin_chars(persona.alias)
    else:
        redirect(URL('error','error404'))



    Org=""; total=0;

    if len(request.args)>2: page=int(request.args[2])
    else: page=0
    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    lista=[]
    ##relPersona
    relPersonas=db(((db.relPersona.origenP==_id) | (db.relPersona.destinoP==_id)) & (db.relPersona.is_active==True) &(db.relPersona.extraO>0)).select(db.relPersona.extraO,groupby=db.relPersona.extraO,cache=(cache.ram,3600))
    for relPersona in relPersonas:
        lista.append(relPersona.extraO)

    ##relPersOrg
    relPersOrgs=db((db.RelPersOrg.is_active==True) &(db.RelPersOrg.origenP==_id)).select(db.RelPersOrg.destinoO,groupby=db.RelPersOrg.destinoO,cache=(cache.ram,3600))
    for relPersOrg in relPersOrgs:
        lista.append(relPersOrg.destinoO)



    tipoOrg=request.args(1)
    Organizationtype="Organización"


    if tipoOrg=='2':
        if lista!=[]:
            total=len(db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg==2)).select(cache=(cache.ram,3600)))
            Org=db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg==2)).select(
                db.Organizacion.id,db.Organizacion.alias,db.Organizacion.name,db.Organizacion.haslogo,db.Organizacion.depiction,
                db.Organizacion.tipoOrg,limitby=limitby,cache=(cache.ram,3600))
        Organizationtype="Empresa";
        controller='personas'; function='empresasrelacionadas'
    else:
        if lista!=[]:
            total=len(db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg!=2)).select(cache=(cache.ram,3600)))
            Org=db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg!=2)).select(
                db.Organizacion.id,db.Organizacion.alias,db.Organizacion.name,db.Organizacion.haslogo,db.Organizacion.depiction,
                db.Organizacion.tipoOrg,limitby=limitby,cache=(cache.ram,3600))
        controller='personas'; function='organizacionesrelacionadas'
    return dict(controller=controller,function=function,Org=Org,
        Organizationtype=Organizationtype,page=page,items_per_page=items_per_page,tipoOrg=tipoOrg,_id=_id,
        total=total,target=target,alias=alias)
Пример #20
0
def relation_privateOrg():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    target=request.cid
    if (target==None) | (target==''):
        redirect(URL('error','error404'))

    persona=db.persona(_id)
    if persona:
        alias=convert_latin_chars(persona.alias)
    else:
        redirect(URL('error','error404'))



    Org=""; total=0;

    if len(request.args)>2: page=int(request.args[2])
    else: page=0
    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    lista=[]
    ##relPersona
    relPersonas=db(((db.relPersona.origenP==_id) | (db.relPersona.destinoP==_id)) & (db.relPersona.is_active==True) &(db.relPersona.extraO>0)).select(db.relPersona.extraO,groupby=db.relPersona.extraO,cache=(cache.ram,3600))
    for relPersona in relPersonas:
        lista.append(relPersona.extraO)

    ##relPersOrg
    relPersOrgs=db((db.RelPersOrg.is_active==True) &(db.RelPersOrg.origenP==_id)).select(db.RelPersOrg.destinoO,groupby=db.RelPersOrg.destinoO,cache=(cache.ram,3600))
    for relPersOrg in relPersOrgs:
        lista.append(relPersOrg.destinoO)



    tipoOrg=request.args(1)
    Organizationtype="Organización"


    if tipoOrg=='2':
        if lista!=[]:
            total=len(db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg==2)).select(cache=(cache.ram,3600)))
            Org=db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg==2)).select(
                db.Organizacion.id,db.Organizacion.alias,db.Organizacion.name,db.Organizacion.haslogo,db.Organizacion.depiction,
                db.Organizacion.tipoOrg,limitby=limitby,cache=(cache.ram,3600))
        Organizationtype="Empresa";
        controller='personas'; function='empresasrelacionadas'
    else:
        if lista!=[]:
            total=len(db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg!=2)).select(cache=(cache.ram,3600)))
            Org=db((db.Organizacion.id.belongs(lista)) &(db.Organizacion.is_active==True) & (db.Organizacion.tipoOrg!=2)).select(
                db.Organizacion.id,db.Organizacion.alias,db.Organizacion.name,db.Organizacion.haslogo,db.Organizacion.depiction,
                db.Organizacion.tipoOrg,limitby=limitby,cache=(cache.ram,3600))
        controller='personas'; function='organizacionesrelacionadas'
    return dict(controller=controller,function=function,Org=Org,
        Organizationtype=Organizationtype,page=page,items_per_page=items_per_page,tipoOrg=tipoOrg,_id=_id,
        total=total,target=target,alias=alias)
Пример #21
0
def documentos():
    from gluon.storage import Storage
    from conversion import convert_latin_chars

    url =request.env.http_host + request.env.request_uri
    response.view='default/documentos.html'

    alias=request.args(0)  or redirect(URL('default','index'))
    alias=alias.decode('utf-8').replace('_',' ').replace('-','.')

    dc_title=request.args(1) or redirect(URL('default','index'))
    dc_title=dc_title.decode('utf-8').replace('_',' ').replace('-','.')

    imagen=IMG(_alt=alias, _src=URL('static','icono-empresas.png'),_height=44)
    href=''


    org= db.Organizacion(alias=alias,tipoOrg=2)
    if org:
        controller='empresas'; href='conexiones'
        _id=org.id
        if org.haslogo!=None:
            imagen=IMG(_alt=org.alias,_src=URL('default','fast_download',args=org.haslogo),_height=44)
        args=convert_latin_chars(org.alias)
    else:
        redirect(URL('error','error404'))


    dc_document=db.documentCloud(title=dc_title,is_active=True)
    if dc_document:
        title=dc_document.title
        dc_args_title=convert_latin_chars(title)
        dc_id=dc_document.dc_id
    else:
        redirect(URL('error','error404'))

    entity=Storage({'id':_id,'alias':alias,'logo':imagen,'controller':controller,
                    'target':href,'args':args,'dc_args':dc_args_title})


    response.title=org.alias + ' | ' + title + ' | Poderopedia'



    return dict(dc_id=dc_id,_id=_id,page=0,sort='false',entity=entity,title=title,url=url)
Пример #22
0
def documentos():
    from gluon.storage import Storage
    from conversion import convert_latin_chars


    response.view='default/documentos.html'

    alias=request.args(0)  or redirect(URL('default','index'))
    alias=alias.decode('utf-8').replace('_',' ')

    dc_title=request.args(1) or redirect(URL('default','index'))
    dc_title=dc_title.decode('utf-8').replace('_',' ').replace('-','.')


    imagen=IMG(_alt=alias, _src=URL('static','img/default-pic-profile-person.png'))
    href=''


    person= db.persona(alias=alias,is_active=True)
    if person:
        controller='personas'; href='conexiones'
        imagen=IMG(_alt=person.alias,_src=URL('static','img/default-pic-profile-person.png'),_height=44)
        _id=person.id
        if person.depiction!=None:
            imagen=IMG(_alt=person.alias,_src=URL('default','fast_download',args=person.depiction),_height=44)
        args=convert_latin_chars(person.alias)
    else:
        redirect(URL('error','error404'))




    dc_document=db.documentCloud(title=dc_title,is_active=True)
    if dc_document:
        title=dc_document.title
        dc_args_title=convert_latin_chars(title)
        dc_id=dc_document.dc_id
    else:
        redirect(URL('error','error404'))

    response.title=person.alias + '|' + title + ' Poderopedia'
    entity=Storage({'id':_id,'alias':alias,'logo':imagen,'controller':controller,
                    'target':href,'args':args,'dc_args':dc_args_title})

    return dict(dc_id=dc_id,_id=_id,page=0,sort='false',entity=entity,title=title)
Пример #23
0
def empresasrelacionadas():
    from conversion import convert_latin_chars
    url = request.env.http_host + request.env.request_uri
    _id = request.args(0) or redirect(URL('error', 'error404'))
    organizacion = db.Organizacion(_id)
    if organizacion:
        if organizacion.tipoOrg == 2:
            redirect(
                URL('empresas',
                    'personasrelacionadas',
                    args=convert_latin_chars(organizacion.alias)))
        else:
            redirect(
                URL('organizaciones',
                    'personasrelacionadas',
                    args=convert_latin_chars(organizacion.alias)))
    else:
        redirect(URL('error', 'error404'))
    return dict(_id=_id, organizacion=organizacion, url=url)
Пример #24
0
def documentos():
    from conversion import convert_latin_chars
    from gluon.storage import Storage

    url = request.env.http_host + request.env.request_uri
    dc_id = request.args(0) or redirect(URL("default", "index"))
    _id = request.args(1) or redirect(URL("default", "index"))
    target = request.args(2) or redirect(URL("default", "index"))

    alias = ""
    imagen = IMG(_alt=alias, _src=URL("static", "img/default-pic-profile-person.png"))
    href = ""

    docs = db.documentCloud(dc_id=dc_id, is_active=True)

    if target == "persona":
        person = db(db.persona.id == _id).select(db.persona.alias, db.persona.depiction).first()
        alias = convert_latin_chars(person.alias)

        if docs:
            redirect(URL("personas", "documentos", args=[alias, convert_latin_chars(docs.title)]))

    elif target == "organizacion":
        org = (
            db(db.Organizacion.id == _id)
            .select(db.Organizacion.alias, db.Organizacion.haslogo, db.Organizacion.tipoOrg)
            .first()
        )
        alias = convert_latin_chars(org.alias)
        href = "caso_organizacion"
        if (org.haslogo != None) & (org.haslogo != ""):
            imagen = IMG(_alt=org.alias, _src=URL("default", "fast_download", args=org.haslogo), _height=44)
        if org.tipoOrg == 2:
            if docs:
                redirect(URL("empresas", "documentos", args=[alias, convert_latin_chars(docs.title)]))
        else:
            if docs:
                redirect(URL("organizaciones", "documentos", args=[alias, convert_latin_chars(docs.title)]))

    redirect(URL("error", "error404"))

    return locals()
Пример #25
0
def Org_relation_privateOrg():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    if _id<0: redirect(URL('default','index'))
    response.view='services/relation_privateOrg.load'



    organizacion=db.Organizacion(_id)
    if organizacion:
        alias=convert_latin_chars(organizacion.alias)
        if organizacion.tipoOrg==2:
            controller='empresas'
        else:
            controller='organizaciones'
    else:
        redirect(URL('error','error404'))



    if len(request.args)>2: page=int(request.args[2])
    else: page=0
    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    tipoOrg=request.args(1)
    Organizationtype="Organización"
    target="organizacion"

    lista=[];
    Org=db((db.relOrg2Org.destinoO==_id)|(db.relOrg2Org.origenO==_id)).select(db.relOrg2Org.destinoO,db.relOrg2Org.origenO)
    for relation in Org:
        select=relation.destinoO
        if relation.destinoO==int(_id):
            select=relation.origenO
        lista.append(select)

    if tipoOrg=='2':
        total=len(db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg==2)).select(cache=(cache.ram,3600)))
        Org=db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg==2)).select(limitby=limitby,cache=(cache.ram,3600))
        Organizationtype="Empresa"; target="empresa"
        function='empresasrelacionadas'
    else:
        total=len(db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg!=2)).select(cache=(cache.ram,3600)))
        Org=db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg!=2)).select(limitby=limitby,cache=(cache.ram,3600))
        function='organizacionesrelacionadas'

    return dict(controller=controller,function=function,Org=Org,Organizationtype=Organizationtype,
        page=page,items_per_page=items_per_page,tipoOrg=tipoOrg,_id=_id,total=total,target=target,alias=alias)
Пример #26
0
def Org_relation_privateOrg():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    if _id<0: redirect(URL('default','index'))
    response.view='services/relation_privateOrg.load'



    organizacion=db.Organizacion(_id)
    if organizacion:
        alias=convert_latin_chars(organizacion.alias)
        if organizacion.tipoOrg==2:
            controller='empresas'
        else:
            controller='organizaciones'
    else:
        redirect(URL('error','error404'))



    if len(request.args)>2: page=int(request.args[2])
    else: page=0
    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    tipoOrg=request.args(1)
    Organizationtype="Organización"
    target="organizacion"

    lista=[];
    Org=db((db.relOrg2Org.destinoO==_id)|(db.relOrg2Org.origenO==_id)).select(db.relOrg2Org.destinoO,db.relOrg2Org.origenO)
    for relation in Org:
        select=relation.destinoO
        if relation.destinoO==int(_id):
            select=relation.origenO
        lista.append(select)

    if tipoOrg=='2':
        total=len(db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg==2)).select(cache=(cache.ram,3600)))
        Org=db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg==2)).select(limitby=limitby,cache=(cache.ram,3600))
        Organizationtype="Empresa"; target="empresa"
        function='empresasrelacionadas'
    else:
        total=len(db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg!=2)).select(cache=(cache.ram,3600)))
        Org=db((db.Organizacion.id.belongs(lista))&(db.Organizacion.tipoOrg!=2)).select(limitby=limitby,cache=(cache.ram,3600))
        function='organizacionesrelacionadas'

    return dict(controller=controller,function=function,Org=Org,Organizationtype=Organizationtype,
        page=page,items_per_page=items_per_page,tipoOrg=tipoOrg,_id=_id,total=total,target=target,alias=alias)
Пример #27
0
def relation_persona_sidebar():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    famrelations=[];target='sidebar_persona'; controller='personas'
    persona=db.persona(_id)
    if persona:
        alias=convert_latin_chars(persona.alias)
    else:
        redirect(URL('error','error404'))
    total=0; personas=""

    if len(request.args)>1: page=int(request.args[1])
    else: page=0

    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    lista=[]
    ##Familiar relations
    familiares=db(((db.relFamiliar.origenP==_id) | (db.relFamiliar.destinoP==_id)) &
                  (db.relFamiliar.is_active==True) ).select(
                   db.relFamiliar.origenP,db.relFamiliar.destinoP,cache=(cache.ram,3600))
    for familiar in familiares:
        select=familiar.destinoP
        if(familiar.destinoP==int(_id)):
            select=familiar.origenP
        lista.append(select)

    ##relPersona
    relPersonas=db(((db.relPersona.origenP==_id) | (db.relPersona.destinoP==_id)) &
                   (db.relPersona.is_active==True) ).select(
                    db.relPersona.origenP,db.relPersona.destinoP,cache=(cache.ram,3600))
    for relPersona in relPersonas:
        select=relPersona.destinoP
        if(relPersona.destinoP==int(_id)):
            select=relPersona.origenP
        lista.append(select)

    if lista!=[]:
        tmplista=set(lista)
        total=len(db(db.persona.id.belongs(tmplista)  &(db.persona.is_active==True)).select(cache=(cache.ram,3600)))
        personas=db((db.persona.id.belongs(tmplista))
                    &(db.persona.is_active==True)).select(limitby=limitby,cache=(cache.ram,3600))



    return dict(controller=controller,personas=personas,page=page,
        items_per_page=items_per_page,target=target,entity=famrelations,_id=_id, total=total, alias=alias)
Пример #28
0
def relation_persona_sidebar():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    famrelations=[];target='sidebar_persona'; controller='personas'
    persona=db.persona(_id)
    if persona:
        alias=convert_latin_chars(persona.alias)
    else:
        redirect(URL('error','error404'))
    total=0; personas=""

    if len(request.args)>1: page=int(request.args[1])
    else: page=0

    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    lista=[]
    ##Familiar relations
    familiares=db(((db.relFamiliar.origenP==_id) | (db.relFamiliar.destinoP==_id)) &
                  (db.relFamiliar.is_active==True) ).select(
                   db.relFamiliar.origenP,db.relFamiliar.destinoP,cache=(cache.ram,3600))
    for familiar in familiares:
        select=familiar.destinoP
        if(familiar.destinoP==int(_id)):
            select=familiar.origenP
        lista.append(select)

    ##relPersona
    relPersonas=db(((db.relPersona.origenP==_id) | (db.relPersona.destinoP==_id)) &
                   (db.relPersona.is_active==True) ).select(
                    db.relPersona.origenP,db.relPersona.destinoP,cache=(cache.ram,3600))
    for relPersona in relPersonas:
        select=relPersona.destinoP
        if(relPersona.destinoP==int(_id)):
            select=relPersona.origenP
        lista.append(select)

    if lista!=[]:
        tmplista=set(lista)
        total=len(db(db.persona.id.belongs(tmplista)  &(db.persona.is_active==True)).select(cache=(cache.ram,3600)))
        personas=db((db.persona.id.belongs(tmplista))
                    &(db.persona.is_active==True)).select(limitby=limitby,cache=(cache.ram,3600))



    return dict(controller=controller,personas=personas,page=page,
        items_per_page=items_per_page,target=target,entity=famrelations,_id=_id, total=total, alias=alias)
Пример #29
0
def Org_relation_persona_sidebar():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    #response.view='services/relation_persona_sidebar.load'



    organizacion=db.Organizacion(_id)
    if organizacion:
        alias=convert_latin_chars(organizacion.alias)
        if organizacion.tipoOrg==2:
            controller='empresas'
        else:
            controller='organizaciones'
    else:
        redirect(URL('error','error404'))


    if len(request.args)>1: page=int(request.args[1])
    else: page=0
    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    target='sidebar_persona'
    persontmp=[]
    total=0

    ##relPersOrg
    relPersOrg=db((db.RelPersOrg.destinoO==_id)).select(db.RelPersOrg.origenP,groupby=db.RelPersOrg.origenP,cache=(cache.ram,3600))
    for relation in relPersOrg:
        persontmp.append(relation.origenP)

    ##relPersona
    relPersona=db(db.relPersona.extraO==_id).select(db.relPersona.origenP,db.relPersona.destinoP,groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
    for relation in relPersona:
        persontmp.append(relation.origenP)
        persontmp.append(relation.destinoP)

    person=set(persontmp)

    personas=""
    if(persontmp!=[]):
        total=len(db(db.persona.id.belongs(person)).select(cache=(cache.ram,3600)))
        personas= db(db.persona.id.belongs(person)).select(limitby=limitby,cache=(cache.ram,3600))

    return dict(controller=controller,total=total, personas=personas,limitby=limitby,
        items_per_page=items_per_page,page=page,target=target,_id=_id,alias=alias)
Пример #30
0
def Org_relation_persona_sidebar():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    _id=request.args(0) or redirect(URL('default','index'))
    #response.view='services/relation_persona_sidebar.load'



    organizacion=db.Organizacion(_id)
    if organizacion:
        alias=convert_latin_chars(organizacion.alias)
        if organizacion.tipoOrg==2:
            controller='empresas'
        else:
            controller='organizaciones'
    else:
        redirect(URL('error','error404'))


    if len(request.args)>1: page=int(request.args[1])
    else: page=0
    items_per_page=8
    limitby=(page*items_per_page,(page+1)*items_per_page+1)

    target='sidebar_persona'
    persontmp=[]
    total=0

    ##relPersOrg
    relPersOrg=db((db.RelPersOrg.destinoO==_id)).select(db.RelPersOrg.origenP,groupby=db.RelPersOrg.origenP,cache=(cache.ram,3600))
    for relation in relPersOrg:
        persontmp.append(relation.origenP)

    ##relPersona
    relPersona=db(db.relPersona.extraO==_id).select(db.relPersona.origenP,db.relPersona.destinoP,groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
    for relation in relPersona:
        persontmp.append(relation.origenP)
        persontmp.append(relation.destinoP)

    person=set(persontmp)

    personas=""
    if(persontmp!=[]):
        total=len(db(db.persona.id.belongs(person)).select(cache=(cache.ram,3600)))
        personas= db(db.persona.id.belongs(person)).select(limitby=limitby,cache=(cache.ram,3600))

    return dict(controller=controller,total=total, personas=personas,limitby=limitby,
        items_per_page=items_per_page,page=page,target=target,_id=_id,alias=alias)
Пример #31
0
def MapasAll():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('error','error404'))
    person=None
    imagen=IMG(_src=URL('static','tmp/avatar-36.gif'))

    person=db.persona(_id)
    if (person!=None):
        redirect(URL('personas','mapa_relaciones',args=convert_latin_chars(person.alias)))
    else:
        redirect(URL('error','error404'))



    return dict(_id=_id,person=person,imagen=imagen,url=url)
Пример #32
0
def MapasAll():
    from conversion import convert_latin_chars
    url =request.env.http_host + request.env.request_uri
    _id=request.args(0) or redirect(URL('error','error404'))
    person=None
    imagen=IMG(_src=URL('static','tmp/avatar-36.gif'))

    person=db.persona(_id)
    if (person!=None):
        redirect(URL('personas','mapa_relaciones',args=convert_latin_chars(person.alias)))
    else:
        redirect(URL('error','error404'))



    return dict(_id=_id,person=person,imagen=imagen,url=url)
Пример #33
0
def mas_popular():
    if request.cid == None:
        redirect(URL("error", "error404"))
    from conversion import convert_latin_chars

    result = []
    active = {}
    args = ""
    active["hoy"] = active["semana"] = active["mes"] = ""
    imagen = None
    function = "connections"
    if request.args(0) == "portada":
        active["hoy"] = "active"
        query = db.plugin_stats.dia == request.now
        if request.args(1) == "month":
            active["mes"] = "active"
            active["hoy"] = ""
            query = (db.plugin_stats.month == int(request.now.strftime("%m"))) & (
                db.plugin_stats.year == request.now.strftime("%Y")
            )
        elif request.args(1) == "week":
            active["semana"] = "active"
            active["hoy"] = ""
            query = (db.plugin_stats.week == int(request.now.strftime("%W"))) & (
                db.plugin_stats.year == request.now.strftime("%Y")
            )
        sum = db.plugin_stats.hits.sum()
        popular = db(db.plugin_stats.page_key.like("%connections%") & query).select(
            db.plugin_stats.hits,
            db.plugin_stats.page_key,
            sum,
            orderby=~sum,
            limitby=(0, 5),
            groupby=db.plugin_stats.page_key,
            cache=(cache.ram, 3600),
        )

        response.view = "services/mas_visto.load"
    else:
        popular = db((db.plugin_stats.page_key.like("%connections%")) & (db.plugin_stats.dia == request.now)).select(
            orderby=~db.plugin_stats.hits, limitby=(0, 4), cache=(cache.ram, 3600)
        )

    for most in popular:
        if request.args(0) == "portada":
            page = most.plugin_stats.page_key.split("/")
            page_key = most.plugin_stats.page_key
        else:
            page = most.page_key.split("/")
            page_key = most.page_key
        largo = len(page)
        if "personas" in page_key:
            if page[largo - 1]:
                alias = page[largo - 1].decode("utf-8").replace("_", " ")
                entity = db.persona(alias=alias, is_active=True)
                if entity != None:
                    imagen = IMG(_alt=entity.alias, _src=URL("static", "tmp/imagen-face.gif"), _width="140")
                    if (entity.depiction != None) & (entity.depiction != ""):
                        imagen = IMG(
                            _alt=entity.alias,
                            _src=URL("default", "fast_download", args=entity.depiction),
                            _class="imagen-perfil-ch",
                            _width="140",
                        )
                    args = convert_latin_chars(entity.alias)
                    alias = entity.alias
                controller = "personas"
        elif ("organizaciones" in page_key) | ("empresas" in page_key):
            alias = page[largo - 1].decode("utf-8").replace("_", " ").replace("-", ".")
            entity = db.Organizacion(alias=alias, is_active=True)
            if entity != None:
                imagen = IMG(
                    _alt=entity.alias,
                    _src=URL("static", "tmp/avatar-organizacion45.gif"),
                    _class="imagen-perfil-ch",
                    _width="100",
                )
                controller = "organizaciones"
                alias = entity.alias
                if entity.tipoOrg == 2:
                    controller = "empresas"
                    imagen = IMG(_alt=entity.alias, _src=URL("static", "tmp/avatar-empresa.png"), _width="100")
                if (entity.haslogo != None) & (entity.haslogo != ""):
                    imagen = IMG(
                        _alt=entity.alias,
                        _src=URL("default", "fast_download", args=entity.haslogo),
                        _class="imagen-perfil-ch",
                        _width="90",
                        _heigth="80",
                    )
                args = convert_latin_chars(entity.alias)

        shortBio = ""
        if entity != None:
            if entity.shortBio != None:
                shortBio = entity.shortBio
        else:
            redirect(URL("error", "error404"))

        result.append(dict(alias=alias, c=controller, f=function, args=args, imagen=imagen, shortBio=shortBio))

    return dict(popular=result, active=active)
Пример #34
0
def mas_popular():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    result=[]; active={}; args=''
    active['hoy']=active['semana']=active['mes']=''
    imagen=None
    function='conexiones'
    if request.args(0)=='portada':
        active['hoy']='active'
        query=(db.plugin_stats.dia==request.now)
        if request.args(1)=='month':
            active['mes']='active'; active['hoy']=''
            query=(db.plugin_stats.month==int(request.now.strftime('%m')))& (db.plugin_stats.year==request.now.strftime('%Y'))
        elif request.args(1)=='week':
            active['semana']='active'; active['hoy']=''
            query=(db.plugin_stats.week==int(request.now.strftime('%W')))& (db.plugin_stats.year==request.now.strftime('%Y'))
        sum = db.plugin_stats.hits.sum()
        popular=db((db.plugin_stats.page_key.like('%conexiones%')) & ~(db.plugin_stats.page_key.like('%tab%')) & query).select(db.plugin_stats.hits,db.plugin_stats.page_key,sum,
            orderby=~sum,limitby=(0,5),groupby=db.plugin_stats.page_key,cache=(cache.ram,3600))

        response.view='services/mas_visto.load'
    else:
        popular=db((db.plugin_stats.page_key.like('%conexiones%'))& ~(db.plugin_stats.page_key.like('%tab%')) & (db.plugin_stats.dia==request.now)).select(
            orderby=~db.plugin_stats.hits,limitby=(0,4),cache=(cache.ram,3600))



    for most in popular:
        if request.args(0)=='portada':
            page=most.plugin_stats.page_key.split('/')
            page_key=most.plugin_stats.page_key
        else:
            page=most.page_key.split('/')
            page_key=most.page_key
        largo=len(page)
        if 'personas' in page_key:
            if page[largo-1]:
                alias= page[largo-1].decode('utf-8').replace('_',' ')
                entity=db.persona(alias=alias, is_active=True)
                if entity is not None:
                    imagen=IMG(_alt=entity.alias,_src=URL('static','tmp/imagen-face.gif'), _width='140')
                    if (entity.depiction!=None) & (entity.depiction!=''):
                        imagen=IMG(_alt=entity.alias,_src=URL('default','fast_download',args=entity.depiction),
                                   _class='imagen-perfil-ch', _width='140')
                    args=convert_latin_chars(entity.alias)
                    alias=entity.alias
                controller='personas'
        elif ('organizaciones' in page_key) | ('empresas' in page_key):
            alias= page[largo-1].decode('utf-8').replace('_',' ').replace('-','.')
            entity=db.Organizacion(alias=alias,is_active=True)
            if entity!=None:
                imagen=IMG(_alt=entity.alias,_src=URL('static','tmp/avatar-organizacion45.gif'),
                           _class='imagen-perfil-ch', _width='100')
                controller='organizaciones'
                alias=entity.alias
                if entity.tipoOrg==2:
                    controller='empresas'
                    imagen=IMG(_alt=entity.alias,_src=URL('static','tmp/avatar-empresa.png'), _width='100')
                if (entity.haslogo!=None) & (entity.haslogo!=''):
                    imagen=IMG(_alt=entity.alias,_src=URL('default','fast_download',args=entity.haslogo),
                               _class='imagen-perfil-ch', _width='90', _heigth='80')
                args=convert_latin_chars(entity.alias)



        shortBio=''
        if entity!=None:
            if entity.shortBio!=None:
                shortBio=entity.shortBio
        else:
            redirect(URL('error','error404'))

        result.append(dict(alias=alias,c=controller,f=function,args=args,imagen=imagen,shortBio=shortBio))

    return dict(popular=result, active=active)
Пример #35
0
def news():
    import random
    from conversion import convert_latin_chars
    if request.cid == None: redirect(URL('error', 'error404'))
    alias = direccion = None
    lista = []
    short = None
    error = None

    aleatorio = random.randint(
        1, 2
    )  #1 empresas 2 organizaciones 3 casos, como no hay casos solo se tiene que agregar mas adelante
    principal = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC", limitby=(0, 1),
        cache=(cache.ram, 15)).first()
    secundarios = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC", limitby=(1, 3), cache=(cache.ram, 15))
    carrusel = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC", limitby=(3, 9), cache=(cache.ram, 15))
    resto = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC",
        limitby=(9, 13),
        cache=(cache.ram, 15))

    personas = db((db.persona.is_active == True)
                  & (db.persona.shortBio != None) & (db.persona.shortBio != '')
                  & (db.persona.depiction != None)
                  & (db.persona.depiction != '')).select(
                      db.persona.alias,
                      db.persona.shortBio,
                      db.persona.depiction,
                      db.persona.created_on,
                      orderby=[~db.persona.modified_on],
                      limitby=(0, 2))

    organizacion = db((db.Organizacion.is_active == True)
                      & (db.Organizacion.shortBio != None)
                      & (db.Organizacion.shortBio != '')
                      & (db.Organizacion.haslogo != None)
                      & (db.Organizacion.haslogo != '')).select(
                          db.Organizacion.id,
                          db.Organizacion.tipoOrg,
                          db.Organizacion.alias,
                          db.Organizacion.shortBio,
                          db.Organizacion.haslogo,
                          db.Organizacion.created_on,
                          orderby=[~db.Organizacion.modified_on],
                          limitby=(0, 2))

    url = {}
    for org in organizacion:
        url[org.id] = URL('organizaciones',
                          'conexiones',
                          args=convert_latin_chars(org.alias),
                          extension=False)
        if org.tipoOrg == 2:
            url[org.id] = URL('empresas',
                              'conexiones',
                              args=convert_latin_chars(org.alias),
                              extension=False)

    shortBio = {}
    for news in resto:

        if (news.referenceEntity != None) & (news.reference != None):
            shortBio[news.referenceEntity[:1] + '_' +
                     str(news.reference)] = 'maluenda'
            if news.referenceEntity == 'persona':
                entity = db.persona(id=news.reference)
            elif (news.referenceEntity == 'empresa') | (news.referenceEntity
                                                        == 'organizacion'):
                entity = db.Organizacion(id=news.reference)
            if entity != None:
                shortBio[news.referenceEntity[:1] + '_' +
                         str(news.reference)] = p.sub('',
                                                      entity.shortBio)[:184]

    if aleatorio == 1:
        random = db((db.persona.is_active == True)
                    & (db.persona.shortBio != '')).select(db.persona.alias,
                                                          orderby='<random>',
                                                          limitby=(0, 1),
                                                          cache=(cache.ram,
                                                                 15)).first()
        if random:
            direccion = URL('personas',
                            'conexiones',
                            args=convert_latin_chars(random.alias),
                            extension=False)
    else:
        random = db((db.Organizacion.is_active == True)
                    & (db.Organizacion.shortBio != '')).select(
                        db.Organizacion.alias,
                        db.Organizacion.tipoOrg,
                        orderby='<random>',
                        limitby=(0, 1),
                        cache=(cache.ram, 15)).first()
        if random:
            direccion = URL('organizaciones',
                            'conexiones',
                            args=convert_latin_chars(random.alias),
                            extension=False)
            if random.tipoOrg == 2:
                direccion = URL('empresas',
                                'conexiones',
                                args=convert_latin_chars(random.alias),
                                extension=False)

    return dict(random=random,
                direccion=direccion,
                url=url,
                principal=principal,
                secundarios=secundarios,
                carrusel=carrusel,
                resto=resto,
                alias=lista,
                shortBio=shortBio,
                personas=personas,
                organizacion=organizacion)
Пример #36
0
def persona2all(_id=0):
    from conversion import convert_latin_chars
    from collections import Counter

    nodes=[]; links=[]; PersonID={}; listaNodosPersona=[]; listaNodosOrgs=[]

    if id!=0:
        listaNodosPersona.append(_id)
        relFamiliar=db(((db.relFamiliar.origenP==_id) | (db.relFamiliar.destinoP==_id)) & (db.relFamiliar.is_active==True)
                       & (db.relFamiliar.parentesco==db.tipoParentesco.id)
                       & (db.relFamiliar.origenP==db.persona.id) & (db.persona.is_active==True)
        ).select(
            db.relFamiliar.origenP,db.relFamiliar.destinoP, db.tipoParentesco.name,
            cache=(cache.ram,3600)
        )
        for relation in relFamiliar:
            person=db(db.persona.id==relation.relFamiliar.destinoP).select(cache=(cache.ram,3600)).first()
            if person.is_active:
                listaNodosPersona.append(relation.relFamiliar.origenP)
                listaNodosPersona.append(relation.relFamiliar.destinoP)
                links.append(dict(
                    source='P'+str(relation.relFamiliar.origenP),
                    target='P'+str(relation.relFamiliar.destinoP),
                    value="1",
                    grupo='Familiar'
                ))
        ##person2person
        num = db.relPersona.origenP.count()
        relPersona=db((db.relPersona.is_active==True) & ((db.relPersona.origenP==_id) | (db.relPersona.destinoP==_id))
                      & (db.relPersona.relacion==db.tipoRelacionP2P.id)).select(
                            db.relPersona.origenP,db.relPersona.destinoP,num,db.tipoRelacionP2P.name,
                            groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
        for relation in relPersona:
            listaNodosPersona.append(relation.relPersona.origenP)
            listaNodosPersona.append(relation.relPersona.destinoP)
            links.append(dict(source='P'+str(relation.relPersona.origenP),target='P'+str(relation.relPersona.destinoP),value=relation[num], grupo=relation.tipoRelacionP2P.name))
        #if listaNodosPersona!=[]:
        #    listatmp=set(listaNodosPersona)
            ##segundo nivel
        #    relPersona2=db((db.relPersona.is_active==True) & (db.relPersona.relacion==db.tipoRelacionP2P.id) & ((db.relPersona.origenP.belongs(listatmp)) | (db.relPersona.destinoP.belongs(listatmp)))).select(db.relPersona.origenP,db.relPersona.destinoP,num,db.tipoRelacionP2P.parent,
        #        groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
        #    for relation in relPersona2:
        #       listaNodosPersona.append(relation.relPersona.origenP)
        #        listaNodosPersona.append(relation.relPersona.destinoP)
        #        links.append(dict(source='P'+str(relation.relPersona.origenP),target='P'+str(relation.relPersona.destinoP),value=relation[num],grupo='P2P'+str(relation.tipoRelacionP2P.parent)))

        num=db.RelPersOrg.origenP.count()
        rel2Orgs=db((db.RelPersOrg.origenP==_id) & (db.RelPersOrg.is_active==True) &
                    (db.RelPersOrg.specificRelation==db.tipoRelacionP20.id) &
                    (db.RelPersOrg.destinoO==db.Organizacion.id) &
                    (db.Organizacion.is_active==True)).select(
                        db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,db.tipoRelacionP20.relationship,
                        groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
        for relation in rel2Orgs:
            listaNodosOrgs.append(relation.RelPersOrg.destinoO)
            links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num],grupo=relation.tipoRelacionP20.relationship))
        #if listaNodosOrgs!=[]:
        #    listatmp=set(listaNodosOrgs)
        #    rel2Orgs=db((db.RelPersOrg.destinoO.belongs(listatmp)) & (db.RelPersOrg.specificRelation==db.tipoRelacionP20.id) &(db.RelPersOrg.is_active==True)).select(db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,
        #        db.tipoRelacionP20.parent,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
        #    for relation in rel2Orgs:
        #        listaNodosPersona.append(relation.RelPersOrg.origenP)
        #        listaNodosOrgs.append(relation.RelPersOrg.destinoO)
        #        links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num],grupo='P20'+str(relation.tipoRelacionP20.parent)))
        #    num=db.relOrg2Org.origenO.count()
        #    relOrg2Orgs=db((db.relOrg2Org.is_active==True) & (db.relOrg2Org.relationOrg==db.tipoRelacionOrg2Org.id) & ((db.relOrg2Org.origenO.belongs(listatmp)) | (db.relOrg2Org.destinoO.belongs(listatmp)))).select(db.relOrg2Org.origenO,db.relOrg2Org.destinoO,num,
        #        db.tipoRelacionOrg2Org.parent, groupby=[db.relOrg2Org.origenO,db.relOrg2Org.destinoO],cache=(cache.ram,3600))
        #    for relation in relOrg2Orgs:
        #        listaNodosOrgs.append(relation.relOrg2Org.origenO)
        #        listaNodosOrgs.append(relation.relOrg2Org.destinoO)
        #        links.append(dict(source='O'+str(relation.relOrg2Org.origenO),target='O'+str(relation.relOrg2Org.destinoO),value=relation[num],grupo='O2O'+str(relation.tipoRelacionOrg2Org.parent)))



        if listaNodosPersona!=[]:
            c = Counter(listaNodosPersona)
            listatmp=set(listaNodosPersona)
            personas= db((db.persona.id.belongs(listatmp))).select(cache=(cache.ram,3600))
            for persona in personas:
                root='false'
                relevance=56
                imagen=URL('static','img/icono-persona56.png')
                shortBio=''
                if persona.depiction:
                    imagen=URL('default','fast_download',args=persona.depiction)
                if persona.shortBio:
                    shortBio=persona.shortBio.decode('utf-8')[:180]+'...'
                if persona.id==int(_id):
                    relevance=56
                    root='true'
                nodes.append(dict(name=persona.alias,shortBio=shortBio,group='persona',id="P"+str(persona.id),relevance=relevance,url=URL('personas','connections',args=convert_latin_chars(persona.alias)),root=root,imagen=imagen))

        if listaNodosOrgs!=[]:
            c = Counter(listaNodosOrgs)
            listatmp=set(listaNodosOrgs)
            orgs=db((db.Organizacion.is_active==True) & (db.Organizacion.id.belongs(listatmp))).select(cache=(cache.ram,3600))
            for org in orgs:
                imagen=URL('static','img/icono-organizaciones56.png')
                shortBio=''
                url=URL('organizaciones','connections',args=convert_latin_chars(org.alias))
                if org.tipoOrg==2:
                    imagen=URL('static','img/icono-empresas56.png')
                    group1='empresa'
                    url=URL('empresas','connections',args=convert_latin_chars(org.alias))
                else:
                    group1='organizacion'
                if org.haslogo:
                    imagen=URL('default','fast_download',args=org.haslogo)
                if org.shortBio:
                    shortBio=org.shortBio.decode('utf-8')[:180]+'...'
                #relevance=c[org.id]*100
                relevance=56
                nodes.append(dict(name=org.alias,shortBio=shortBio,group=group1, id="O"+str(org.id),relevance=relevance,url=url,root='false',imagen=imagen))

        #relPerOrgs=db((db.RelPersOrg.is_active==True) ).select()
    return dict(nodes=nodes,links=links)
Пример #37
0
def news():
    import random
    from conversion import convert_latin_chars

    if request.cid == None:
        redirect(URL("error", "error404"))
    alias = direccion = None
    lista = []
    short = None
    error = None

    aleatorio = random.randint(
        1, 2
    )  # 1 empresas 2 organizaciones 3 casos, como no hay casos solo se tiene que agregar mas adelante
    principal = (
        db(db.destacados.is_active == True)
        .select(orderby="destacados.fecha DESC", limitby=(0, 1), cache=(cache.ram, 15))
        .first()
    )
    secundarios = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC", limitby=(1, 3), cache=(cache.ram, 15)
    )
    carrusel = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC", limitby=(3, 9), cache=(cache.ram, 15)
    )
    resto = db(db.destacados.is_active == True).select(
        orderby="destacados.fecha DESC", limitby=(9, 13), cache=(cache.ram, 15)
    )

    personas = db(
        (db.persona.is_active == True)
        & (db.persona.shortBio != None)
        & (db.persona.shortBio != "")
        & (db.persona.depiction != None)
        & (db.persona.depiction != "")
    ).select(
        db.persona.alias,
        db.persona.shortBio,
        db.persona.depiction,
        db.persona.created_on,
        orderby=[~db.persona.modified_on],
        limitby=(0, 2),
    )

    organizacion = db(
        (db.Organizacion.is_active == True)
        & (db.Organizacion.shortBio != None)
        & (db.Organizacion.shortBio != "")
        & (db.Organizacion.haslogo != None)
        & (db.Organizacion.haslogo != "")
    ).select(
        db.Organizacion.id,
        db.Organizacion.tipoOrg,
        db.Organizacion.alias,
        db.Organizacion.shortBio,
        db.Organizacion.haslogo,
        db.Organizacion.created_on,
        orderby=[~db.Organizacion.modified_on],
        limitby=(0, 2),
    )

    url = {}
    for org in organizacion:
        url[org.id] = URL("organizaciones", "conexiones", args=convert_latin_chars(org.alias), extension=False)
        if org.tipoOrg == 2:
            url[org.id] = URL("empresas", "conexiones", args=convert_latin_chars(org.alias), extension=False)

    shortBio = {}
    for news in resto:

        if (news.referenceEntity != None) & (news.reference != None):
            shortBio[news.referenceEntity[:1] + "_" + str(news.reference)] = "maluenda"
            if news.referenceEntity == "persona":
                entity = db.persona(id=news.reference)
            elif (news.referenceEntity == "empresa") | (news.referenceEntity == "organizacion"):
                entity = db.Organizacion(id=news.reference)
            if entity != None:
                shortBio[news.referenceEntity[:1] + "_" + str(news.reference)] = p.sub("", entity.shortBio)[:184]

    if aleatorio == 1:
        random = (
            db((db.persona.is_active == True) & (db.persona.shortBio != ""))
            .select(db.persona.alias, orderby="<random>", limitby=(0, 1), cache=(cache.ram, 15))
            .first()
        )
        if random:
            direccion = URL("personas", "conexiones", args=convert_latin_chars(random.alias), extension=False)
    else:
        random = (
            db((db.Organizacion.is_active == True) & (db.Organizacion.shortBio != ""))
            .select(
                db.Organizacion.alias,
                db.Organizacion.tipoOrg,
                orderby="<random>",
                limitby=(0, 1),
                cache=(cache.ram, 15),
            )
            .first()
        )
        if random:
            direccion = URL("organizaciones", "conexiones", args=convert_latin_chars(random.alias), extension=False)
            if random.tipoOrg == 2:
                direccion = URL("empresas", "conexiones", args=convert_latin_chars(random.alias), extension=False)

    return dict(
        random=random,
        direccion=direccion,
        url=url,
        principal=principal,
        secundarios=secundarios,
        carrusel=carrusel,
        resto=resto,
        alias=lista,
        shortBio=shortBio,
        personas=personas,
        organizacion=organizacion,
    )
Пример #38
0
def orgs2all(_id=0,user_key='xxxxxxxx'):
    """

    :param _id:
    :return:
    """
    cid=request.cid or redirect(URL('error','error404.load'))
    from collections import Counter
    from conversion import convert_latin_chars
    error='OK'
    provider_key = 'c1f18606c752b4942771205b16a01249'
    #app_id = 'f8395cf0'
    #app_key = 'dd88190daab4754b60b77c5db71b4e96'
    nodes=[]; links=[]; PersonID={}; listaNodosPersona=[]; listaNodosOrgs=[]
    #import ThreeScalePY
    #authrep = ThreeScalePY.ThreeScaleAuthRepUserKey(provider_key, user_key)
    #if authrep.authrep():

    num = db.relPersona.origenP.count()
    if(_id!=0):
        listaNodosOrgs.append(_id)
        num=db.RelPersOrg.destinoO.count()
        rel2Orgs=db((db.RelPersOrg.destinoO==_id) & (db.RelPersOrg.is_active==True) & (db.RelPersOrg.origenP==db.persona.id) &
                    (db.persona.is_active==True) & (db.RelPersOrg.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)
                    ).select(db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
        for relation in rel2Orgs:
            listaNodosPersona.append(relation.RelPersOrg.origenP)
            links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num]))
        #if listaNodosPersona!=[]:
            #listatmp=set(listaNodosPersona)
            #rel2Orgs=db((db.RelPersOrg.origenP.belongs(listatmp)) & (db.RelPersOrg.is_active==True) & (db.RelPersOrg.origenP==db.persona.id) &
            #    (db.persona.is_active==True) & (db.RelPersOrg.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)).select(
            #    db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
            #for relation in rel2Orgs:
            #    listaNodosPersona.append(relation.RelPersOrg.origenP)
            #    listaNodosOrgs.append(relation.RelPersOrg.destinoO)
            #    links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num]))
            ##person2person
            #num=db.relPersona.destinoP.count()
            #listatmp=set(listaNodosPersona)
            #relPersona=db((db.relPersona.is_active==True) & ((db.relPersona.origenP.belongs(listatmp)) | (db.relPersona.destinoP.belongs(listatmp)))).select(db.relPersona.origenP,db.relPersona.destinoP,num,
            #    groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
            #for relation in relPersona:
            #    listaNodosPersona.append(relation.relPersona.origenP)
            #    listaNodosPersona.append(relation.relPersona.destinoP)
            #    links.append(dict(source='P'+str(relation.relPersona.origenP),target='P'+str(relation.relPersona.destinoP),value=relation[num]))




        num=db.relOrg2Org.origenO.count()
        relOrgs2Orgs=db((db.relOrg2Org.is_active==True) & ((db.relOrg2Org.origenO==_id) | (db.relOrg2Org.destinoO==_id)) &
                        (db.relOrg2Org.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)).select(db.relOrg2Org.origenO,db.relOrg2Org.destinoO,num,groupby=[db.relOrg2Org.origenO,db.relOrg2Org.destinoO],cache=(cache.ram,3600))
        for relation in relOrgs2Orgs:
            listaNodosOrgs.append(relation.relOrg2Org.origenO)
            listaNodosOrgs.append(relation.relOrg2Org.destinoO)
            links.append(dict(source='O'+str(relation.relOrg2Org.origenO),target='O'+str(relation.relOrg2Org.destinoO),value=relation[num]))

        #if listaNodosOrgs!=[]:
            #listatmp=set(listaNodosOrgs)
            #relOrg2Orgs=db((db.relOrg2Org.is_active==True) & ((db.relOrg2Org.origenO.belongs(listatmp)) | (db.relOrg2Org.destinoO.belongs(listatmp))) &
            #               (db.relOrg2Org.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)).select(db.relOrg2Org.origenO,db.relOrg2Org.destinoO,num,groupby=[db.relOrg2Org.origenO,db.relOrg2Org.destinoO],cache=(cache.ram,3600))
            #for relation in relOrg2Orgs:
            #    listaNodosOrgs.append(relation.relOrg2Org.origenO)
            #    listaNodosOrgs.append(relation.relOrg2Org.destinoO)
            #    links.append(dict(source='O'+str(relation.relOrg2Org.origenO),target='O'+str(relation.relOrg2Org.destinoO),value=relation[num]))

            #listatmp=set(listaNodosOrgs)
            #rel2Orgs=db((db.RelPersOrg.destinoO.belongs(listatmp)) & (db.RelPersOrg.is_active==True) & (db.RelPersOrg.origenP==db.persona.id) &
            #            (db.persona.is_active==True) & (db.RelPersOrg.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)
            #            ).select(db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
            #for relation in rel2Orgs:
            #    listaNodosOrgs.append(relation.RelPersOrg.destinoO)
            #    listaNodosPersona.append(relation.RelPersOrg.origenP)
            #    links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num]))




        if listaNodosPersona!=[]:
            c = Counter(listaNodosPersona)
            listatmp=set(listaNodosPersona)
            personas= db((db.persona.id.belongs(listatmp)) & (db.persona.is_active==True)).select(cache=(cache.ram,3600))
            for persona in personas:
                root='false'
                relevance = 56
                #relevance=c[persona.id]*100
                imagen=URL('static','img/icono-persona56.png')
                shortBio=''
                if persona.depiction:
                    imagen=URL('default','fast_download',args=persona.depiction)
                if persona.shortBio:
                    shortBio=persona.shortBio.decode('utf-8')[:180]+'...'
                nodes.append(dict(name=persona.alias,shortBio=shortBio,group='persona',id="P"+str(persona.id),relevance=relevance,url=URL('personas','connections',args=convert_latin_chars(persona.alias)),root=root,imagen=imagen))

        if listaNodosOrgs!=[]:
            c = Counter(listaNodosOrgs)
            listatmp=set(listaNodosOrgs)
            orgs=db((db.Organizacion.is_active==True) & (db.Organizacion.id.belongs(listatmp))).select(cache=(cache.ram,3600))
            for org in orgs:
                relevance = 56
                imagen=URL('static','img/icono-organizaciones56.png')
                shortBio=''
                url=URL('organizaciones','connections',args=convert_latin_chars(org.alias))
                if org.tipoOrg==2:
                    imagen=URL('static','img/icono-empresas56.png')
                    group1='empresa'
                    url=URL('empresas','connections',args=convert_latin_chars(org.alias))
                else:
                    group1='organizacion'
                if org.haslogo:
                    imagen=URL('default','fast_download',args=org.haslogo)
                if org.shortBio:
                    shortBio=org.shortBio.decode('utf-8')[:180]+'...'
                #relevance=c[org.id]*100
                nodes.append(dict(name=org.alias,shortBio=shortBio,group=group1, id="O"+str(org.id),relevance=relevance,url=url,root='false',imagen=imagen))

                #relPerOrgs=db((db.RelPersOrg.is_active==True) ).select()

                    # all was ok, proceed normally


    return dict(nodes=nodes,links=links)
Пример #39
0
def lo_ultimo():
    from conversion import convert_latin_chars

    entradas = []
    resultados = dict(
        title="Poderopedia",
        link="http://www.poderopedia.org",
        description="Poderopedia Lo Ultimo",
        created_on=str(request.now),
    )
    personas = db(
        (db.persona.is_active == True)
        & (db.persona.shortBio != None)
        & (db.persona.shortBio != "")
        & (db.persona.depiction != None)
        & (db.persona.depiction != "")
    ).select(
        db.persona.alias,
        db.persona.shortBio,
        db.persona.depiction,
        db.persona.modified_on,
        orderby=[~db.persona.modified_on],
        limitby=(0, 2),
    )

    for persona in personas:
        results = dict(
            title=persona.alias.decode("utf-8"),
            link=URL("personas", "conexiones", args=convert_latin_chars(persona.alias)),
            description=persona.shortBio.decode("utf-8"),
            created_on=str(persona.modified_on),
        )
        entradas.append(results)

    organizacion = db(
        (db.Organizacion.is_active == True)
        & (db.Organizacion.shortBio != None)
        & (db.Organizacion.shortBio != "")
        & (db.Organizacion.haslogo != None)
        & (db.Organizacion.haslogo != "")
    ).select(
        db.Organizacion.id,
        db.Organizacion.tipoOrg,
        db.Organizacion.alias,
        db.Organizacion.shortBio,
        db.Organizacion.haslogo,
        db.Organizacion.modified_on,
        orderby=[~db.Organizacion.modified_on],
        limitby=(0, 2),
    )

    for org in organizacion:
        args = convert_latin_chars(org.alias)
        link = URL("organizaciones", "conexiones", args=args)
        if org.tipoOrg == 2:
            link = URL("empresas", "conexiones", args=args)
        results = dict(
            title=org.alias.decode("utf-8"),
            link=link,
            description=org.shortBio.decode("utf-8"),
            created_on=str(org.modified_on),
        )
        entradas.append(results)
    entradas = sorted(entradas, key=lambda k: k["created_on"], reverse=True)
    resultados["entries"] = entradas
    response.headers["Content-Type"] = "application/rss+xml"
    return resultados
Пример #40
0
def orgs2all(_id=0,user_key='xxxxxxxx'):
    """

    :param _id:
    :return:
    """
    cid=request.cid or redirect(URL('error','error404.load'))
    from collections import Counter
    from conversion import convert_latin_chars
    error='OK'
    provider_key = 'c1f18606c752b4942771205b16a01249'
    #app_id = 'f8395cf0'
    #app_key = 'dd88190daab4754b60b77c5db71b4e96'
    nodes=[]; links=[]; PersonID={}; listaNodosPersona=[]; listaNodosOrgs=[]
    #import ThreeScalePY
    #authrep = ThreeScalePY.ThreeScaleAuthRepUserKey(provider_key, user_key)
    #if authrep.authrep():

    num = db.relPersona.origenP.count()
    if(_id!=0):
        listaNodosOrgs.append(_id)
        num=db.RelPersOrg.destinoO.count()
        rel2Orgs=db((db.RelPersOrg.destinoO==_id) & (db.RelPersOrg.is_active==True) & (db.RelPersOrg.origenP==db.persona.id) &
                    (db.persona.is_active==True) & (db.RelPersOrg.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)
                    ).select(db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
        for relation in rel2Orgs:
            listaNodosPersona.append(relation.RelPersOrg.origenP)
            links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num]))
        #if listaNodosPersona!=[]:
            #listatmp=set(listaNodosPersona)
            #rel2Orgs=db((db.RelPersOrg.origenP.belongs(listatmp)) & (db.RelPersOrg.is_active==True) & (db.RelPersOrg.origenP==db.persona.id) &
            #    (db.persona.is_active==True) & (db.RelPersOrg.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)).select(
            #    db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
            #for relation in rel2Orgs:
            #    listaNodosPersona.append(relation.RelPersOrg.origenP)
            #    listaNodosOrgs.append(relation.RelPersOrg.destinoO)
            #    links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num]))
            ##person2person
            #num=db.relPersona.destinoP.count()
            #listatmp=set(listaNodosPersona)
            #relPersona=db((db.relPersona.is_active==True) & ((db.relPersona.origenP.belongs(listatmp)) | (db.relPersona.destinoP.belongs(listatmp)))).select(db.relPersona.origenP,db.relPersona.destinoP,num,
            #    groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
            #for relation in relPersona:
            #    listaNodosPersona.append(relation.relPersona.origenP)
            #    listaNodosPersona.append(relation.relPersona.destinoP)
            #    links.append(dict(source='P'+str(relation.relPersona.origenP),target='P'+str(relation.relPersona.destinoP),value=relation[num]))




        num=db.relOrg2Org.origenO.count()
        relOrgs2Orgs=db((db.relOrg2Org.is_active==True) & ((db.relOrg2Org.origenO==_id) | (db.relOrg2Org.destinoO==_id)) &
                        (db.relOrg2Org.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)).select(db.relOrg2Org.origenO,db.relOrg2Org.destinoO,num,groupby=[db.relOrg2Org.origenO,db.relOrg2Org.destinoO],cache=(cache.ram,3600))
        for relation in relOrgs2Orgs:
            listaNodosOrgs.append(relation.relOrg2Org.origenO)
            listaNodosOrgs.append(relation.relOrg2Org.destinoO)
            links.append(dict(source='O'+str(relation.relOrg2Org.origenO),target='O'+str(relation.relOrg2Org.destinoO),value=relation[num]))

        #if listaNodosOrgs!=[]:
            #listatmp=set(listaNodosOrgs)
            #relOrg2Orgs=db((db.relOrg2Org.is_active==True) & ((db.relOrg2Org.origenO.belongs(listatmp)) | (db.relOrg2Org.destinoO.belongs(listatmp))) &
            #               (db.relOrg2Org.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)).select(db.relOrg2Org.origenO,db.relOrg2Org.destinoO,num,groupby=[db.relOrg2Org.origenO,db.relOrg2Org.destinoO],cache=(cache.ram,3600))
            #for relation in relOrg2Orgs:
            #    listaNodosOrgs.append(relation.relOrg2Org.origenO)
            #    listaNodosOrgs.append(relation.relOrg2Org.destinoO)
            #    links.append(dict(source='O'+str(relation.relOrg2Org.origenO),target='O'+str(relation.relOrg2Org.destinoO),value=relation[num]))

            #listatmp=set(listaNodosOrgs)
            #rel2Orgs=db((db.RelPersOrg.destinoO.belongs(listatmp)) & (db.RelPersOrg.is_active==True) & (db.RelPersOrg.origenP==db.persona.id) &
            #            (db.persona.is_active==True) & (db.RelPersOrg.destinoO==db.Organizacion.id) & (db.Organizacion.is_active==True)
            #            ).select(db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
            #for relation in rel2Orgs:
            #    listaNodosOrgs.append(relation.RelPersOrg.destinoO)
            #    listaNodosPersona.append(relation.RelPersOrg.origenP)
            #    links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num]))




        if listaNodosPersona!=[]:
            c = Counter(listaNodosPersona)
            listatmp=set(listaNodosPersona)
            personas= db((db.persona.id.belongs(listatmp)) & (db.persona.is_active==True)).select(cache=(cache.ram,3600))
            for persona in personas:
                root='false'
                relevance = 56
                #relevance=c[persona.id]*100
                imagen=URL('static','img/icono-persona56.png')
                shortBio=''
                if persona.depiction:
                    imagen=URL('default','fast_download',args=persona.depiction)
                if persona.shortBio:
                    shortBio=persona.shortBio.decode('utf-8')[:180]+'...'
                nodes.append(dict(name=persona.alias,shortBio=shortBio,group='persona',id="P"+str(persona.id),relevance=relevance,url=URL('personas','conexiones',args=convert_latin_chars(persona.alias)),root=root,imagen=imagen))

        if listaNodosOrgs!=[]:
            c = Counter(listaNodosOrgs)
            listatmp=set(listaNodosOrgs)
            orgs=db((db.Organizacion.is_active==True) & (db.Organizacion.id.belongs(listatmp))).select(cache=(cache.ram,3600))
            for org in orgs:
                relevance = 56
                imagen=URL('static','img/icono-organizaciones56.png')
                shortBio=''
                url=URL('organizaciones','conexiones',args=convert_latin_chars(org.alias))
                if org.tipoOrg==2:
                    imagen=URL('static','img/icono-empresas56.png')
                    group1='empresa'
                    url=URL('empresas','conexiones',args=convert_latin_chars(org.alias))
                else:
                    group1='organizacion'
                if org.haslogo:
                    imagen=URL('default','fast_download',args=org.haslogo)
                if org.shortBio:
                    shortBio=org.shortBio.decode('utf-8')[:180]+'...'
                #relevance=c[org.id]*100
                nodes.append(dict(name=org.alias,shortBio=shortBio,group=group1, id="O"+str(org.id),relevance=relevance,url=url,root='false',imagen=imagen))

                #relPerOrgs=db((db.RelPersOrg.is_active==True) ).select()

                    # all was ok, proceed normally


    return dict(nodes=nodes,links=links)
Пример #41
0
def lo_ultimo_rss():
    from conversion import convert_latin_chars

    response.view = "services/mas_popular_rss.html"
    entradas = []
    resultados = dict(
        title="Poderopedia ",
        link="http://www.poderopedia.org",
        description="Poderopedia | Lo último",
        created_on=request.now,
    )
    personas = db(
        (db.persona.is_active == True)
        & (db.persona.shortBio != None)
        & (db.persona.shortBio != "")
        & (db.persona.depiction != None)
        & (db.persona.depiction != "")
    ).select(
        db.persona.alias,
        db.persona.shortBio,
        db.persona.depiction,
        db.persona.modified_on,
        orderby=[~db.persona.modified_on],
        limitby=(0, 2),
    )

    for persona in personas:
        imagen = URL("static", "tmp/imagen-face.gif")
        if persona.depiction != "":
            imagen = URL("default", "fast_download", args=persona.depiction)
        media = dict(url="http://" + request.env.http_host + imagen, medium="image", width="140")
        results = dict(
            title=persona.alias,
            link=URL("personas", "connections", args=convert_latin_chars(persona.alias)),
            description=persona.shortBio[:184],
            created_on=persona.modified_on,
        )
        results["media:content"] = media
        entradas.append(results)

    organizacion = db(
        (db.Organizacion.is_active == True)
        & (db.Organizacion.shortBio != None)
        & (db.Organizacion.shortBio != "")
        & (db.Organizacion.haslogo != None)
        & (db.Organizacion.haslogo != "")
    ).select(
        db.Organizacion.id,
        db.Organizacion.tipoOrg,
        db.Organizacion.alias,
        db.Organizacion.shortBio,
        db.Organizacion.haslogo,
        db.Organizacion.modified_on,
        orderby=[~db.Organizacion.modified_on],
        limitby=(0, 2),
    )

    for org in organizacion:
        args = convert_latin_chars(org.alias)
        imagen = URL("static", "tmp/avatar-organizacion45.gif")
        link = URL("organizaciones", "connections", args=args)
        if org.tipoOrg == 2:
            imagen = URL("static", "tmp/avatar-empresa.png")
            link = URL("empresas", "connections", args=args)
        if org.haslogo != "":
            imagen = URL("default", "fast_download", args=org.haslogo)
        media = dict(url="http://" + request.env.http_host + imagen, medium="image", width="140")
        results = dict(title=org.alias, link=link, description=org.shortBio[:184], created_on=org.modified_on)
        results["media:content"] = media
    entradas.append(results)
    entradas = sorted(entradas, key=lambda k: k["created_on"], reverse=True)
    resultados["entries"] = entradas
    response.headers["Content-Type"] = "application/rss+xml"
    return dict(resultados=resultados, title="Lo ültimo", desc="Últimas actualizaciones en Poderopedia")
Пример #42
0
def mas_popular():
    if request.cid==None: redirect(URL('error','error404'))
    from conversion import convert_latin_chars
    result=[]; active={}; args=''
    active['hoy']=active['semana']=active['mes']=''
    imagen=None
    function='conexiones'
    if request.args(0)=='portada':
        active['hoy']='active'
        query=(db.plugin_stats.dia==request.now)
        if request.args(1)=='month':
            active['mes']='active'; active['hoy']=''
            query=(db.plugin_stats.month==int(request.now.strftime('%m')))& (db.plugin_stats.year==request.now.strftime('%Y'))
        elif request.args(1)=='week':
            active['semana']='active'; active['hoy']=''
            query=(db.plugin_stats.week==int(request.now.strftime('%W')))& (db.plugin_stats.year==request.now.strftime('%Y'))
        sum = db.plugin_stats.hits.sum()
        popular=db(db.plugin_stats.page_key.like('%conexiones%') & query).select(db.plugin_stats.hits,db.plugin_stats.page_key,sum,
            orderby=~sum,limitby=(0,5),groupby=db.plugin_stats.page_key,cache=(cache.ram,3600))

        response.view='services/mas_visto.load'
    else:
        popular=db((db.plugin_stats.page_key.like('%conexiones%')) & (db.plugin_stats.dia==request.now)).select(
            orderby=~db.plugin_stats.hits,limitby=(0,4),cache=(cache.ram,3600))

    for most in popular:
        if request.args(0)=='portada':
            page=most.plugin_stats.page_key.split('/')
            page_key=most.plugin_stats.page_key
        else:
            page=most.page_key.split('/')
            page_key=most.page_key
        largo=len(page)
        if 'personas' in page_key:
            if page[largo-1]:
                alias= page[largo-1].decode('utf-8').replace('_',' ')
                entity=db.persona(alias=alias, is_active=True)
                if entity!=None:
                    imagen=IMG(_alt=entity.alias,_src=URL('static','tmp/imagen-face.gif'), _width='140')
                    if (entity.depiction!=None) & (entity.depiction!=''):
                        imagen=IMG(_alt=entity.alias,_src=URL('default','fast_download',args=entity.depiction),
                                   _class='imagen-perfil-ch', _width='140')
                    args=convert_latin_chars(entity.alias)
                    alias=entity.alias
                controller='personas';
        elif ('organizaciones' in page_key) | ('empresas' in page_key):
            alias= page[largo-1].decode('utf-8').replace('_',' ').replace('-','.')
            entity=db.Organizacion(alias=alias,is_active=True)
            if entity!=None:
                imagen=IMG(_alt=entity.alias,_src=URL('static','tmp/avatar-organizacion45.gif'),
                           _class='imagen-perfil-ch', _width='100')
                controller='organizaciones'
                alias=entity.alias
                if entity.tipoOrg==2:
                    controller='empresas'
                    imagen=IMG(_alt=entity.alias,_src=URL('static','tmp/avatar-empresa.png'), _width='100')
                if (entity.haslogo!=None) & (entity.haslogo!=''):
                    imagen=IMG(_alt=entity.alias,_src=URL('default','fast_download',args=entity.haslogo),
                               _class='imagen-perfil-ch', _width='90', _heigth='80')
                args=convert_latin_chars(entity.alias)



        shortBio=''
        if entity!=None:
            if entity.shortBio!=None:
                shortBio=entity.shortBio
        else:
            redirect(URL('error','error404'))

        result.append(dict(alias=alias,c=controller,f=function,args=args,imagen=imagen,shortBio=shortBio))

    return dict(popular=result, active=active)
Пример #43
0
def mas_popular_rss():
    from conversion import convert_latin_chars

    entradas = []
    resultados = dict(
        title="Más Popular Hoy | Poderopedia",
        link="http://www.poderopedia.org",
        description="Poderopedia | Más Popular",
        created_on=str(request.now),
    )
    query = (db.plugin_stats.month == int(request.now.strftime("%m"))) & (
        db.plugin_stats.year == request.now.strftime("%Y")
    )
    sum = db.plugin_stats.hits.sum()
    popular = db(db.plugin_stats.page_key.like("%connections%") & query).select(
        db.plugin_stats.hits,
        db.plugin_stats.page_key,
        sum,
        orderby=~sum,
        limitby=(0, 2),
        groupby=db.plugin_stats.page_key,
        cache=(cache.ram, 3600),
    )

    for most in popular:
        page = most.plugin_stats.page_key.split("/")
        page_key = most.plugin_stats.page_key
        largo = len(page)
        if "personas" in page_key:
            if page[largo - 1]:
                alias = page[largo - 1].decode("utf-8").replace("_", " ")
                entity = db.persona(alias=alias, is_active=True)
                if entity != None:
                    imagen = URL("static", "tmp/imagen-face.gif")
                    if (entity.depiction != None) & (entity.depiction != ""):
                        imagen = URL("default", "fast_download", args=entity.depiction)

                    args = convert_latin_chars(entity.alias)
                    alias = entity.alias
                controller = "personas"
        elif ("organizaciones" in page_key) | ("empresas" in page_key):
            alias = page[largo - 1].decode("utf-8").replace("_", " ").replace("-", ".")
            entity = db.Organizacion(alias=alias, is_active=True)
            if entity != None:
                imagen = URL("static", "tmp/avatar-organizacion45.gif")

                controller = "organizaciones"
                alias = entity.alias
                if entity.tipoOrg == 2:
                    controller = "empresas"
                    imagen = URL("static", "tmp/avatar-empresa.png")
                if (entity.haslogo != None) & (entity.haslogo != ""):
                    imagen = URL("default", "fast_download", args=entity.haslogo)

                args = convert_latin_chars(entity.alias)

        media = dict(url="http://" + request.env.http_host + imagen, medium="image", width="140")
        results = dict(
            title=alias,
            link=URL(controller, "connections", args=args, extension=False),
            description=entity.shortBio[:184],
            created_on=entity.modified_on,
        )
        results["media:content"] = media
        entradas.append(results)
    resultados["entries"] = entradas
    response.headers["Content-Type"] = "application/rss+xml"

    return dict(resultados=resultados, title="Más Popular Ahora", desc="Lo más popular en Poderopedia")
Пример #44
0
def persona2all(_id=0):
    from conversion import convert_latin_chars
    from collections import Counter

    nodes=[]; links=[]; PersonID={}; listaNodosPersona=[]; listaNodosOrgs=[]

    if id!=0:
        listaNodosPersona.append(_id)
        relFamiliar=db(((db.relFamiliar.origenP==_id) | (db.relFamiliar.destinoP==_id)) & (db.relFamiliar.is_active==True)
                       & (db.relFamiliar.parentesco==db.tipoParentesco.id)
                       & (db.relFamiliar.origenP==db.persona.id) & (db.persona.is_active==True)
        ).select(
            db.relFamiliar.origenP,db.relFamiliar.destinoP, db.tipoParentesco.name,
            cache=(cache.ram,3600)
        )
        for relation in relFamiliar:
            person=db(db.persona.id==relation.relFamiliar.destinoP).select(cache=(cache.ram,3600)).first()
            if person.is_active:
                listaNodosPersona.append(relation.relFamiliar.origenP)
                listaNodosPersona.append(relation.relFamiliar.destinoP)
                links.append(dict(
                    source='P'+str(relation.relFamiliar.origenP),
                    target='P'+str(relation.relFamiliar.destinoP),
                    value="1",
                    grupo='Familiar'
                ))
        ##person2person
        num = db.relPersona.origenP.count()
        relPersona=db((db.relPersona.is_active==True) & ((db.relPersona.origenP==_id) | (db.relPersona.destinoP==_id))
                      & (db.relPersona.relacion==db.tipoRelacionP2P.id)).select(
                            db.relPersona.origenP,db.relPersona.destinoP,num,db.tipoRelacionP2P.name,
                            groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
        for relation in relPersona:
            listaNodosPersona.append(relation.relPersona.origenP)
            listaNodosPersona.append(relation.relPersona.destinoP)
            links.append(dict(source='P'+str(relation.relPersona.origenP),target='P'+str(relation.relPersona.destinoP),value=relation[num], grupo=relation.tipoRelacionP2P.name))
        #if listaNodosPersona!=[]:
        #    listatmp=set(listaNodosPersona)
            ##segundo nivel
        #    relPersona2=db((db.relPersona.is_active==True) & (db.relPersona.relacion==db.tipoRelacionP2P.id) & ((db.relPersona.origenP.belongs(listatmp)) | (db.relPersona.destinoP.belongs(listatmp)))).select(db.relPersona.origenP,db.relPersona.destinoP,num,db.tipoRelacionP2P.parent,
        #        groupby=[db.relPersona.origenP,db.relPersona.destinoP],cache=(cache.ram,3600))
        #    for relation in relPersona2:
        #       listaNodosPersona.append(relation.relPersona.origenP)
        #        listaNodosPersona.append(relation.relPersona.destinoP)
        #        links.append(dict(source='P'+str(relation.relPersona.origenP),target='P'+str(relation.relPersona.destinoP),value=relation[num],grupo='P2P'+str(relation.tipoRelacionP2P.parent)))

        num=db.RelPersOrg.origenP.count()
        rel2Orgs=db((db.RelPersOrg.origenP==_id) & (db.RelPersOrg.is_active==True) &
                    (db.RelPersOrg.specificRelation==db.tipoRelacionP20.id) &
                    (db.RelPersOrg.destinoO==db.Organizacion.id) &
                    (db.Organizacion.is_active==True)).select(
                        db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,db.tipoRelacionP20.relationship,
                        groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
        for relation in rel2Orgs:
            listaNodosOrgs.append(relation.RelPersOrg.destinoO)
            links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num],grupo=relation.tipoRelacionP20.relationship))
        #if listaNodosOrgs!=[]:
        #    listatmp=set(listaNodosOrgs)
        #    rel2Orgs=db((db.RelPersOrg.destinoO.belongs(listatmp)) & (db.RelPersOrg.specificRelation==db.tipoRelacionP20.id) &(db.RelPersOrg.is_active==True)).select(db.RelPersOrg.origenP,db.RelPersOrg.destinoO,num,
        #        db.tipoRelacionP20.parent,groupby=[db.RelPersOrg.origenP,db.RelPersOrg.destinoO],cache=(cache.ram,3600))
        #    for relation in rel2Orgs:
        #        listaNodosPersona.append(relation.RelPersOrg.origenP)
        #        listaNodosOrgs.append(relation.RelPersOrg.destinoO)
        #        links.append(dict(source='P'+str(relation.RelPersOrg.origenP),target='O'+str(relation.RelPersOrg.destinoO),value=relation[num],grupo='P20'+str(relation.tipoRelacionP20.parent)))
        #    num=db.relOrg2Org.origenO.count()
        #    relOrg2Orgs=db((db.relOrg2Org.is_active==True) & (db.relOrg2Org.relationOrg==db.tipoRelacionOrg2Org.id) & ((db.relOrg2Org.origenO.belongs(listatmp)) | (db.relOrg2Org.destinoO.belongs(listatmp)))).select(db.relOrg2Org.origenO,db.relOrg2Org.destinoO,num,
        #        db.tipoRelacionOrg2Org.parent, groupby=[db.relOrg2Org.origenO,db.relOrg2Org.destinoO],cache=(cache.ram,3600))
        #    for relation in relOrg2Orgs:
        #        listaNodosOrgs.append(relation.relOrg2Org.origenO)
        #        listaNodosOrgs.append(relation.relOrg2Org.destinoO)
        #        links.append(dict(source='O'+str(relation.relOrg2Org.origenO),target='O'+str(relation.relOrg2Org.destinoO),value=relation[num],grupo='O2O'+str(relation.tipoRelacionOrg2Org.parent)))



        if listaNodosPersona!=[]:
            c = Counter(listaNodosPersona)
            listatmp=set(listaNodosPersona)
            personas= db((db.persona.id.belongs(listatmp))).select(cache=(cache.ram,3600))
            for persona in personas:
                root='false'
                relevance=56
                imagen=URL('static','img/icono-persona56.png')
                shortBio=''
                if persona.depiction:
                    imagen=URL('default','fast_download',args=persona.depiction)
                if persona.shortBio:
                    shortBio=persona.shortBio.decode('utf-8')[:180]+'...'
                if persona.id==int(_id):
                    relevance=56
                    root='true'
                nodes.append(dict(name=persona.alias,shortBio=shortBio,group='persona',id="P"+str(persona.id),relevance=relevance,url=URL('personas','conexiones',args=convert_latin_chars(persona.alias)),root=root,imagen=imagen))

        if listaNodosOrgs!=[]:
            c = Counter(listaNodosOrgs)
            listatmp=set(listaNodosOrgs)
            orgs=db((db.Organizacion.is_active==True) & (db.Organizacion.id.belongs(listatmp))).select(cache=(cache.ram,3600))
            for org in orgs:
                imagen=URL('static','img/icono-organizaciones56.png')
                shortBio=''
                url=URL('organizaciones','conexiones',args=convert_latin_chars(org.alias))
                if org.tipoOrg==2:
                    imagen=URL('static','img/icono-empresas56.png')
                    group1='empresa'
                    url=URL('empresas','conexiones',args=convert_latin_chars(org.alias))
                else:
                    group1='organizacion'
                if org.haslogo:
                    imagen=URL('default','fast_download',args=org.haslogo)
                if org.shortBio:
                    shortBio=org.shortBio.decode('utf-8')[:180]+'...'
                #relevance=c[org.id]*100
                relevance=56
                nodes.append(dict(name=org.alias,shortBio=shortBio,group=group1, id="O"+str(org.id),relevance=relevance,url=url,root='false',imagen=imagen))

        #relPerOrgs=db((db.RelPersOrg.is_active==True) ).select()
    return dict(nodes=nodes,links=links)