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.