[web2py] Re: Simple loan system for library

2014-05-24 Thread john smith
I'm very new to this, so I'm not sure if I understand the 'foreign key' 
concept, but from what I understand
Field('copies', db.copies),
would be my foreign key reference. Now that i thought about it, it should 
probably go the other way since I want one book to have many copies. But I 
would still like to create many copies while creating a book and while 
modifying it. 
If by attributes you mean fields then it will probably get attribute like 
'state' that will describe whether the copy was damaged or lost, and it 
might get something else but nothing comes to my mind right now. If that is 
not what you meant, then I have no idea. 
I should add that this is a school project so I can change it pretty much 
any way I like it. If you have better idea on how to create renting system 
then please do tell.

W dniu sobota, 24 maja 2014 04:51:00 UTC+2 użytkownik Andrew W napisał:

 Hi John,
 One step at a time, looking at your database model,  how does 'copies' 
 relate to a book ?  You are missing a foreign key reference.   Are there 
 any other attributes that a copy may have ?


 On Saturday, May 24, 2014 7:30:35 AM UTC+10, john smith wrote:

 I'm trying to create library system and have a little problem. Here's my 
 current model:
 db.define_table('tags', 
 Field('name'),format='%(name)s') 
 db.define_table('copies',
 Field('is_active','boolean',default=True))

 db.define_table('book',
 Field('title',requires=IS_NOT_EMPTY(), label='Tytuł'),
 Field('author', requires=IS_NOT_EMPTY(), label='Autor'),
 Field('isbn', 'integer', requires=IS_LENGTH(13), label='ISBN'),
 Field('release_year', 'integer', requires=IS_INT_IN_RANGE(-3000, 
 request.utcnow.year+1), label='Rok wydania'),
 Field('format', label='Format'),
 Field('cover', 'upload', requires = IS_EMPTY_OR(IS_IMAGE()), 
 label='Okładka'),
 Field('publisher', label='Wydawca'),
 Field('tags', 'list:reference tags', label='Tagi'), 
 Field('copies', db.copies),
 auth.signature)

 db.book.tags.widget = SQLFORM.widgets.checkboxes.widget

 Here is what I want to achieve: when a user adds new 'book' table record, 
 he types number of copies of that book and that amount of records is 
 automatically created in 'copies' table. Then a user will be able to loan a 
 specific copy of a book (i will probably be able to figure this part out 
 thanks to library example) but only for specific period. If you have other 
 ideas on how to solve my problem, please share.
 Also less important but i would like to change the style of my tags 
 widget, so it would display either set number of tags per row or just 
 display maximum number that will fit in screen.
 Thanks in advance for all replies.



-- 
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/d/optout.


[web2py] Re: Simple loan system for library

2014-05-23 Thread Andrew W
Hi John,
One step at a time, looking at your database model,  how does 'copies' 
relate to a book ?  You are missing a foreign key reference.   Are there 
any other attributes that a copy may have ?


On Saturday, May 24, 2014 7:30:35 AM UTC+10, john smith wrote:

 I'm trying to create library system and have a little problem. Here's my 
 current model:
 db.define_table('tags', 
 Field('name'),format='%(name)s') 
 db.define_table('copies',
 Field('is_active','boolean',default=True))

 db.define_table('book',
 Field('title',requires=IS_NOT_EMPTY(), label='Tytuł'),
 Field('author', requires=IS_NOT_EMPTY(), label='Autor'),
 Field('isbn', 'integer', requires=IS_LENGTH(13), label='ISBN'),
 Field('release_year', 'integer', requires=IS_INT_IN_RANGE(-3000, 
 request.utcnow.year+1), label='Rok wydania'),
 Field('format', label='Format'),
 Field('cover', 'upload', requires = IS_EMPTY_OR(IS_IMAGE()), 
 label='Okładka'),
 Field('publisher', label='Wydawca'),
 Field('tags', 'list:reference tags', label='Tagi'), 
 Field('copies', db.copies),
 auth.signature)

 db.book.tags.widget = SQLFORM.widgets.checkboxes.widget

 Here is what I want to achieve: when a user adds new 'book' table record, 
 he types number of copies of that book and that amount of records is 
 automatically created in 'copies' table. Then a user will be able to loan a 
 specific copy of a book (i will probably be able to figure this part out 
 thanks to library example) but only for specific period. If you have other 
 ideas on how to solve my problem, please share.
 Also less important but i would like to change the style of my tags 
 widget, so it would display either set number of tags per row or just 
 display maximum number that will fit in screen.
 Thanks in advance for all replies.


-- 
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/d/optout.