With a bit of effort I rebuilt it to work by meerging my code with the
documentation found in the manual. Ish... lots of work... but for the
sake of showing it to others, here you go.
Thank you for the book. It was the big saver in all this.
---
BR,
Jason
On Wed, 2010-05-12 at 21:05 -0700, mdipierro wrote:
> Not sure this should have ever worked. It needs
>
> This:
> self.settings.table_user = db.users
> should be:
> self.settings.table_user_name = 'users'
>
> Honestly I have not tested much what happens if you rename the
> auth_user table. Please let us know if you encouter ther problems.
>
>
> On May 12, 10:19 pm, Jason Brower <[email protected]> wrote:
> > It used to work back in the day. But it doesn't seem to be working now.
> > Any idea on what I would be doing wrong?
> > This is my model and the view is below when I try to register. As you
> > can see they don't go together. :/ For example, I should have university
> > affiliation there in the view. Any ideas what I did wrong here?
> > ---
> > Best Regards,
> > Jason Brower
> >
> > Screenshot.png
> > 117KViewDownload
> >
> > example-db.py
> > 2KViewDownload
from datetime import datetime, date, time
now = datetime.utcnow()
today = date.today()
db = SQLDB('sqlite://interestID.db')
#######################################
# Authentication System
#######################################
from gluon.tools import Mail, Auth
mail = Mail()
mail.settings.server='smtp.gmail.com:587'
mail.settings.sender= '[email protected]'
mail.settings.login='[email protected]:----'
auth = Auth(globals(), db)
# after
# auth = Auth(globals(),db)
auth_table = db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('email', length=128, default='', unique=True),
Field('password', 'password', length=256,
readable=False, label='Password'),
Field('registration_key', length=128, default= '',
writable=False, readable=False),
Field('nickname', 'string', length=20),
Field('phone_number', 'string', length=15),
Field('university_affiliation', 'string', length=25),
Field('created', 'datetime', default=now, readable=False, writable=False),
Field('avatar', 'upload'),
Field('short_description','text'),
Field('sex','text')
)
auth_table.first_name.requires = \
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.last_name.requires = \
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
auth_table.password.requires = [IS_STRONG(), CRYPT()]
auth_table.email.requires = [
IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, auth_table.email)]
auth.settings.table_user = auth_table
auth_table.nickname.requires = IS_NOT_IN_DB(db,'auth_users.nickname')
auth_table.created.requires = IS_NOT_EMPTY()
auth_table.sex.requires = IS_IN_SET(["Male","Female","Unset"])
# before
# auth.define_tables()
auth.settings.mailer = mail
auth.define_tables()
db.define_table('tag',
Field('name', 'string'),
Field('description', 'text'),
Field('logo', 'upload'),
Field('created', 'date', default=now, writable=False),
Field('creator', 'string', writable=False))
db.define_table('user_tags',
Field('tag_id',db.tag),
Field('user_id', auth_table))
db.define_table('user_photos',
Field('photo', 'upload'),
Field('description', 'text'),
Field('tag', db.tag),
Field('date_added', 'datetime', default=request.now, readable=False, writable=False))
db.user_photos.tag.requires = IS_IN_DB(db, db.tag.id, '%(name)s')
db.user_tags.tag_id.requires = IS_IN_DB(db,'tag.id')
db.user_tags.user_id.requires = IS_IN_DB(db,'auth_users.id')
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