Hi Alan and Anthony,

Thanks for your replies. This solution partially solved the problem:

db.NodeRelatedCard.targetID.represent = lambda targetID, row:
db(db.Organization.nodeID == targetID).select().first().name

In appadmin the targetID is now represented by the name of the
organization, however, in the following delete form
the targetID is still the id:

@auth.requires(auth.has_membership(VCARD) or
auth.has_membership(ROOT))
def relatedcards():
    id=auth.user.nodeID
    db.NodeRelatedCard.sourceID.default=id
 
rows=db((db.NodeRelatedCard.sourceID==id)&(db.NodeRelatedCard.targetID==db.Organization.id))
\
    
.select(db.NodeRelatedCard.ALL,db.Organization.name,orderby=db.Organization.name)
    if not rows:
        if not response.flash: response.flash='No related cards in
database'
    else:
        if not response.flash: response.flash='Related cards in
database'
        if len(request.args):
            if request.args(0)=='delete':
 
row=db(db.NodeRelatedCard.id==request.args(1)).select().first()
                response.flash='Delete related card'
                message='Related card deleted'
 
form=crud.update(table=db.NodeRelatedCard,record=row,message=message,deletable=True)
            form[0][-1]
[1].append(INPUT(_type="button",_value="Cancel",_onclick='javascript:history.go(-1);'))
    return dict(form=form,rows=rows)


Adding this:

db.NodeRelatedCard.targetID.represent=lambda targetID, row:
db(db.Organization.nodeID==targetID).select().first().name

after:

db.NodeRelatedCard.sourceID.default=id

doesn't make any difference. What's wrong with the function above?


Kind regards,

Annet.

Reply via email to