No, multiplicity is not a mental condition, but I am having trouble
learning how to make a statement that brings to tables together.
I have three tables I am working with.
"Tags","Users", and "User_tags"
I want to see the users that have the same tags as the user that is
logged in with auth, and what tag they are bound together with.
Here is the code of the tables...
---MODEL---
db.define_table('users',
SQLField('first_name', 'string', length=15),
SQLField('last_name', 'string', length=15),
SQLField('phone_number', 'string', length=15),
SQLField('email', 'string'),
SQLField('password', 'password'),
SQLField('university_affiliation', 'string', length=25),
SQLField('created', 'datetime', default=now, readable=False,
writable=False),
SQLField('registration_key', length=128, writable=False,
readable=False, default=''),
SQLField('avatar', 'upload'),
SQLField('short_description','text'))
db.define_table('tag',
SQLField('name', 'string'),
SQLField('description', 'text'),
SQLField('logo', 'upload'),
SQLField('created', 'date', default=now, writable=False),
SQLField('creator', 'string', writable=False))
db.define_table('user_tags',
SQLField('tag_id',db.tag),
SQLField('user_id',db.users))
db.user_tags.tag_id.requires = IS_IN_DB(db,'tag.id')
db.user_tags.user_id.requires = IS_IN_DB(db,'users.id')
db.users.first_name.requires = IS_NOT_EMPTY()
db.users.last_name.requires = IS_NOT_EMPTY()
db.users.password.requires = CRYPT()
db.users.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db,'users.email')]
db.users.created.requires = IS_NOT_EMPTY()
db.tag.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db,'tag.name')]
db.tag.description.requires = IS_NOT_EMPTY()
db.tag.logo.requires = IS_NOT_EMPTY()
db.tag.created.requires = IS_NOT_EMPTY()
#Special condition to default to the current user.
if auth.user:
user_id=auth.user.email
else: user_id=0
db.tag.creator.default=user_id
Thanks for the help,
Jason Brower
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---