Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
test-it
test_oauth2_django
Commits
feef65c0
Commit
feef65c0
authored
Nov 05, 2017
by
Sharad Heft
Browse files
Various important fixes, previous commits were immature.
parent
630ea71b
Changes
3
Hide whitespace changes
Inline
Side-by-side
test_oauth/backend.py
View file @
feef65c0
...
...
@@ -5,7 +5,7 @@ from django.conf import settings
from
django.db
import
transaction
from
test_oauth.models
import
TESTOAuth2Data
from
test_oauth.models
import
TESTOAuth2Data
,
Character
class
TESTOAuth2Backend
(
ModelBackend
):
...
...
@@ -72,11 +72,12 @@ class TESTOAuth2Backend(ModelBackend):
user
.
auth
.
primary_character
=
None
for
c
in
characters
:
character
,
_
=
Group
.
objects
.
update_or_create
(
print
(
c
)
character
,
_
=
Character
.
objects
.
update_or_create
(
id
=
c
[
'id'
],
defaults
=
{
'name'
:
c
[
'name'
],
'alliance_id'
:
c
[
'alliance'
][
'id'
],
'alliance_id'
:
(
c
[
'alliance'
]
or
{
'id'
:
None
})
[
'id'
],
'corporation_id'
:
c
[
'corporation'
][
'id'
]
}
)
...
...
test_oauth/migrations/0001_initial.py
View file @
feef65c0
...
...
@@ -9,7 +9,6 @@ class Migration(migrations.Migration):
dependencies
=
[
(
'auth'
,
'0001_initial'
),
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
]
operations
=
[
...
...
@@ -18,8 +17,8 @@ class Migration(migrations.Migration):
fields
=
[
(
'id'
,
models
.
BigIntegerField
(
serialize
=
False
,
primary_key
=
True
)),
(
'name'
,
models
.
CharField
(
max_length
=
128
)),
(
'alliance_id'
,
models
.
BigIntegerField
()),
(
'corporation_id'
,
models
.
BigIntegerField
()),
(
'alliance_id'
,
models
.
BigIntegerField
(
null
=
True
)),
(
'corporation_id'
,
models
.
BigIntegerField
(
null
=
True
)),
],
options
=
{
},
...
...
@@ -40,7 +39,7 @@ class Migration(migrations.Migration):
migrations
.
AddField
(
model_name
=
'character'
,
name
=
'auth'
,
field
=
models
.
ManyToManyField
(
related_name
=
'characters'
,
to
=
settings
.
AUTH_USER_MODEL
,
db_index
=
True
),
field
=
models
.
ManyToManyField
(
related_name
=
'characters'
,
to
=
'test_oauth.TESTOAuth2Data'
,
db_index
=
True
),
preserve_default
=
True
,
),
]
test_oauth/models.py
View file @
feef65c0
...
...
@@ -7,13 +7,13 @@ class Character(models.Model):
name
=
models
.
CharField
(
max_length
=
128
)
auth
=
models
.
ManyToManyField
(
settings
.
AUTH_USER_MODEL
,
'TESTOAuth2Data'
,
db_index
=
True
,
related_name
=
'characters'
)
alliance_id
=
models
.
BigIntegerField
(
null
=
Fals
e
)
corporation_id
=
models
.
BigIntegerField
(
null
=
Fals
e
)
alliance_id
=
models
.
BigIntegerField
(
null
=
Tru
e
)
corporation_id
=
models
.
BigIntegerField
(
null
=
Tru
e
)
class
TESTOAuth2Data
(
models
.
Model
):
...
...
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