Skip to content

Commit 62847af

Browse files
committed
added migration for skip_authorization field
1 parent ab8adc7 commit 62847af

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# -*- coding: utf-8 -*-
2+
from south.utils import datetime_utils as datetime
3+
from south.db import db
4+
from south.v2 import SchemaMigration
5+
from django.db import models
6+
7+
8+
try:
9+
from django.contrib.auth import get_user_model
10+
except ImportError: # django < 1.5
11+
from django.contrib.auth.models import User
12+
else:
13+
User = get_user_model()
14+
15+
from oauth2_provider.models import get_application_model
16+
ApplicationModel = get_application_model()
17+
18+
19+
class Migration(SchemaMigration):
20+
21+
def forwards(self, orm):
22+
# Adding field 'Application.skip_authorization'
23+
db.add_column(u'oauth2_provider_application', 'skip_authorization',
24+
self.gf('django.db.models.fields.BooleanField')(default=False),
25+
keep_default=False)
26+
27+
28+
# Changing field 'AccessToken.user'
29+
db.alter_column(u'oauth2_provider_accesstoken', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['%s.%s' % (User._meta.app_label, User._meta.object_name)], null=True))
30+
31+
def backwards(self, orm):
32+
# Deleting field 'Application.skip_authorization'
33+
db.delete_column(u'oauth2_provider_application', 'skip_authorization')
34+
35+
36+
# User chose to not deal with backwards NULL issues for 'AccessToken.user'
37+
raise RuntimeError("Cannot reverse this migration. 'AccessToken.user' and its values cannot be restored.")
38+
39+
# The following code is provided here to aid in writing a correct migration
40+
# Changing field 'AccessToken.user'
41+
db.alter_column(u'oauth2_provider_accesstoken', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['%s.%s' % (User._meta.app_label, User._meta.object_name)]))
42+
43+
models = {
44+
u'auth.group': {
45+
'Meta': {'object_name': 'Group'},
46+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
47+
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
48+
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
49+
},
50+
u'auth.permission': {
51+
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
52+
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
53+
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
54+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
55+
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
56+
},
57+
u'%s.%s' % (User._meta.app_label, User._meta.object_name): {
58+
'Meta': {'object_name': User.__name__},
59+
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
60+
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
61+
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
62+
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
63+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
64+
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
65+
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
66+
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
67+
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
68+
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
69+
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
70+
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
71+
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
72+
},
73+
u'contenttypes.contenttype': {
74+
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
75+
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
76+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
77+
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
78+
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
79+
},
80+
u'oauth2_provider.accesstoken': {
81+
'Meta': {'object_name': 'AccessToken'},
82+
'application': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s.%s']"% (ApplicationModel._meta.app_label, ApplicationModel._meta.object_name)}),
83+
'expires': ('django.db.models.fields.DateTimeField', [], {}),
84+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
85+
'scope': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
86+
'token': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
87+
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s.%s']" % (User._meta.app_label, User._meta.object_name), 'null': 'True', 'blank': 'True'})
88+
},
89+
u"%s.%s" % (ApplicationModel._meta.app_label, ApplicationModel._meta.object_name): {
90+
'Meta': {'object_name': ApplicationModel.__name__},
91+
'authorization_grant_type': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
92+
'client_id': ('django.db.models.fields.CharField', [], {'default': "u'amXbsy974anVL3xgzY2dczL8SRMSXA5awkXyjtsY'", 'unique': 'True', 'max_length': '100', 'db_index': 'True'}),
93+
'client_secret': ('django.db.models.fields.CharField', [], {'default': "u'trXjdJB8EO7HPsZcPswIT1l0Zdg3W3AWDxXvh5Jj9rON2MAoRT6YVDSHqKFB76rIgD9X9YBxoY7jjT4Mj12UHc2BjCCXJI4nzx4qwEwoyZ7l6N88xiHaM6J5qXeWJ6e3'", 'max_length': '255', 'db_index': 'True', 'blank': 'True'}),
94+
'client_type': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
95+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
96+
'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
97+
'redirect_uris': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
98+
'skip_authorization': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
99+
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s.%s']" % (User._meta.app_label, User._meta.object_name)})
100+
},
101+
u'oauth2_provider.grant': {
102+
'Meta': {'object_name': 'Grant'},
103+
'application': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s.%s']"% (ApplicationModel._meta.app_label, ApplicationModel._meta.object_name)}),
104+
'code': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
105+
'expires': ('django.db.models.fields.DateTimeField', [], {}),
106+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
107+
'redirect_uri': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
108+
'scope': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
109+
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s.%s']" % (User._meta.app_label, User._meta.object_name)})
110+
},
111+
u'oauth2_provider.refreshtoken': {
112+
'Meta': {'object_name': 'RefreshToken'},
113+
'access_token': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "u'refresh_token'", 'unique': 'True', 'to': u"orm['oauth2_provider.AccessToken']"}),
114+
'application': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s.%s']"% (ApplicationModel._meta.app_label, ApplicationModel._meta.object_name)}),
115+
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
116+
'token': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
117+
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s.%s']" % (User._meta.app_label, User._meta.object_name)})
118+
}
119+
}
120+
121+
complete_apps = ['oauth2_provider']

0 commit comments

Comments
 (0)