Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #841 from johngian/fix-resolve-polls
Browse files Browse the repository at this point in the history
[Fix bug 1090402] Resolve actions items after voting for a budget poll.
  • Loading branch information
johngian committed Oct 29, 2014
2 parents 7e188b6 + 96b1d3b commit ca6179c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
19 changes: 19 additions & 0 deletions remo/dashboard/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ def test_vote_action_item(self):
ok_(item.priority, ActionItem.NORMAL)
ok_(not item.completed)

def test_budget_vote_action_item(self):
model = ContentType.objects.get_for_model(Poll)
items = ActionItem.objects.filter(content_type=model)
ok_(not items.exists())

council = Group.objects.get(name='Council')
user = UserFactory.create(groups=['Council'])
bug = BugFactory.create()
PollFactory.create(valid_groups=council, automated_poll=True, bug=bug)

items = ActionItem.objects.filter(content_type=model)
eq_(items.count(), 1)

for item in items:
eq_(item.name, 'Cast your vote for budget request')
eq_(item.user, user)
ok_(item.priority, ActionItem.NORMAL)
ok_(not item.completed)

def test_resolve_vote_action_item(self):
model = ContentType.objects.get_for_model(Poll)
items = ActionItem.objects.filter(content_type=model)
Expand Down
2 changes: 1 addition & 1 deletion remo/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def save(self, *args, **kwargs):
# Resolve action items for post event metrics
ActionItem.resolve(instance=self.event,
user=self.event.owner,
name='Submit post event metrics')
name=SUBMIT_POST_EVENT_METRICS_ACTION)


class EventComment(models.Model):
Expand Down
4 changes: 2 additions & 2 deletions remo/profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from remo.base.tasks import send_remo_mail
from remo.base.utils import add_permissions_to_groups
from remo.dashboard.models import ActionItem
from remo.remozilla.models import Bug
from remo.remozilla.models import Bug, WAITING_MENTOR_VALIDATION_ACTION

DISPLAY_NAME_MAX_LENGTH = 50

Expand Down Expand Up @@ -374,7 +374,7 @@ def update_mentor_action_items(sender, instance, raw, **kwargs):
user_profile = get_object_or_none(UserProfile, user=instance.user)
if user_profile and not raw:
if user_profile.mentor and user_profile.mentor != instance.mentor:
action_name = 'Waiting mentor validation'
action_name = WAITING_MENTOR_VALIDATION_ACTION
action_model = ContentType.objects.get_for_model(Bug)
action_items = ActionItem.objects.filter(content_type=action_model,
name=action_name,
Expand Down
6 changes: 3 additions & 3 deletions remo/remozilla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ def set_uppercase_pre_save(sender, instance, **kwargs):
def update_budget_needinfo_action_items(sender, instance, action, pk_set,
**kwargs):
"""Update ActionItem objects on needinfo change."""
name = 'Pending open questions'
if action == 'post_remove':
for pk in pk_set:
ActionItem.resolve(instance=instance, user=User.objects.get(pk=pk),
name=name)
name=NEEDINFO_ACTION)

if action == 'post_clear':
for user in instance.budget_needinfo.all():
ActionItem.resolve(instance=instance, user=user, name=name)
ActionItem.resolve(instance=instance, user=user,
name=NEEDINFO_ACTION)

if action == 'post_add':
ActionItem.create(instance=instance)
8 changes: 6 additions & 2 deletions remo/voting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ def __unicode__(self):
return '%s %s' % (self.user, self.poll)

def save(self, *args, **kwargs):
ActionItem.resolve(instance=self.poll, user=self.user,
name='Cast your vote')
if self.poll.automated_poll:
ActionItem.resolve(instance=self.poll, user=self.user,
name=BUDGET_VOTE_ACTION)
else:
ActionItem.resolve(instance=self.poll, user=self.user,
name=VOTE_ACTION)

super(Vote, self).save(*args, **kwargs)

Expand Down

0 comments on commit ca6179c

Please sign in to comment.