PageRenderTime 55ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/apps/users/migrations/0028_migrate_profile_picture_path.py

https://github.com/lmorchard/mozillians
Python | 123 lines | 120 code | 2 blank | 1 comment | 0 complexity | 34ccb22cfaf2efa1e58e2e719d74166a MD5 | raw file
  1. # encoding: utf-8
  2. import datetime
  3. import os
  4. from south.db import db
  5. from south.v2 import DataMigration
  6. from django.db import models
  7. class Migration(DataMigration):
  8. def forwards(self, orm):
  9. """Prepend 'uploads' to profile photo path."""
  10. queryset = orm['users.UserProfile'].objects.exclude(photo='')
  11. for profile in queryset:
  12. profile.photo.name = os.path.join('uploads', profile.photo.name)
  13. profile.save()
  14. def backwards(self, orm):
  15. """Remove 'uploads' from profile photo path."""
  16. queryset = orm['users.UserProfile'].objects.exclude(photo='')
  17. for profile in queryset:
  18. profile.photo.name = profile.photo.name[8:]
  19. profile.save()
  20. models = {
  21. 'auth.group': {
  22. 'Meta': {'object_name': 'Group'},
  23. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  24. 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
  25. 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
  26. },
  27. 'auth.permission': {
  28. 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
  29. 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  30. 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
  31. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  32. 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
  33. },
  34. 'auth.user': {
  35. 'Meta': {'object_name': 'User'},
  36. 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 2, 13, 2, 22, 40, 378533)'}),
  37. 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
  38. 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
  39. 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
  40. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  41. 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
  42. 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  43. 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  44. 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 2, 13, 2, 22, 40, 378473)'}),
  45. 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
  46. 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
  47. 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
  48. 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
  49. },
  50. 'contenttypes.contenttype': {
  51. 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
  52. 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  53. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  54. 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  55. 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
  56. },
  57. 'groups.group': {
  58. 'Meta': {'object_name': 'Group', 'db_table': "'group'"},
  59. 'always_auto_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  60. 'auto_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
  61. 'description': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
  62. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  63. 'irc_channel': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '63', 'blank': 'True'}),
  64. 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
  65. 'steward': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['users.UserProfile']", 'null': 'True', 'blank': 'True'}),
  66. 'system': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
  67. 'url': ('autoslug.fields.AutoSlugField', [], {'unique_with': '()', 'max_length': '50', 'blank': 'True', 'unique': 'True', 'populate_from': "'name'", 'db_index': 'True'}),
  68. 'website': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
  69. 'wiki': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'})
  70. },
  71. 'groups.language': {
  72. 'Meta': {'object_name': 'Language'},
  73. 'always_auto_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  74. 'auto_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
  75. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  76. 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
  77. 'url': ('autoslug.fields.AutoSlugField', [], {'unique_with': '()', 'max_length': '50', 'blank': 'True', 'unique': 'True', 'populate_from': "'name'", 'db_index': 'True'})
  78. },
  79. 'groups.skill': {
  80. 'Meta': {'object_name': 'Skill'},
  81. 'always_auto_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  82. 'auto_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
  83. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  84. 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
  85. 'url': ('autoslug.fields.AutoSlugField', [], {'unique_with': '()', 'max_length': '50', 'blank': 'True', 'unique': 'True', 'populate_from': "'name'", 'db_index': 'True'})
  86. },
  87. 'users.usernameblacklist': {
  88. 'Meta': {'ordering': "['value']", 'object_name': 'UsernameBlacklist'},
  89. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  90. 'is_regex': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  91. 'value': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
  92. },
  93. 'users.userprofile': {
  94. 'Meta': {'ordering': "['full_name']", 'object_name': 'UserProfile', 'db_table': "'profile'"},
  95. 'allows_community_sites': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
  96. 'allows_mozilla_sites': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
  97. 'basket_token': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1024', 'blank': 'True'}),
  98. 'bio': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
  99. 'city': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
  100. 'country': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
  101. 'full_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
  102. 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['groups.Group']", 'symmetrical': 'False', 'blank': 'True'}),
  103. 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  104. 'ircname': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '63', 'blank': 'True'}),
  105. 'is_vouched': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  106. 'languages': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['groups.Language']", 'symmetrical': 'False', 'blank': 'True'}),
  107. 'last_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'auto_now': 'True', 'blank': 'True'}),
  108. 'photo': ('sorl.thumbnail.fields.ImageField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}),
  109. 'region': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}),
  110. 'skills': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['groups.Skill']", 'symmetrical': 'False', 'blank': 'True'}),
  111. 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}),
  112. 'vouched_by': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['users.UserProfile']", 'null': 'True', 'blank': 'True'}),
  113. 'website': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'})
  114. }
  115. }
  116. complete_apps = ['users']