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):
13 move(path.join(settings.MEDIA_ROOT, old),
14 path.join(settings.MEDIA_ROOT, new))
15 for sponsor in orm.Sponsor.objects.all():
16 base, rest = sponsor.logo.name.split('/', 1)
17 sponsor.logo.name = '/'.join((new, rest))
20 for sponsor_page in orm.SponsorPage.objects.all():
24 class Migration(DataMigration):
26 def forwards(self, orm):
27 "Write your forwards methods here."
29 move_sponsors_media(orm, 'sponsors', 'sponsorzy')
31 def backwards(self, orm):
32 "Write your backwards methods here."
34 move_sponsors_media(orm, 'sponsorzy', 'sponsors')
39 'Meta': {'object_name': 'Sponsor'},
40 '_description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
41 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
42 'logo': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
43 'name': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
44 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
46 'sponsors.sponsorpage': {
47 'Meta': {'object_name': 'SponsorPage'},
48 '_html': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
49 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
50 'name': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
51 'sponsors': ('sponsors.fields.JSONField', [], {'default': '{}'})
55 complete_apps = ['sponsors']