List Info

Thread: Different users with access to different fields




Different users with access to different fields
user name
2006-02-27 00:38:01
Can anyone suggest the best way to implement a model where
there are
many different types of users, all of which have access to
different
fields in the same database item?

We are a pair of Django newbies who are trying to port an
in-house
Content Management System across from PHP. The CMS sits
behind a web
site that publishes information about movies. We have a
fairly complex
editorial process involving about 5 different
writers/editors. Each
writer needs to be able to see the other writers' fields,
but just be
able to edit the data in their own.

Our problem is that we can't figure out the best way to
restrict user
access to the particular fields they should be working with.

Our first attempt to implement this involved setting up
separate models
for each user and then creating one-to-one relationships
between them.
We figured this would let us use the built-in Admin's
permissions to
determine who can edit what. It would also keep our business
logic in
the model, which is the best place for it. So far we have
not had much
success with this approach, partly because we can't find
any good
documentation for one-to-one relationships. We haven't even
been able
to get a simplified test implementation working this way
(see my
colleague's post at
http://groups.google.com/group/
django-users/browse_thread/thread/a788ec21d57f19a0),
and we're really not sure if it's worth persevering with
this approach,
as the complete business model is reasonably complex, with
one-to-many
relationships as well as the one-to-ones. Has anyone
successfully built
something like this? Are we barking up the wrong tree?

Our fallback approach is to simplify our model and deal with
the
different levels of user access at the view level, by adding
a switch
to views.py that uses a different template for each user
group. This is
pretty inelegant, but at least we know we can get it
working.

Or are there other approaches we have missed?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Different users with access to different fields
user name
2006-02-27 00:58:05


On Feb 26, 2006, at 7:38 PM, tttallis wrote:

>
> Can anyone suggest the best way to implement a model
where there are
> many different types of users, all of which have access
to different
> fields in the same database item?

Same way as you'd write a model for any other thing. If
every record has
all the fields, the most you can do is limit which ones can
be  
updated by
not letting the user have access to form elements that
"connect" to  
those
fields in teh database, and not show them to the user when
just viewing.



> We are a pair of Django newbies who are trying to port
an in-house
> Content Management System across from PHP. The CMS sits
behind a web
> site that publishes information about movies. We have a
fairly complex
> editorial process involving about 5 different
writers/editors. Each
> writer needs to be able to see the other writers'
fields, but just be
> able to edit the data in their own.
>
> Our problem is that we can't figure out the best way
to restrict user
> access to the particular fields they should be working
with.

if elif else usually work best. Django has a very good
templating system
which would let you conditionally output different views
based on  
permissions.


---
Andrew Gwozdziewycz
apgwozgmail.com
http://ihadagreatview.org
http://and.rovir.us



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )