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
f325f869
Kaydet (Commit)
f325f869
authored
Haz 27, 2013
tarafından
Andrew Godwin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20244: PermissionsMixin now defines a related_query_name for M2Ms
üst
12cb0df1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
models.py
django/contrib/auth/models.py
+4
-2
test_custom_user.py
django/contrib/auth/tests/test_custom_user.py
+21
-1
No files found.
django/contrib/auth/models.py
Dosyayı görüntüle @
f325f869
...
...
@@ -295,10 +295,12 @@ class PermissionsMixin(models.Model):
groups
=
models
.
ManyToManyField
(
Group
,
verbose_name
=
_
(
'groups'
),
blank
=
True
,
help_text
=
_
(
'The groups this user belongs to. A user will '
'get all permissions granted to each of '
'his/her group.'
))
'his/her group.'
),
related_name
=
"user_set"
,
related_query_name
=
"user"
)
user_permissions
=
models
.
ManyToManyField
(
Permission
,
verbose_name
=
_
(
'user permissions'
),
blank
=
True
,
help_text
=
'Specific permissions for this user.'
)
help_text
=
'Specific permissions for this user.'
,
related_name
=
"user_set"
,
related_query_name
=
"user"
)
class
Meta
:
abstract
=
True
...
...
django/contrib/auth/tests/test_custom_user.py
Dosyayı görüntüle @
f325f869
...
...
@@ -4,7 +4,9 @@ from django.contrib.auth.models import (
AbstractBaseUser
,
AbstractUser
,
UserManager
,
PermissionsMixin
PermissionsMixin
,
Group
,
Permission
,
)
...
...
@@ -81,6 +83,20 @@ class CustomUser(AbstractBaseUser):
return
self
.
is_admin
# At this point, temporarily remove the groups and user_permissions M2M
# fields from the AbstractUser class, so they don't clash with the related_name
# that sets.
old_au_local_m2m
=
AbstractUser
.
_meta
.
local_many_to_many
old_pm_local_m2m
=
PermissionsMixin
.
_meta
.
local_many_to_many
groups
=
models
.
ManyToManyField
(
Group
,
blank
=
True
)
groups
.
contribute_to_class
(
PermissionsMixin
,
"groups"
)
user_permissions
=
models
.
ManyToManyField
(
Permission
,
blank
=
True
)
user_permissions
.
contribute_to_class
(
PermissionsMixin
,
"user_permissions"
)
PermissionsMixin
.
_meta
.
local_many_to_many
=
[
groups
,
user_permissions
]
AbstractUser
.
_meta
.
local_many_to_many
=
[
groups
,
user_permissions
]
# The extension user is a simple extension of the built-in user class,
# adding a required date_of_birth field. This allows us to check for
# any hard references to the name "User" in forms/handlers etc.
...
...
@@ -178,3 +194,7 @@ class CustomUserBadRequiredFields(AbstractBaseUser):
class
Meta
:
app_label
=
'auth'
# Undo swap hack
AbstractUser
.
_meta
.
local_many_to_many
=
old_au_local_m2m
PermissionsMixin
.
_meta
.
local_many_to_many
=
old_pm_local_m2m
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