I changed the code and I suppose I'm on the right track but I get an
error message when I try to run the app:
************************
...../create.html", line 91
response.write(form)
^
SyntaxError: invalid syntax
************************
Here is the code:
===in a controller file===
@auth.requires_login()
def create():
records =
db(auth.settings.table_user==auth.user).select(db.day.theauth,
distinct=True, orderby=db.day.thedate)
form = SQLFORM(db.day, fields=['thedate','value'])
if form.accepts(request.post_vars, session):
session.flash = 'Saved.'
redirect(URL('create'))
return dict(records=records, form=form)
===in create.html===
<table>
<tr>
<td>
{{for record in records:}}
{{#if recording!=record.thedate:}}
</td>
<td>
<span style="margin:0em 0.5em 0em
-0.5em"><i>{{#=record.thedate}}</
i></span>
{{pass}}
{{#session.uuid=record.uuid}}
{{=record.value}} <br>
{{pass}}
</td>
</tr>
</table>
{{=form}}
===in the model file===
auth = Auth(globals(), db)
auth.define_tables(username=True)
import uuid
import datetime
now = datetime.date.today()
db.define_table('day',
Field('uuid', length=64, default=uuid.uuid4()),
Field('thedate','date', default=request.now),
Field('value', 'integer'),
Field('theauth', auth.settings.table_user))
On Jan 16, 4:58 am, Rick <[email protected]> wrote:
> Hurray, I'm getting somewhere now! Thanks pbreit, now I try to do what
> I want to do without modifying the authentication functionality and it
> works better. But I get the message "invalid function" when I try to
> login. Here is the code:
>
> ===in the model file===
> auth = Auth(globals(), db)
> auth.define_tables(username=True)
>
> ===in the controller file===
> def users():
> return users[0].id
>
> def admin():
> records = db().select(auth.settings.table_user.ALL,
> orderby=auth.settings.table_user.username)
> form = SQLFORM(auth.settings.table_user,
> fields=['username','password'],)
> if form.accepts(request.post_vars, session):
> session.flash = 'Address saved.'
> redirect(URL('admin'))
> return dict(form=form, records=records)
>
> ===in user.html===
> {{extend 'layout.html'}}
> <h2>{{=request.args(0).replace('_',' ').capitalize()}}</h2>
> {{=form}}
> {{if request.args(0)=='login':}}
> {{pass}}
>
>
>
>
>
>
>
> >On Jan 16, 3:24 am, Rick <[email protected]> wrote:
> > ...or maybe the problem lies int this function in the controller file:
> > def admin():
> > records = db().select(custom_auth_table.ALL,
> > orderby=custom_auth_table.username)
> > form = SQLFORM(db[auth.settings.table_user_name])
> > if form.accepts(request.post_vars, session):
> > session.flash = 'saved.'
> > redirect(URL('admin'))
> > return dict(form=form, records=records)
>
> > On Jan 16, 1:08 am, Rick <[email protected]> wrote:
>
> > > Perhaps I should reformulate the problem -- I want to make one table
> > > for each auth-user, so that an auth-user can't see the records of
> > > ohters auth-users.
>
> > > On Jan 15, 11:52 pm, pbreit <[email protected]> wrote:
>
> > > > I may not understand either. The user authentication functionality is
> > > > automatically provided by web2py scaffolding. I would suggest using it
> > > > without modifications until you run into limitations.