I created a custom profile view so that the user can create/update his
profile. Currently I have something like:
models/db.py:
db.define_table('images',
Field('image', 'upload', requires = IS_EMPTY_OR(IS_IMAGE()))
auth.settings.extra_fields['auth_user'] = [
Field('user_image', 'reference images', requires=IS_NULL_OR(IS_IN_DB(db,db
.images.id)))
]
controller/default.py:
def user():
return dict(form=auth())
view (for editing):
{{=form.custom.begin}}
...
<span> Your Image: </span>
{{=form.custom.widget.user_image}}
{{=form.custom.end}}
The problem is {{=form.custom.widget.user_image}} will render a dropdown of
all image ids that are in the images table. Instead, I want a file upload,
so that the user can change the image and it will be reflected in the
database. How would I change the form to do this?
Also, since an image doesn't initially exist for a user, web2py will have
to first do the insert into the image table, and then update/insert it to
the auth_user table. The other problem is if a user decides to change his
user picture, then web2py has to deal with deleting the old picture in the
database *and *on the filesystem.
How can I handle these problems in web2py?
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.