11# -*- coding: utf-8 -*-
22from __future__ import unicode_literals
33
4- from django .db import models , migrations
5- from django .conf import settings
6-
74from oauth2_provider .settings import oauth2_settings
8- import oauth2_provider . generators
5+ from django . db import models , migrations
96import oauth2_provider .validators
7+ import oauth2_provider .generators
8+ from django .conf import settings
109
1110
1211class Migration (migrations .Migration ):
1312
1413 dependencies = [
1514 migrations .swappable_dependency (settings .AUTH_USER_MODEL ),
15+ migrations .swappable_dependency (oauth2_settings .APPLICATION_MODEL ),
1616 ]
1717
1818 operations = [
19- migrations .CreateModel (
20- name = 'AccessToken' ,
21- fields = [
22- ('id' , models .AutoField (primary_key = True , verbose_name = 'ID' , auto_created = True , serialize = False )),
23- ('token' , models .CharField (max_length = 255 , db_index = True )),
24- ('expires' , models .DateTimeField ()),
25- ('scope' , models .TextField (blank = True )),
26- ],
27- ),
2819 migrations .CreateModel (
2920 name = 'Application' ,
3021 fields = [
31- ('id' , models .AutoField (primary_key = True , verbose_name = 'ID' , auto_created = True , serialize = False )),
22+ ('id' , models .AutoField (verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
3223 ('client_id' , models .CharField (default = oauth2_provider .generators .generate_client_id , unique = True , max_length = 100 , db_index = True )),
33- ('redirect_uris' , models .TextField (validators = [ oauth2_provider . validators . validate_uris ], help_text = 'Allowed URIs list, space separated' , blank = True )),
24+ ('redirect_uris' , models .TextField (help_text = 'Allowed URIs list, space separated' , blank = True , validators = [ oauth2_provider . validators . validate_uris ] )),
3425 ('client_type' , models .CharField (max_length = 32 , choices = [('confidential' , 'Confidential' ), ('public' , 'Public' )])),
3526 ('authorization_grant_type' , models .CharField (max_length = 32 , choices = [('authorization-code' , 'Authorization code' ), ('implicit' , 'Implicit' ), ('password' , 'Resource owner password-based' ), ('client-credentials' , 'Client credentials' )])),
36- ('client_secret' , models .CharField (default = oauth2_provider .generators .generate_client_secret , blank = True , max_length = 255 , db_index = True )),
37- ('name' , models .CharField (blank = True , max_length = 255 )),
27+ ('client_secret' , models .CharField (default = oauth2_provider .generators .generate_client_secret , max_length = 255 , db_index = True , blank = True )),
28+ ('name' , models .CharField (max_length = 255 , blank = True )),
3829 ('skip_authorization' , models .BooleanField (default = False )),
39- ('user' , models .ForeignKey (to = settings . AUTH_USER_MODEL , related_name = 'oauth2_provider_application' )),
30+ ('user' , models .ForeignKey (related_name = 'oauth2_provider_application' , to = settings . AUTH_USER_MODEL )),
4031 ],
4132 options = {
4233 'abstract' : False ,
4334 },
4435 ),
36+ migrations .CreateModel (
37+ name = 'AccessToken' ,
38+ fields = [
39+ ('id' , models .AutoField (verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
40+ ('token' , models .CharField (max_length = 255 , db_index = True )),
41+ ('expires' , models .DateTimeField ()),
42+ ('scope' , models .TextField (blank = True )),
43+ ('application' , models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL )),
44+ ('user' , models .ForeignKey (blank = True , to = settings .AUTH_USER_MODEL , null = True )),
45+ ],
46+ ),
4547 migrations .CreateModel (
4648 name = 'Grant' ,
4749 fields = [
48- ('id' , models .AutoField (primary_key = True , verbose_name = 'ID' , auto_created = True , serialize = False )),
50+ ('id' , models .AutoField (verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
4951 ('code' , models .CharField (max_length = 255 , db_index = True )),
5052 ('expires' , models .DateTimeField ()),
5153 ('redirect_uri' , models .CharField (max_length = 255 )),
@@ -57,21 +59,11 @@ class Migration(migrations.Migration):
5759 migrations .CreateModel (
5860 name = 'RefreshToken' ,
5961 fields = [
60- ('id' , models .AutoField (primary_key = True , verbose_name = 'ID' , auto_created = True , serialize = False )),
62+ ('id' , models .AutoField (verbose_name = 'ID' , serialize = False , auto_created = True , primary_key = True )),
6163 ('token' , models .CharField (max_length = 255 , db_index = True )),
62- ('access_token' , models .OneToOneField (to = 'oauth2_provider.AccessToken ' , related_name = 'refresh_token ' )),
64+ ('access_token' , models .OneToOneField (related_name = 'refresh_token ' , to = 'oauth2_provider.AccessToken ' )),
6365 ('application' , models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL )),
6466 ('user' , models .ForeignKey (to = settings .AUTH_USER_MODEL )),
6567 ],
6668 ),
67- migrations .AddField (
68- model_name = 'accesstoken' ,
69- name = 'application' ,
70- field = models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL ),
71- ),
72- migrations .AddField (
73- model_name = 'accesstoken' ,
74- name = 'user' ,
75- field = models .ForeignKey (to = settings .AUTH_USER_MODEL , null = True , blank = True ),
76- ),
7769 ]
0 commit comments