From db0a3a39b0d5fbc7a9c40272fc3eee276af2a826 Mon Sep 17 00:00:00 2001 From: Tasos Katsoulas Date: Tue, 11 Nov 2014 16:35:24 +0200 Subject: [PATCH] [bug 1096206] Resolve invalid needinfo action items. --- .../migrations/0009_remove_old_needinfo.py | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 remo/remozilla/migrations/0009_remove_old_needinfo.py diff --git a/remo/remozilla/migrations/0009_remove_old_needinfo.py b/remo/remozilla/migrations/0009_remove_old_needinfo.py new file mode 100644 index 000000000..fd1310a8b --- /dev/null +++ b/remo/remozilla/migrations/0009_remove_old_needinfo.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + + def forwards(self, orm): + from django.contrib.contenttypes.management import update_contenttypes + from django.db.models import get_app, get_models + + update_contenttypes(get_app('remozilla'), get_models()) + name = 'Pending open questions' + + bug_type = orm['contenttypes.ContentType'].objects.get( + app_label='remozilla', model='Bug') + + needinfo_user_ids = orm['remozilla.Bug'].objects.filter( + budget_needinfo__isnull=False).values_list('budget_needinfo', flat=True) + action_items = (orm['dashboard.ActionItem'].objects + .filter(content_type=bug_type, resolved=False, name=name) + .exclude(user__id__in=needinfo_user_ids)) + + for action_item in action_items: + action_item.resolved = True + action_item.completed = True + action_item.save() + + + def backwards(self, orm): + pass + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'dashboard.actionitem': { + 'Meta': {'ordering': "['-due_date', '-updated_on', '-created_on']", 'object_name': 'ActionItem'}, + 'completed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + 'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'due_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}), + 'priority': ('django.db.models.fields.IntegerField', [], {}), + 'resolved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'updated_on': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'action_items_assigned'", 'to': u"orm['auth.User']"}) + }, + u'remozilla.bug': { + 'Meta': {'ordering': "['-bug_last_change_time']", 'object_name': 'Bug'}, + 'assigned_to': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'bugs_assigned'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': u"orm['auth.User']"}), + 'budget_needinfo': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.User']", 'symmetrical': 'False'}), + 'bug_creation_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'bug_id': ('django.db.models.fields.PositiveIntegerField', [], {'unique': 'True'}), + 'bug_last_change_time': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'cc': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'bugs_cced'", 'symmetrical': 'False', 'to': u"orm['auth.User']"}), + 'component': ('django.db.models.fields.CharField', [], {'max_length': '200'}), + 'council_member_assigned': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'council_vote_requested': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'bugs_created'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': u"orm['auth.User']"}), + 'first_comment': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'pending_mentor_validation': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'resolution': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30'}), + 'status': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30'}), + 'summary': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '500'}), + 'updated_on': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'whiteboard': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '500'}) + }, + u'remozilla.status': { + 'Meta': {'object_name': 'Status'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_updated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(1970, 1, 1, 0, 0)'}) + } + } + + complete_apps = ['remozilla'] + symmetrical = True