1
1
# -*- coding: utf-8 -*-
2
2
from __future__ import unicode_literals
3
3
4
- from django .db import models , migrations
5
- from django .conf import settings
6
-
7
4
from oauth2_provider .settings import oauth2_settings
8
- import oauth2_provider . generators
5
+ from django . db import models , migrations
9
6
import oauth2_provider .validators
7
+ import oauth2_provider .generators
8
+ from django .conf import settings
10
9
11
10
12
11
class Migration (migrations .Migration ):
13
12
14
13
dependencies = [
15
14
migrations .swappable_dependency (settings .AUTH_USER_MODEL ),
15
+ migrations .swappable_dependency (oauth2_settings .APPLICATION_MODEL ),
16
16
]
17
17
18
18
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
- ),
28
19
migrations .CreateModel (
29
20
name = 'Application' ,
30
21
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 )),
32
23
('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 ] )),
34
25
('client_type' , models .CharField (max_length = 32 , choices = [('confidential' , 'Confidential' ), ('public' , 'Public' )])),
35
26
('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 )),
38
29
('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 )),
40
31
],
41
32
options = {
42
33
'abstract' : False ,
43
34
},
44
35
),
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
+ ),
45
47
migrations .CreateModel (
46
48
name = 'Grant' ,
47
49
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 )),
49
51
('code' , models .CharField (max_length = 255 , db_index = True )),
50
52
('expires' , models .DateTimeField ()),
51
53
('redirect_uri' , models .CharField (max_length = 255 )),
@@ -57,21 +59,11 @@ class Migration(migrations.Migration):
57
59
migrations .CreateModel (
58
60
name = 'RefreshToken' ,
59
61
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 )),
61
63
('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 ' )),
63
65
('application' , models .ForeignKey (to = oauth2_settings .APPLICATION_MODEL )),
64
66
('user' , models .ForeignKey (to = settings .AUTH_USER_MODEL )),
65
67
],
66
68
),
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
- ),
77
69
]
0 commit comments