I'm not sure about questions 1 and 2, but for 3 and 4...
3. Look at SQLFORM.grid in the book
-
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid
4. You wouldn't add them to 'membership' admin, but to 'group' admin.
Something like db.auth_membership.insert(userid=999, group_id=1234) where
999 is the id of the user and 1234 is the id of the Admin group. See here:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#insert
for more info on inserting records and
here:
http://web2py.com/books/default/chapter/29/09/access-control#Authorization
for more info on authentication and authorization.
-Jim
On Monday, March 20, 2017 at 8:38:00 AM UTC-5, pau...@gmail.com wrote:
>
> Howdy. I have a task with web2py. This is my first experience. My
> background is in Flask/Django. Here are a few quick questions:
>
> 1. I have an image in the a database. The model is defined like this:
>
> Field('Image', "upload", requires=[
> IS_NOT_EMPTY()], autodelete=True, uploadfolder='uploads/', notnull=False,
> label=T('Images'),
> represent=lambda x, row: x and A('%s' %
> (db.package.Images.retrieve(x)[0]),
> _href=URL(
> 'default', 'template/viewer.html', args=x),
> _target="_blank",
> _title=T("Open Image"),
> _class='file-reference')
> or ''),
>
> Can someone explain what this does conceptually?
> db.package.Images.retrieve(x)[0]
>
> If I understand, this will look in the package table, in the Image field,
> and it will retrieve the image that matches x (which is the value of x in
> this table). What I'm not sure, is it matches x and pulls the first
> element. I'm probably going to wipe this code and not use it (it doesn't
> work) but I'm curious what it was attempting to do.
>
> 2. How can I display the image and have it clickable (I have it to show
> the text currently). I see the images get uploaded to 'uploads/'. I'm
> having trouble finding exactly how retrieve() works in the docs, perhaps
> I've been looking in the wrong place.
>
> 3. I want to build a basic CRUD admin interface to manage a table defined
> in the model. Any two cents on where I can start here? I've gone through
> some of the docs.
>
> 4. How do I add a user to a membership 'admin' ?
>
--
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.