| 1 | # encoding: utf-8 |
|---|
| 2 | import datetime |
|---|
| 3 | from south.db import db |
|---|
| 4 | from south.v2 import DataMigration |
|---|
| 5 | import django.contrib.auth.hashers |
|---|
| 6 | from django.db import models |
|---|
| 7 | from django.db.models import F |
|---|
| 8 | |
|---|
| 9 | class Migration(DataMigration): |
|---|
| 10 | |
|---|
| 11 | def forwards(self, orm): |
|---|
| 12 | "Write your forwards methods here." |
|---|
| 13 | issues = orm['auth.user'].objects.filter(password__in=['', 'SocketAuth']) |
|---|
| 14 | try: # pre-1.6 |
|---|
| 15 | new_password = django.contrib.auth.hashers.UNUSABLE_PASSWORD |
|---|
| 16 | except AttributeError: # post-1.6 |
|---|
| 17 | # See https://code.djangoproject.com/ticket/20079 for details on the change. |
|---|
| 18 | # Ideally, we'd use a different suffix per user, but I don't want |
|---|
| 19 | # to deal with that, and this is probably acceptably secure. |
|---|
| 20 | # |
|---|
| 21 | # Also, it seems a little unlikely that this code will actually |
|---|
| 22 | # run -- it requires an install that hasn't already run the |
|---|
| 23 | # migration (notably, esp.mit.edu has already), but *does* have |
|---|
| 24 | # accounts with SocketAuth passwords. |
|---|
| 25 | prefix = django.contrib.auth.hashers.UNUSABLE_PASSWORD_PREFIX |
|---|
| 26 | suffix = django.contrib.auth.hashers.get_random_string(django.contrib.auth.hashers.UNUSABLE_PASSWORD_SUFFIX_LENGTH) |
|---|
| 27 | new_password = prefix + F("password") + prefix + suffix |
|---|
| 28 | issues.update(password=new_password) |
|---|
| 29 | |
|---|
| 30 | def backwards(self, orm): |
|---|
| 31 | "Write your backwards methods here." |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | models = { |
|---|
| 35 | 'auth.group': { |
|---|
| 36 | 'Meta': {'object_name': 'Group'}, |
|---|
| 37 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 38 | 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), |
|---|
| 39 | 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) |
|---|
| 40 | }, |
|---|
| 41 | 'auth.permission': { |
|---|
| 42 | 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, |
|---|
| 43 | 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), |
|---|
| 44 | 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), |
|---|
| 45 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 46 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) |
|---|
| 47 | }, |
|---|
| 48 | 'auth.user': { |
|---|
| 49 | 'Meta': {'object_name': 'User'}, |
|---|
| 50 | 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 1, 25, 17, 25, 58, 606126)'}), |
|---|
| 51 | 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), |
|---|
| 52 | 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), |
|---|
| 53 | 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), |
|---|
| 54 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 55 | 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), |
|---|
| 56 | 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), |
|---|
| 57 | 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), |
|---|
| 58 | 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 1, 25, 17, 25, 58, 606042)'}), |
|---|
| 59 | 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), |
|---|
| 60 | 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), |
|---|
| 61 | 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), |
|---|
| 62 | 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) |
|---|
| 63 | }, |
|---|
| 64 | 'contenttypes.contenttype': { |
|---|
| 65 | 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, |
|---|
| 66 | 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), |
|---|
| 67 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 68 | 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), |
|---|
| 69 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) |
|---|
| 70 | }, |
|---|
| 71 | 'finance_core.budgetarea': { |
|---|
| 72 | 'Meta': {'ordering': "['path']", 'object_name': 'BudgetArea'}, |
|---|
| 73 | 'account_number': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), |
|---|
| 74 | 'always': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), |
|---|
| 75 | 'budget_term': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['finance_core.BudgetTerm']", 'through': "orm['finance_core.BudgetAreaTerm']", 'symmetrical': 'False'}), |
|---|
| 76 | 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}), |
|---|
| 77 | 'depth': ('django.db.models.fields.PositiveIntegerField', [], {}), |
|---|
| 78 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 79 | 'interested': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), |
|---|
| 80 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), |
|---|
| 81 | 'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), |
|---|
| 82 | 'owner': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), |
|---|
| 83 | 'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), |
|---|
| 84 | 'use_owner': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) |
|---|
| 85 | }, |
|---|
| 86 | 'finance_core.budgetareaterm': { |
|---|
| 87 | 'Meta': {'object_name': 'BudgetAreaTerm'}, |
|---|
| 88 | 'budget_area': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['finance_core.BudgetArea']"}), |
|---|
| 89 | 'budget_term': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['finance_core.BudgetTerm']"}), |
|---|
| 90 | 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}), |
|---|
| 91 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) |
|---|
| 92 | }, |
|---|
| 93 | 'finance_core.budgetterm': { |
|---|
| 94 | 'Meta': {'object_name': 'BudgetTerm'}, |
|---|
| 95 | 'end_date': ('django.db.models.fields.DateField', [], {}), |
|---|
| 96 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 97 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '20'}), |
|---|
| 98 | 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '20', 'db_index': 'True'}), |
|---|
| 99 | 'start_date': ('django.db.models.fields.DateField', [], {}), |
|---|
| 100 | 'submit_deadline': ('django.db.models.fields.DateField', [], {}) |
|---|
| 101 | }, |
|---|
| 102 | 'finance_core.lineitem': { |
|---|
| 103 | 'Meta': {'object_name': 'LineItem'}, |
|---|
| 104 | 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '7', 'decimal_places': '2'}), |
|---|
| 105 | 'budget_area': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['finance_core.BudgetArea']"}), |
|---|
| 106 | 'budget_term': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['finance_core.BudgetTerm']"}), |
|---|
| 107 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 108 | 'label': ('django.db.models.fields.CharField', [], {'max_length': '60'}), |
|---|
| 109 | 'layer': ('django.db.models.fields.IntegerField', [], {}), |
|---|
| 110 | 'tx': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['finance_core.Transaction']"}) |
|---|
| 111 | }, |
|---|
| 112 | 'finance_core.transaction': { |
|---|
| 113 | 'Meta': {'object_name': 'Transaction'}, |
|---|
| 114 | 'desc': ('django.db.models.fields.TextField', [], {'blank': 'True'}), |
|---|
| 115 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), |
|---|
| 116 | 'incurred_time': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), |
|---|
| 117 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '60'}), |
|---|
| 118 | 'tx_create_time': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}) |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | complete_apps = ['auth', 'finance_core'] |
|---|