Need some help in deploying Marin's advice.

To actually select a record is difficult for me to conceptualize. Is it 
possible to leverage a grid to do the selection, and also provide prompts 
for the displayName fields?

Here's a sample of my idea below.  Can this be fixed so it works?

thanks,

Alex

def convert_suggestion_to_a_proposal(): ## 
    grid = SQLFORM.smartgrid(db.Suggestion , 
linked_tables=['Proposal','Idea','ObjectSuperType']), 
    suggestion = db.Suggestion.id
    idea = db.Idea[suggestion.ideaID]
    ## idea_object_id = db.ObjectSuperType.insert(objectdisplayName = 'type 
in Object name here')
    ## proposal_object_id = db.ObjectSuperType.insert(objectdisplayName = 
'type in Proposal name here')
    new_idea_id = db.Idea.insert(objectID = idea_object_id, ideaTitle = 
idea.ideaTitle) #copy title from old one
    ## Do the same for proposal:
    new_proposal_id = db.Proposal.insert(objectID = proposal_object_id, 
ideaID = new_idea_id, suggestionID = suggestion.id)
    return dict(grid=grid)



On Wednesday, June 5, 2013 9:48:07 AM UTC-7, Marin Pranjić wrote:
>
> Hi Alex.
>
> So, somehow user selects a record from table Suggestions.
>
> suggestion = db.Suggestion[<suggestion id here>] 
>
> then you can get an Idea:
>
> idea = db.Idea[suggestion.ideaID] 
>
> Then you create an object for new idea:
>
>  idea_object_id = db.ObjectSuperType.insert(objectdisplayName = '<object 
> display here>')
>
> Then, create an object for new proposal:
>
> proposal_object_id = db.ObjectSuperType.insert(objectdisplayName = '<object 
> display here>')
>
> Create new idea from old one, with new object:
>
> new_idea_id = db.Idea.insert(objectID = idea_object_id, ideaTitle = 
> idea.ideaTitle) #copy title from old one
>
> Do the same for proposal:
>
> new_proposal_id = db.Proposal.insert(objectID = proposal_object_id, ideaID 
> = new_idea_id, suggestionID = suggestion.id)
>
> Hope this helps. Later you can merge first two queries in one with a join:
>
> row = db(db.Suggestion.id == <suggestion id here>)(db.Suggestion.ideaID 
> == db.Idea.id).select().first()
> suggestion = row.Suggestion
> idea = row.Idea
>
>
> Marin
>
>
>
> Dana srijeda, 5. lipnja 2013. 18:20:30 UTC+2, korisnik Alex Glaros napisao 
> je:
>>
>> I want user to:
>>
>>
>>    1. search "Suggestion" table along with its linked table "Idea". Once 
>>    they select one specific Suggestion record (linked to specific "Idea" 
>>    record):
>>    2. FOR TABLE "IDEA": copy field "ideaTitle" from table "Idea" (old 
>>    selected record) and paste it into a new record in table "Idea" with a 
>> new 
>>    (incremented from parent ObjectSupertype) number for field "objectID" 
>>    3. FOR TABLE "PROPOSAL": copy the new "ideaID" from table "Idea", and 
>>    the new "objectID" from parent table "ObjectSuperType"
>>    
>>
>> To summarize:
>>
>>
>>    1. parent table ObjectSuperType increments twice, i.e., creates two 
>>    new ID numbers, one for the new record in "Proposal" table and a 
>> different 
>>    one for the new record in "Idea" table.  
>>    2. The new record in "Idea" table copies field "ideaTitle" from the 
>>    old, selected-by-user record in "Idea" table (plus it gets a new 
>> objectID). 
>>    3. The new record in "Proposal" table gets the related "ideaID" 
>>    number that links it to the new "Idea" table record, and a new "objectID" 
>>    number from table "ObjectSuperType" that is different than the "objectID" 
>>    field in the "Idea" table" 
>>    
>>
>> Any example would be deeply appreciated!
>>
>> db.define_table('ObjectSuperType',  ## Super-type over Party and 
>> components.  Can be person, organization, project, program, business 
>> process, anything.
>>     Field('objectdisplayName','string', label='Object Name'))
>>
>>
>> db.define_table('Suggestion', 
>> Field('ideaID', 'reference Idea',label='Suggestion Idea ID'))
>>
>>
>> db.define_table('Idea',
>> Field('ideaTitle','string', length=140, comment='140 characters max'),
>> Field('objectID', 'reference ObjectSuperType'))
>>
>>
>> db.define_table('Proposal',Field('suggestionID','reference Suggestion'), 
>> ## can be null
>> Field('ideaID', 'reference Idea',label='Proposal Idea ID'), 
>> Field('objectID', 'reference ObjectSuperType'))
>>
>>
>>
>> Alex Glaros
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to