summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorolivierdalang <olivier.dalang@gmail.com>2018-05-02 20:39:12 +1200
committerTim Graham <timograham@gmail.com>2018-05-16 06:44:55 -0400
commit825f0beda804e48e9197fcf3b0d909f9f548aa47 (patch)
treebe5036c256efa1cd06a72b3265ed97884afc39cb /docs/ref
parent35b6a348dea6b019679fe35fd443be875bdb028e (diff)
Fixed #8936 -- Added a view permission and a read-only admin.
Co-authored-by: Petr Dlouhy <petr.dlouhy@email.cz> Co-authored-by: Olivier Dalang <olivier.dalang@gmail.com>
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/admin/actions.txt3
-rw-r--r--docs/ref/contrib/admin/index.txt21
-rw-r--r--docs/ref/models/options.txt16
3 files changed, 31 insertions, 9 deletions
diff --git a/docs/ref/contrib/admin/actions.txt b/docs/ref/contrib/admin/actions.txt
index 0eb6de5b11..88fcd60751 100644
--- a/docs/ref/contrib/admin/actions.txt
+++ b/docs/ref/contrib/admin/actions.txt
@@ -340,6 +340,9 @@ Conditionally enabling or disabling actions
Finally, you can conditionally enable or disable actions on a per-request
(and hence per-user basis) by overriding :meth:`ModelAdmin.get_actions`.
+ This doesn't return any actions if the user doesn't have the "change"
+ permission for the model.
+
This returns a dictionary of actions allowed. The keys are action names, and
the values are ``(function, name, short_description)`` tuples.
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index abaeeb5c22..9b0a7cc8a4 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1623,7 +1623,7 @@ templates used by the :class:`ModelAdmin` views:
a ``list`` or ``tuple`` of :class:`~django.contrib.admin.InlineModelAdmin`
objects, as described below in the :class:`~django.contrib.admin.InlineModelAdmin`
section. For example, the following would return inlines without the default
- filtering based on add, change, and delete permissions::
+ filtering based on add, change, delete, and view permissions::
class MyModelAdmin(admin.ModelAdmin):
inlines = (MyInline,)
@@ -1887,6 +1887,19 @@ templates used by the :class:`ModelAdmin` views:
Override this method to customize the lookups permitted for your
:class:`~django.contrib.admin.ModelAdmin` subclass.
+.. method:: ModelAdmin.has_view_permission(request, obj=None)
+
+ .. versionadded:: 2.1
+
+ Should return ``True`` if viewing ``obj`` is permitted, ``False`` otherwise.
+ If obj is ``None``, should return ``True`` or ``False`` to indicate whether
+ viewing of objects of this type is permitted in general (e.g., ``False``
+ will be interpreted as meaning that the current user is not permitted to
+ view any object of this type).
+
+ The default implementation returns ``True`` if the user has either the
+ "change" or "view" permission.
+
.. method:: ModelAdmin.has_add_permission(request)
Should return ``True`` if adding an object is permitted, ``False``
@@ -1914,7 +1927,8 @@ templates used by the :class:`ModelAdmin` views:
accessing the module's index page is permitted, ``False`` otherwise.
Uses :meth:`User.has_module_perms()
<django.contrib.auth.models.User.has_module_perms>` by default. Overriding
- it does not restrict access to the add, change or delete views,
+ it does not restrict access to the view, add, change, or delete views,
+ :meth:`~ModelAdmin.has_view_permission`,
:meth:`~ModelAdmin.has_add_permission`,
:meth:`~ModelAdmin.has_change_permission`, and
:meth:`~ModelAdmin.has_delete_permission` should be used for that.
@@ -2862,7 +2876,8 @@ Templates can override or extend base admin templates as described in
* ``object_name``: class name of the model
* ``name``: plural name of the model
- * ``perms``: a ``dict`` tracking ``add``, ``change``, and ``delete`` permissions
+ * ``perms``: a ``dict`` tracking ``add``, ``change``, ``delete``, and
+ ``view`` permissions
* ``admin_url``: admin changelist URL for the model
* ``add_url``: admin URL to add a new model instance
diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt
index fe51a1a362..51a87fc632 100644
--- a/docs/ref/models/options.txt
+++ b/docs/ref/models/options.txt
@@ -313,7 +313,7 @@ Django quotes column and table names behind the scenes.
.. attribute:: Options.permissions
Extra permissions to enter into the permissions table when creating this object.
- Add, delete and change permissions are automatically created for each
+ Add, change, delete, and view permissions are automatically created for each
model. This example specifies an extra permission, ``can_deliver_pizzas``::
permissions = (("can_deliver_pizzas", "Can deliver pizzas"),)
@@ -326,11 +326,15 @@ Django quotes column and table names behind the scenes.
.. attribute:: Options.default_permissions
- Defaults to ``('add', 'change', 'delete')``. You may customize this list,
- for example, by setting this to an empty list if your app doesn't require
- any of the default permissions. It must be specified on the model before
- the model is created by :djadmin:`migrate` in order to prevent any omitted
- permissions from being created.
+ Defaults to ``('add', 'change', 'delete', 'view')``. You may customize this
+ list, for example, by setting this to an empty list if your app doesn't
+ require any of the default permissions. It must be specified on the model
+ before the model is created by :djadmin:`migrate` in order to prevent any
+ omitted permissions from being created.
+
+ .. versionchanged:: 2.1
+
+ The ``view`` permission was added.
``proxy``
---------