3 from south.db import db
4 from south.v2 import DataMigration
5 from django.db import models
7 from django.conf import settings
8 from shutil import move
12 def move_sponsors_media(orm, old, new):
14 move(path.join(settings.MEDIA_ROOT, old),
15 path.join(settings.MEDIA_ROOT, new))
17 # there could be no sponsors directory yet
19 for sponsor in orm.Sponsor.objects.all():
20 base, rest = sponsor.logo.name.split('/', 1)
21 sponsor.logo.name = '/'.join((new, rest))
24 for sponsor_page in orm.SponsorPage.objects.all():
28 class Migration(DataMigration):
30 def forwards(self, orm):
31 "Write your forwards methods here."
33 move_sponsors_media(orm, 'sponsors', 'sponsorzy')
35 def backwards(self, orm):
36 "Write your backwards methods here."
38 move_sponsors_media(orm, 'sponsorzy', 'sponsors')
43 'Meta': {'object_name': 'Sponsor'},
44 '_description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
45 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
46 'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
47 'name': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
48 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
50 'sponsors.sponsorpage': {
51 'Meta': {'object_name': 'SponsorPage'},
52 '_html': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
53 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
54 'name': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
55 'sponsors': ('sponsors.fields.JSONField', [], {'default': '{}'})
59 complete_apps = ['sponsors']