This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #855 from akatsoulas/remove-vote-actions
[fix bug 1096206] Resolve old action items for voting objects.
- Loading branch information
Showing
1 changed file
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
# -*- 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.utils.timezone import now | ||
from django.contrib.contenttypes.management import update_contenttypes | ||
from django.db.models import get_app, get_models | ||
|
||
update_contenttypes(get_app('voting'), get_models()) | ||
|
||
poll_type = orm['contenttypes.ContentType'].objects.get( | ||
app_label='voting', model='Poll') | ||
|
||
# Close old polls | ||
polls_ids = (orm['voting.Poll'].objects.filter(end__lt=now()) | ||
.values_list('id', flat=True)) | ||
action_items = orm['dashboard.ActionItem'].objects.filter( | ||
content_type=poll_type, object_id__in=polls_ids, resolved=False) | ||
for action_item in action_items: | ||
user = action_item.user | ||
poll = orm['voting.Poll'].objects.get(pk=action_item.object_id) | ||
if orm['voting.Vote'].objects.filter(user=user, poll=poll).exists(): | ||
action_item.completed = True | ||
action_item.resolved = 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'voting.poll': { | ||
'Meta': {'ordering': "['-created_on']", 'object_name': 'Poll'}, | ||
'automated_poll': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | ||
'bug': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['remozilla.Bug']", 'null': 'True', 'blank': 'True'}), | ||
'comments_allowed': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), | ||
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'range_polls_created'", 'to': u"orm['auth.User']"}), | ||
'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
'description': ('django.db.models.fields.TextField', [], {}), | ||
'end': ('django.db.models.fields.DateTimeField', [], {}), | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'is_extended': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | ||
'name': ('django.db.models.fields.CharField', [], {'max_length': '300'}), | ||
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}), | ||
'start': ('django.db.models.fields.DateTimeField', [], {}), | ||
'task_end_id': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'null': 'True', 'blank': 'True'}), | ||
'task_start_id': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '256', 'null': 'True', 'blank': 'True'}), | ||
'users_voted': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'polls_voted'", 'symmetrical': 'False', 'through': u"orm['voting.Vote']", 'to': u"orm['auth.User']"}), | ||
'valid_groups': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'valid_polls'", 'to': u"orm['auth.Group']"}) | ||
}, | ||
u'voting.pollcomment': { | ||
'Meta': {'ordering': "['created_on']", 'object_name': 'PollComment'}, | ||
'comment': ('django.db.models.fields.TextField', [], {}), | ||
'created_on': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'poll': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comments'", 'to': u"orm['voting.Poll']"}), | ||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}) | ||
}, | ||
u'voting.radiopoll': { | ||
'Meta': {'object_name': 'RadioPoll'}, | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'poll': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'radio_polls'", 'to': u"orm['voting.Poll']"}), | ||
'question': ('django.db.models.fields.CharField', [], {'max_length': '500'}) | ||
}, | ||
u'voting.radiopollchoice': { | ||
'Meta': {'ordering': "['-votes']", 'object_name': 'RadioPollChoice'}, | ||
'answer': ('django.db.models.fields.CharField', [], {'max_length': '500'}), | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'radio_poll': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'answers'", 'to': u"orm['voting.RadioPoll']"}), | ||
'votes': ('django.db.models.fields.IntegerField', [], {'default': '0'}) | ||
}, | ||
u'voting.rangepoll': { | ||
'Meta': {'object_name': 'RangePoll'}, | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '500'}), | ||
'poll': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'range_polls'", 'to': u"orm['voting.Poll']"}) | ||
}, | ||
u'voting.rangepollchoice': { | ||
'Meta': {'ordering': "['-votes', 'nominee__last_name', 'nominee__first_name']", 'object_name': 'RangePollChoice'}, | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'nominee': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}), | ||
'range_poll': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'choices'", 'to': u"orm['voting.RangePoll']"}), | ||
'votes': ('django.db.models.fields.IntegerField', [], {'default': '0'}) | ||
}, | ||
u'voting.vote': { | ||
'Meta': {'object_name': 'Vote'}, | ||
'date_voted': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}), | ||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'poll': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['voting.Poll']"}), | ||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}) | ||
} | ||
} | ||
|
||
complete_apps = ['voting'] | ||
symmetrical = True |