Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-openid-auth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-openid-auth
Commits
60457a5e
Commit
60457a5e
authored
Jun 21, 2013
by
James Tait
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just use the object manager to get the permission.
parent
840648c1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
10 deletions
+13
-10
django_openid_auth/auth.py
+1
-1
django_openid_auth/models.py
+1
-5
django_openid_auth/tests/test_auth.py
+6
-2
django_openid_auth/tests/test_models.py
+5
-2
No files found.
django_openid_auth/auth.py
View file @
60457a5e
...
@@ -316,7 +316,7 @@ class OpenIDBackend:
...
@@ -316,7 +316,7 @@ class OpenIDBackend:
updated
=
True
updated
=
True
account_verified
=
details
.
get
(
'account_verified'
,
None
)
account_verified
=
details
.
get
(
'account_verified'
,
None
)
if
(
account_verified
is
not
None
):
if
(
account_verified
is
not
None
):
permission
=
UserOpenID
.
permission
(
)
permission
=
Permission
.
objects
.
get
(
codename
=
'account_verified'
)
perm_label
=
'
%
s.
%
s'
%
(
permission
.
content_type
.
app_label
,
perm_label
=
'
%
s.
%
s'
%
(
permission
.
content_type
.
app_label
,
permission
.
codename
)
permission
.
codename
)
if
account_verified
and
not
user
.
has_perm
(
perm_label
):
if
account_verified
and
not
user
.
has_perm
(
perm_label
):
...
...
django_openid_auth/models.py
View file @
60457a5e
...
@@ -65,11 +65,7 @@ class UserOpenID(models.Model):
...
@@ -65,11 +65,7 @@ class UserOpenID(models.Model):
(
'account_verified'
,
'The OpenID has been verified'
),
(
'account_verified'
,
'The OpenID has been verified'
),
)
)
@classmethod
def
permission
(
self
):
return
Permission
.
objects
.
get
(
codename
=
'account_verified'
)
def
delete
(
self
,
using
=
None
):
def
delete
(
self
,
using
=
None
):
permission
=
UserOpenID
.
permission
(
)
permission
=
Permission
.
objects
.
get
(
codename
=
'account_verified'
)
self
.
user
.
user_permissions
.
remove
(
permission
)
self
.
user
.
user_permissions
.
remove
(
permission
)
super
(
UserOpenID
,
self
)
.
delete
(
using
)
super
(
UserOpenID
,
self
)
.
delete
(
using
)
django_openid_auth/tests/test_auth.py
View file @
60457a5e
...
@@ -29,7 +29,11 @@
...
@@ -29,7 +29,11 @@
import
unittest
import
unittest
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
Group
,
User
from
django.contrib.auth.models
import
(
Group
,
Permission
,
User
,
)
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django_openid_auth.auth
import
OpenIDBackend
from
django_openid_auth.auth
import
OpenIDBackend
...
@@ -207,7 +211,7 @@ class OpenIDBackendTests(TestCase):
...
@@ -207,7 +211,7 @@ class OpenIDBackendTests(TestCase):
def
_test_account_verified
(
self
,
user
,
initially_verified
,
expected
):
def
_test_account_verified
(
self
,
user
,
initially_verified
,
expected
):
# set user's verification status
# set user's verification status
permission
=
UserOpenID
.
permission
(
)
permission
=
Permission
.
objects
.
get
(
codename
=
'account_verified'
)
if
initially_verified
:
if
initially_verified
:
user
.
user_permissions
.
add
(
permission
)
user
.
user_permissions
.
add
(
permission
)
else
:
else
:
...
...
django_openid_auth/tests/test_models.py
View file @
60457a5e
...
@@ -31,7 +31,10 @@ import unittest
...
@@ -31,7 +31,10 @@ import unittest
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django_openid_auth.models
import
UserOpenID
from
django_openid_auth.models
import
(
Permission
,
UserOpenID
,
)
class
UserOpenIDModelTestCase
(
TestCase
):
class
UserOpenIDModelTestCase
(
TestCase
):
...
@@ -60,7 +63,7 @@ class UserOpenIDModelTestCase(TestCase):
...
@@ -60,7 +63,7 @@ class UserOpenIDModelTestCase(TestCase):
user
=
user
,
user
=
user
,
claimed_id
=
'http://example.com/existing_identity'
,
claimed_id
=
'http://example.com/existing_identity'
,
display_id
=
'http://example.com/existing_identity'
)
display_id
=
'http://example.com/existing_identity'
)
permission
=
UserOpenID
.
permission
(
)
permission
=
Permission
.
objects
.
get
(
codename
=
'account_verified'
)
user
.
user_permissions
.
add
(
permission
)
user
.
user_permissions
.
add
(
permission
)
self
.
assertTrue
(
self
.
assertTrue
(
User
.
objects
.
get
(
username
=
'someuser'
)
.
has_perm
(
User
.
objects
.
get
(
username
=
'someuser'
)
.
has_perm
(
...
...
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