nwal...@sprynet.com
unread,Mar 22, 2009, 9:08:19 PM3/22/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google App Engine
I have a table where users can add their own rows, but the admin must
approve it.
So my model contains this:
dateAdminDecision = db.DateTimeProperty(auto_now=True)
Obviously, at first, every row, even when the users added their data,
was getting set to this date.
But I only want the date to be set when the Admin approves the row
using a special Admin form.
What about the approach I have tried below, so far it seems to be
working. Is this technically called inspection or reflection? I use
the same template, but two different forms classes, each form class
has different "exclude"s on it so the non-Admin sees a different set
of fields than the Admin-user.
if users.IsCurrentUserAdmin():
MyModelName.__dict__["dateAdminDecision"].__dict__["auto_now"] =
True;
form = AdminForm(data=request.POST or None, instance=conference)
else:
MyModelName.__dict__["dateAdminDecision"].__dict__["auto_now"] =
False;
form = UserForm(data=request.POST or None, instance=conference)
I saw in some other post that auto_now maybe going away soon. I'm
creating this app for GAE right now, but want to think broadly of how
I might do this on an LAMP type server as well.
Thanks,
Neal Walters