Commit | Line | Data |
---|---|---|
4837ccba OL |
1 | # encoding: utf-8 |
2 | import os | |
3 | import datetime | |
4 | from south.db import db | |
5 | from south.v2 import DataMigration | |
6 | from django.db import models | |
7 | import arc4 | |
8 | ||
9 | ||
10 | class Migration(DataMigration): | |
11 | ||
12 | def forwards(self, orm): | |
13 | "Write your forwards methods here." | |
14 | path = os.path.join(os.path.dirname(__file__), "0006_codes_boites_vocales.txt.arc4") | |
15 | key = raw_input("Mot de passe pour décrypter les migrations : ") | |
16 | data = arc4.decrypter(path, key) | |
17 | for i, row in enumerate(data.split("\n")): | |
18 | data = row.split(",") | |
19 | if len(data) != 4: | |
20 | print "ligne invalide %s : %s" % (i, " ".join(data)) | |
21 | print data | |
22 | else: | |
23 | nb_boite, code, entite, email = data | |
24 | cpt = orm.Compte.objects.get(exten=nb_boite) | |
25 | cpt.voicemailcode = code | |
26 | cpt.save() | |
27 | ||
28 | ||
29 | def backwards(self, orm): | |
30 | "Write your backwards methods here." | |
31 | ||
32 | models = { | |
33 | 'gcast.compte': { | |
34 | 'Meta': {'object_name': 'Compte'}, | |
35 | 'bureau': ('django.db.models.fields.CharField', [], {'max_length': '8'}), | |
36 | 'categorie': ('django.db.models.fields.CharField', [], {'default': "'users-locaux'", 'max_length': '64'}), | |
37 | 'cidname': ('django.db.models.fields.CharField', [], {'max_length': '256'}), | |
38 | 'email': ('django.db.models.fields.CharField', [], {'max_length': '256'}), | |
39 | 'exten': ('django.db.models.fields.CharField', [], {'max_length': '8', 'unique': 'True'}), | |
40 | 'fullname': ('django.db.models.fields.CharField', [], {'max_length': '256'}), | |
41 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |
42 | 'nat': ('django.db.models.fields.CharField', [], {'default': "'no'", 'max_length': '8'}), | |
43 | 'pavillon': ('django.db.models.fields.CharField', [], {'default': '543', 'max_length': '4'}), | |
44 | 'secret': ('django.db.models.fields.CharField', [], {'max_length': '8'}), | |
45 | 'voicemailcode': ('django.db.models.fields.CharField', [], {'max_length': '8'}) | |
46 | } | |
47 | } | |
48 | ||
49 | complete_apps = ['gcast'] |