[web2py] Re: Please help me to design my database structure

2013-09-10 Thread Andreas Wienes
Each steps from table project_type_step should be copied to table 
project_step, after creating a new project through the form.

Am Dienstag, 10. September 2013 11:16:33 UTC+2 schrieb Luc Chase:
>
> You want to copy all the steps... then mark each as it is done? Or are you 
> wanting to create each done project_step record only after it is done?
>
>
>
> On Tuesday, 10 September 2013 00:02:40 UTC+1, Andreas Wienes wrote:
>>
>> Thanks for your advice! I corrected the small error and created the new 
>> table. Now I'm trying to copy the steps for a specific project_type to a 
>> new created project.
>>
>> I tried the following:
>>
>> def start():
>> form = SQLFORM(db.project).process()
>> if form.accepted:
>> project_type = form.vars.project_type
>> for row in db(db.step.project_type_id==project_type).select():
>> # copy each step to the project_step table
>>
>> redirect(URL('index', args=form.vars.project_type))
>> return locals()
>>
>> But I don't know how to copy from one table to another. Any ideas?
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Please help me to design my database structure

2013-09-10 Thread Luc Chase
You want to copy all the steps... then mark each as it is done? Or are you 
wanting to create each done project_step record only after it is done?



On Tuesday, 10 September 2013 00:02:40 UTC+1, Andreas Wienes wrote:
>
> Thanks for your advice! I corrected the small error and created the new 
> table. Now I'm trying to copy the steps for a specific project_type to a 
> new created project.
>
> I tried the following:
>
> def start():
> form = SQLFORM(db.project).process()
> if form.accepted:
> project_type = form.vars.project_type
> for row in db(db.step.project_type_id==project_type).select():
> # copy each step to the project_step table
>
> redirect(URL('index', args=form.vars.project_type))
> return locals()
>
> But I don't know how to copy from one table to another. Any ideas?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Please help me to design my database structure

2013-09-09 Thread Luc Chase
You have thought of the correct solution ( I would call it project_steps ) 
.  




On Monday, 9 September 2013 17:12:04 UTC+1, Andreas Wienes wrote:
>
> Hello,
>
> I've three models called project, project_type and steps.
>
> A project belongs to a certain project_type and depending on what kind of 
> project it is, includes different steps. For example "writing a book" is a 
> new project and belongs to the project_type "hobby project".
>  
> "making a plan" and "get feedback" are steps for a "hobby project".  So 
> the project "writing a book" should contain this steps.
>
> *My question:*
> After creating a second project and saying it's also a "hobby project" the 
> new project is connected to the same steps like my first project. And if I 
> modify anything in a step, like mark "making a plan" as completed, it's 
> also completed for any other project. You can imagine that this is not what 
> I want to do.
>
> How can I create several steps for a new project, based on which 
> project_type it is?
>
> I thought about creating a new table "project-with-steps" and insert the 
> project_id and each project_steps for the project_type into it, but maybe 
> there is a smarter solution? 
>
> This is my current database definition:
>
> db.define_table('project_type',
> Field('title', notnull=True, unique=True),
> Field('description', 'text', notnull=True),
> format='%(title)s')
>
> db.define_table('project',
> Field('name', notnull=True),
> Field('description', 'text', notnull=True),
> Field('project_type', db.project_type, notnull=True),
> format='%(name)s')
>
> db.define_table('step',
> Field('title',  notnull=True, unique=True),
> Field('description', 'text', notnull=True),
> Field('project_id', db.project),
> format='%(title)s')
>
>
> db.define_table('project_type_with_steps',
> Field('type_id', db.project_type),
> Field('step_id', db.step))
>
>
>
>
> Thanks for your help!
> Andreas
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Please help me to design my database structure

2013-09-09 Thread Andreas Wienes
Thanks for your advice! I corrected the small error and created the new 
table. Now I'm trying to copy the steps for a specific project_type to a 
new created project.

I tried the following:

def start():
form = SQLFORM(db.project).process()
if form.accepted:
project_type = form.vars.project_type
for row in db(db.step.project_type_id==project_type).select():
# copy each step to the project_step table

redirect(URL('index', args=form.vars.project_type))
return locals()

But I don't know how to copy from one table to another. Any ideas?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.