I still haven't solved the problem described in the post above.
This is what I have got so far:
@auth.requires_membership('user_3')
def crud_address():
db.adres.bedrijf.default=auth.user.bedrijf
form=crud.create(db.adres)
rows=db(db.adres.bedrijf==auth.user.bedrijf)\
.select
(db.adres.id,db.adres.adressoort,db.adres.straat,db.adres.plaats,orderby=db.adres.straat)
if form.accepts(form.vars,session):
response.flash = T('new record inserted')
elif form.errors:
response.flash = T('form has errors')
else:
response.flash = T('please fill the form')
return dict(form=form,rows=rows)
@auth.requires_membership('user_3')
def update_address():
record_id=request.args[0]
record=db.adres[... something ..]
if not record.bedrijf==auth.user.bedrijf:
session.flash = T('form has been tampered with')
else:
form=crud.update(db.mytable,record)
return dict(form=form)
The code in the update_address function comes from a reply to one of
my previous posts on this subject:
http://groups.google.com/group/web2py/browse_thread/thread/1748ced2e18d6e5a/54327bd6acc695bb?lnk=gst&q=annet#54327bd6acc695bb
Now. the second arg of crud.update can be a record or a record_id so
you can do:
def update_mytable():
record_id=request.args[0]
record=db.mytable[myrecord]
if not auth.has_permission
('update','company',record.company_id):
redirect(.... somwehere....)
form=crud.update(db.mytable,record)
return dict(form=form)
I don't know what this line of code means:
record=db.mytable[myrecord]
I hope one of you can find the time to help me solve this problem.
Kind regards,
Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---