Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
cd790ed1
Kaydet (Commit)
cd790ed1
authored
Agu 16, 2018
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Agu 16, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #8936 -- Added ModelAdmin.has_view_or_change_permission().
üst
dd3feb08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
options.py
django/contrib/admin/options.py
+8
-6
No files found.
django/contrib/admin/options.py
Dosyayı görüntüle @
cd790ed1
...
...
@@ -518,6 +518,9 @@ class BaseModelAdmin(metaclass=forms.MediaDefiningClass):
request
.
user
.
has_perm
(
'
%
s.
%
s'
%
(
opts
.
app_label
,
codename_change
))
)
def
has_view_or_change_permission
(
self
,
request
,
obj
=
None
):
return
self
.
has_view_permission
(
request
,
obj
)
or
self
.
has_change_permission
(
request
,
obj
)
def
has_module_permission
(
self
,
request
):
"""
Return True if the given request has any permission in the given
...
...
@@ -588,9 +591,8 @@ class ModelAdmin(BaseModelAdmin):
else
:
inline_has_add_permission
=
inline
.
has_add_permission
(
request
)
if
request
:
if
not
(
inline
.
has_view_permission
(
request
,
obj
)
or
if
not
(
inline
.
has_view_
or_change_
permission
(
request
,
obj
)
or
inline_has_add_permission
or
inline
.
has_change_permission
(
request
,
obj
)
or
inline
.
has_delete_permission
(
request
,
obj
)):
continue
if
not
inline_has_add_permission
:
...
...
@@ -1556,7 +1558,7 @@ class ModelAdmin(BaseModelAdmin):
else
:
obj
=
self
.
get_object
(
request
,
unquote
(
object_id
),
to_field
)
if
not
self
.
has_view_
permission
(
request
,
obj
)
and
not
self
.
has
_change_permission
(
request
,
obj
):
if
not
self
.
has_view_
or
_change_permission
(
request
,
obj
):
raise
PermissionDenied
if
obj
is
None
:
...
...
@@ -1678,7 +1680,7 @@ class ModelAdmin(BaseModelAdmin):
from
django.contrib.admin.views.main
import
ERROR_FLAG
opts
=
self
.
model
.
_meta
app_label
=
opts
.
app_label
if
not
self
.
has_view_
permission
(
request
)
and
not
self
.
has
_change_permission
(
request
):
if
not
self
.
has_view_
or
_change_permission
(
request
):
raise
PermissionDenied
try
:
...
...
@@ -1904,7 +1906,7 @@ class ModelAdmin(BaseModelAdmin):
if
obj
is
None
:
return
self
.
_get_obj_does_not_exist_redirect
(
request
,
model
.
_meta
,
object_id
)
if
not
self
.
has_view_
permission
(
request
,
obj
)
and
not
self
.
has
_change_permission
(
request
,
obj
):
if
not
self
.
has_view_
or
_change_permission
(
request
,
obj
):
raise
PermissionDenied
# Then get the history for this object.
...
...
@@ -2111,7 +2113,7 @@ class InlineModelAdmin(BaseModelAdmin):
def
get_queryset
(
self
,
request
):
queryset
=
super
()
.
get_queryset
(
request
)
if
not
self
.
has_
change_permission
(
request
)
and
not
self
.
has_view
_permission
(
request
):
if
not
self
.
has_
view_or_change
_permission
(
request
):
queryset
=
queryset
.
none
()
return
queryset
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment