|
91
|
1 |
# -*- coding: utf-8 -*- |
|
|
2 |
from south.v2 import DataMigration |
|
|
3 |
from hp.utils import get_all_objects |
|
|
4 |
from hp import settings |
|
|
5 |
|
|
|
6 |
class Migration(DataMigration): |
|
|
7 |
|
|
|
8 |
def forwards(self, orm): |
|
|
9 |
url = settings.LDT_API_URL + "contents/" |
|
|
10 |
contents = get_all_objects(url, {'limit':settings.LDT_MAX_FETCH}, None) |
|
|
11 |
|
|
|
12 |
title_dict = dict([(c.get('iri_id',''), c.get('title','')) for c in contents]) |
|
|
13 |
|
|
|
14 |
for rel in orm.VideoKCRel.objects.all(): |
|
|
15 |
rel.content_title = title_dict.get(rel.iri_id,None) |
|
|
16 |
rel.save() |
|
|
17 |
|
|
|
18 |
def backwards(self, orm): |
|
|
19 |
for rel in orm.VideoKCRel.objects.all(): |
|
|
20 |
rel.content_title = None |
|
|
21 |
rel.save() |
|
|
22 |
|
|
|
23 |
models = { |
|
|
24 |
'hp.videokcrel': { |
|
|
25 |
'Meta': {'object_name': 'VideoKCRel'}, |
|
|
26 |
'content_title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), |
|
|
27 |
'graph_id': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), |
|
|
28 |
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|
|
29 |
'iri_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), |
|
|
30 |
'project_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), |
|
|
31 |
'topic_id': ('django.db.models.fields.CharField', [], {'max_length': '1024'}) |
|
|
32 |
} |
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
complete_apps = ['hp'] |
|
|
36 |
symmetrical = True |