I changed the code but it still doesn't work:

==admin.html==
{{extend 'layout.html'}}
Add a user: <br>
{{=form}}
<br><br>
Users:
<br>
{{for record in records:}}
{{=record.username}} : {{=record.password}}
[
<a href="#"
onclick="ajax('{{=URL('db(auth.settings.table_user_name==record.username).delete()')}}',
[],'')">Delete this user</a>
]
{{pass}}
============

==Here is some code from models/db.py==
auth = Auth(globals(), db)

db.define_table(
    auth.settings.table_user_name,
    Field('username'),
    Field('password'),
    Field('registration_key', default=''))

auth.define_tables()

custom_auth_table = db[auth.settings.table_user_name] # get the
custom_auth_table
======



On Dec 30 2010, 6:21 pm, Rick <[email protected]> wrote:
> Hi,
>
> I don't know if the way I add users is proper, but it works. Now I try
> to write a <a> tag for deleting users, and it doesn't work. Here is
> the code:
>
> ==in a controller file==
> def admin():
>         records = db().select(custom_auth_table.ALL,
> orderby=custom_auth_table.username)
>         #records = SQLFORM(custom_auth_table, user, deletable=True)
>         form = SQLFORM(db[auth.settings.table_user_name])
>         if form.accepts(request.post_vars, session):
>                 session.flash = 'Address saved.'
>                 redirect(URL('admin'))
>         return dict(form=form, records=records)
> ========
>
> ==admin.html==
> {{extend 'layout.html'}}
> Add a user: <br>
> {{=form}}
> <br><br>
> Users:
> <br>
> {{for record in records:}}
> {{=record.username}} : {{=record.password}}
>  [
> <a href="#"
> onclick="ajax('{{=URL('db[auth.remove.record.username]')}}',
> [],'')">Delete this user</a>
> ]
> <br>
> {{pass}}
> ========
>
> Thanks in advance for help

Reply via email to