Cheers!
> --
> You received this message because you are subscribed to the Google
> Groups "Django developers" group.
> To post to this group, send email to django-d...@googlegroups.com
> .
> To unsubscribe from this group, send email to django-develop...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
> .
>
It provides this functionality:
* Every user with is_staff=True can read all objects in the admin.
* View permission means: You can see the usual change form but you cannot save
the form
There is a small drawback: If a user has no other permissions (like
change/add/delete permissions) the model will not show up in admin's index
page. Maybe this is not a problem for you if you have a custom admin index
page.
[1] http://gremu.net/blog/2010/django-admin-read-only-permission/
--
Servus,
Gregor Müllegger
2010/7/2 Josh Ourisman <jo...@joshourisman.com>:
You're most welcome - and thanks for sharing your story. We've been
meaning to start gathering success stories so that we can show the
world all the interesting ways and places that Django is used. It
would be fantastic to be able to tell the world about success stories
such as yours.
The idea has been proposed in the past:
[1] http://code.djangoproject.com/ticket/820
[2] http://code.djangoproject.com/ticket/7150
As you can see from those tickets, the historical position has been to
reject the idea. However, it also hasn't been a subject of serious
discussion for a couple of years. There have been a couple of changes
in recent history that suggest to me that there might be scope to
revisit this area -- more details below.
> 3) Can I add view permissions functionality on top of the Contrib
> Admin without changing its interior, thus avoiding problems on next
> Django update?
You can always add new permissions without any risk. Django's docs
describe how extra permissions can be defined in the Meta block of a
model [3], but a permission is ultimately just an Django object
itself, so you can create custom permissions manually or
programmatically if you want.
[3] http://docs.djangoproject.com/en/1.2/topics/auth/#id2
However, the admin will only honor the add/edit/delete permissions by
default. If you want admin to honor your custom view permissions,
you'll need to add custom readonly views that check for that
permission. Luckily, you can also add custom views to a standard Admin
install without risk. ModelAdmin allows you to provide a get_urls()
method that exposes custom views. Josh Ourisman's blog post (see his
reply on this thread) shows how this can be done.
> 4) If not, are there many changes planned for the Contrib Admin on
> next release -- would it be wise for me to add it my self?
We're still in the process of working out what we will be adding to
Django 1.3, so at the moment, there aren't any firm plans. However,
the broad intention of Django 1.3 is to concentrate less on big
features, and more on bug fixes and smaller features. That doesn't
mean we're not going to add new features -- just that the intention is
to focus less on big features (like multiple database support), and
more on bug fixes.
That said, ultimately we'll consider any patch that implements a
trunk-ready feature for inclusion in trunk.
Concerning the historical reluctance to add view permissions: Django
1.2 added two features that lead me to believe that the time may have
come to revisit the earlier decisions to avoid view permissions.
Firstly, we added readonly fields. Ultimately, a readonly view is just
a view where all the fields are readonly; to me, it seems like a small
jump from "specifying an admin with N readonly fields" to "specifying
an admin that is all readonly fields".
Secondly, we added a framework for per-object permissions. Although
the API is in place for this, I'm not convinced that the consequences
of this change have been fully reflected in the admin. After all, it's
now possible to have a list of objects, but only have access to edit
some of those objects - but that doesn't mean you can't *see* the
remaining object - especially in the context of foreign key relations.
So -- I'm at least willing to entertain the discussion about adding
this as a first-class feature of the admin. If this is a feature that
you are enthused by, then put together a full proposal describing
exactly what you would like to add (possibly with a prototype patch),
and we can have the discussion over whether we should add this feature
to trunk -- or whether, like with per-object permissions, we just need
to expose an better API to make it easier to add view permissions as
an end-user.
Yours,
Russ Magee %-)