Commit feef65c0 authored by Sharad Heft's avatar Sharad Heft

Various important fixes, previous commits were immature.

parent 630ea71b
......@@ -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']
}
)
......
......@@ -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,
),
]
......@@ -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=False)
corporation_id = models.BigIntegerField(null=False)
alliance_id = models.BigIntegerField(null=True)
corporation_id = models.BigIntegerField(null=True)
class TESTOAuth2Data(models.Model):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment