Commit 7302bb16b5753b5d7216c07b074eb7ffcb4b7079
1 parent
eb6eb08a
Exists in
master
and in
39 other branches
Fixing twitter and facebook accounts. Updates #28
Showing
1 changed file
with
67 additions
and
0 deletions
Show diff stats
src/accounts/migrations/0005_remove_host_from_social_accounts.py
0 → 100644
@@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
1 | +# -*- coding: utf-8 -*- | ||
2 | +import datetime | ||
3 | +from south.db import db | ||
4 | +from south.v2 import DataMigration | ||
5 | +from django.db import models | ||
6 | + | ||
7 | +class Migration(DataMigration): | ||
8 | + | ||
9 | + def forwards(self, orm): | ||
10 | + for user in orm.User.objects.iterator(): | ||
11 | + if user.twitter: | ||
12 | + user.twitter = user.twitter.split('/')[-1] | ||
13 | + if user.facebook: | ||
14 | + user.facebook = user.facebook.split('/')[-1] | ||
15 | + user.save() | ||
16 | + | ||
17 | + def backwards(self, orm): | ||
18 | + "Write your backwards methods here." | ||
19 | + | ||
20 | + models = { | ||
21 | + u'accounts.user': { | ||
22 | + 'Meta': {'object_name': 'User'}, | ||
23 | + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | ||
24 | + 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75', 'blank': 'True'}), | ||
25 | + 'facebook': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
26 | + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | ||
27 | + 'google_talk': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), | ||
28 | + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), | ||
29 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
30 | + 'institution': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
31 | + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), | ||
32 | + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | ||
33 | + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | ||
34 | + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | ||
35 | + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | ||
36 | + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | ||
37 | + 'role': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
38 | + 'twitter': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
39 | + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), | ||
40 | + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}), | ||
41 | + 'verification_hash': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}), | ||
42 | + 'webpage': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}) | ||
43 | + }, | ||
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'contenttypes.contenttype': { | ||
58 | + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, | ||
59 | + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
60 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
61 | + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
62 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + complete_apps = ['accounts'] | ||
67 | + symmetrical = True |