I'm using code like this to simulate row level permissions:
class JobOptions (admin.ModelAdmin):
def queryset(self, request):
userOrg = Organisation.objects.filter(contact=request.user.id)
if (request.user.id==1): # admin can edit all jobs
return Job.objects.all()
else: # restrict queryset to just those of the current user's
organisation
return Job.objects.filter(organisation=userOrg[0].id)
When editing a job I want to restrict the options available in the
drop-down list for organisation to just the current organisation (or
even hide that widget for non-super users and replace it with a hidden
field containing the correct value)
organisation is a simple foreign key field:
organisation = models.ForeignKey(Organisation)
The idea being that as well as only being able to edit their own jobs,
organisations shouldn't be able to add a job for another organisation
or edit the org for a job to be that of a different org.
What's the most obvious way to implement this in newforms-admin?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---