You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.6 KiB
53 lines
2.6 KiB
# -*- coding: utf-8 -*-
|
|
from south.utils import datetime_utils as datetime
|
|
from south.db import db
|
|
from south.v2 import DataMigration
|
|
from django.db import models
|
|
|
|
from ..utils import extract_email
|
|
|
|
|
|
class Migration(DataMigration):
|
|
|
|
def forwards(self, orm):
|
|
"Write your forwards methods here."
|
|
# Note: Don't use "from appname.models import ModelName".
|
|
# Use orm.ModelName to refer to models in this application,
|
|
# and orm['appname.ModelName'] for models in other applications.
|
|
|
|
for entry in orm.Entry.objects.all():
|
|
user_email = extract_email(entry.email_phone)
|
|
if user_email:
|
|
entry.email = user_email
|
|
entry.save()
|
|
entry.save()
|
|
|
|
def backwards(self, orm):
|
|
"Write your backwards methods here."
|
|
raise RuntimeError("Cannot reverse this migration.")
|
|
|
|
models = {
|
|
u'guestbook.entry': {
|
|
'Meta': {'ordering': "['-pub_date', '-created_at']", 'object_name': 'Entry'},
|
|
'added_origtext': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
|
'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
|
'email': ('django.db.models.fields.EmailField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
|
|
'email_phone': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
|
'message': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
|
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
|
'notified_user': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
|
'pub_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
|
|
'published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
|
'reply': ('django.db.models.fields.TextField', [], {'default': "''", 'max_length': '2000', 'blank': 'True'}),
|
|
'updated_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
|
|
},
|
|
u'guestbook.recipient': {
|
|
'Meta': {'ordering': "['email']", 'object_name': 'Recipient'},
|
|
'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}),
|
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
|
}
|
|
}
|
|
|
|
complete_apps = ['guestbook']
|
|
symmetrical = True
|
|
|