Re: Accessing logged-in user object in models

2006-06-13 Thread Nuno Mariz
foo.updater = request.user ? In each view of Admin? Todd O'Bryan wrote: > You don't want to save the user id explicitly. Your model should be > > updater = models.ForeignKey(User) > > Since you'll be setting the updater (or some other better word) from > within a view, you'll have access to t

Re: Accessing logged-in user object in models

2006-06-13 Thread Todd O'Bryan
You don't want to save the user id explicitly. Your model should be updater = models.ForeignKey(User) Since you'll be setting the updater (or some other better word) from within a view, you'll have access to the currently logged-in user. Just do foo.updater = request.user and you're good t

Re: Accessing logged-in user object in models

2006-06-13 Thread Nuno Mariz
Ok, I agree. But if I want to save the ID of the user logged-in in a field in my table, I can't. Basically in almost of my tables I will have this fields: ip (IP Address) last_update (Record last update) user_id (User id that make the change) Don Arbow wrote: > On Jun 13, 2006, at 7:58 AM, [EMA

Re: Accessing logged-in user object in models

2006-06-13 Thread nm
Ok, I will give a try. Thanks all. Nuno Quoting Michael Radziej <[EMAIL PROTECTED]>: > > Don Arbow wrote: >> Then in the view that calls the template, you determine if the user >> is authorized to edit the field. > > You don't have a view function with an Admin page ... that doesn't work. > > B

Re: Accessing logged-in user object in models

2006-06-13 Thread Michael Radziej
Don Arbow wrote: > Then in the view that calls the template, you determine if the user > is authorized to edit the field. You don't have a view function with an Admin page ... that doesn't work. But you could just redirect the Admin page to a view function (using the URL config) and from the

Re: Accessing logged-in user object in models

2006-06-13 Thread Don Arbow
On Jun 13, 2006, at 7:58 AM, [EMAIL PROTECTED] wrote: > > I have a problem then. > I just need to test if a user have permission to edit a field in > Admin. > Then in the view that calls the template, you determine if the user is authorized to edit the field. You can test the authorization i

Re: Accessing logged-in user object in models

2006-06-13 Thread nm
I have a problem then. I just need to test if a user have permission to edit a field in Admin. Quoting Michael Radziej <[EMAIL PROTECTED]>: > > [EMAIL PROTECTED] wrote: >> Hi, >> I need the access to the logged-in user object in a model, to verify >> permissions. >> How I do that? > > You can't.

Re: Accessing logged-in user object in models

2006-06-13 Thread Michael Radziej
[EMAIL PROTECTED] wrote: > Hi, > I need the access to the logged-in user object in a model, to verify > permissions. > How I do that? You can't. The model is decoupled from the http stuff and has no way to access it. Such kind of validations must be done in the Manipulator or view. There are