Merge pull request #1182 from normanjaeckel/CoupleAssignmentListOfSpeakers
Coupled assignment candidates with list of speakers. Fixed #1092.
This commit is contained in:
commit
f60f668471
@ -8,6 +8,8 @@ Version 1.6 (unreleased)
|
||||
========================
|
||||
[https://github.com/OpenSlides/OpenSlides/issues?milestone=14]
|
||||
|
||||
Assignment:
|
||||
- Coupled assignment candidates with list of speakers.
|
||||
Participants:
|
||||
- Disabled widgets by default.
|
||||
- Added form field for multiple creation of new participants.
|
||||
|
2
fabfile.py
vendored
2
fabfile.py
vendored
@ -25,7 +25,7 @@ def coverage_report_plain():
|
||||
Runs all tests and prints the coverage report.
|
||||
"""
|
||||
test()
|
||||
local('coverage report -m --fail-under=76')
|
||||
local('coverage report -m --fail-under=77')
|
||||
|
||||
|
||||
def coverage():
|
||||
|
@ -1,16 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext_lazy, ugettext_noop
|
||||
|
||||
from openslides.agenda.models import Item, Speaker
|
||||
from openslides.config.api import config
|
||||
from openslides.poll.models import (BaseOption, BasePoll, BaseVote,
|
||||
CollectInvalid, CollectVotesCast,
|
||||
PublishPollMixin)
|
||||
from openslides.projector.models import RelatedModelMixin, SlideMixin
|
||||
from openslides.utils.exceptions import OpenSlidesError
|
||||
from openslides.utils.models import AbsoluteUrlMixin
|
||||
from openslides.utils.person import PersonField
|
||||
from openslides.utils.utils import html_strong
|
||||
@ -192,9 +195,25 @@ class Assignment(SlideMixin, AbsoluteUrlMixin, models.Model):
|
||||
return person in self.elected
|
||||
|
||||
def gen_poll(self):
|
||||
"""
|
||||
Creates an new poll for the assignment and adds all candidates to all
|
||||
lists of speakers of related agenda items.
|
||||
"""
|
||||
poll = AssignmentPoll.objects.create(
|
||||
assignment=self, description=self.poll_description_default)
|
||||
poll.set_options([{'candidate': person} for person in self.candidates])
|
||||
items = Item.objects.filter(content_type=ContentType.objects.get_for_model(Assignment), object_id=self.pk)
|
||||
for item in items:
|
||||
someone_added = None
|
||||
for candidate in self.candidates:
|
||||
try:
|
||||
someone_added = Speaker.objects.add(candidate, item)
|
||||
except OpenSlidesError:
|
||||
# The Speaker is already on the list. Do nothing.
|
||||
# TODO: Find a smart way not to catch the error concerning AnonymousUser.
|
||||
pass
|
||||
if someone_added is not None:
|
||||
someone_added.check_and_update_projector()
|
||||
return poll
|
||||
|
||||
def vote_results(self, only_published):
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from django.test.client import Client
|
||||
|
||||
from openslides.agenda.models import Item
|
||||
from openslides.agenda.models import Item, Speaker
|
||||
from openslides.assignment.models import Assignment
|
||||
from openslides.participant.models import User
|
||||
from openslides.utils.test import TestCase
|
||||
@ -22,3 +22,20 @@ class AssignmentModelTest(TestCase):
|
||||
self.assertEqual(Item.objects.get(pk=1).get_title(), 'assignment_name_fgdhensbch34zfu1284ds')
|
||||
assignment.delete()
|
||||
self.assertTrue(Item.objects.filter(pk=1).exists())
|
||||
|
||||
def test_begin_speach(self):
|
||||
assignment = Assignment.objects.create(name='test_assignment_gjbnchs4620sdfhjfsksj1', posts=1)
|
||||
item = Item.objects.create(content_object=assignment)
|
||||
person_1 = User.objects.create(username='user_1_bnhdjgd8747djcbjd8fg')
|
||||
person_2 = User.objects.create(username='user_2_qmlkohid6qvx5q0fbmh9')
|
||||
person_3 = User.objects.create(username='user_3_nbjf74jf9bjag219ou96')
|
||||
assignment.run(person_1, person_1)
|
||||
assignment.run(person_2, person_2)
|
||||
assignment.run(person_3, person_3)
|
||||
Speaker.objects.add(person_1, item)
|
||||
self.assertEqual(item.speaker_set.count(), 1)
|
||||
|
||||
assignment.gen_poll()
|
||||
self.assertTrue(item.speaker_set.filter(person=person_1).exists())
|
||||
self.assertTrue(item.speaker_set.filter(person=person_2).exists())
|
||||
self.assertTrue(item.speaker_set.filter(person=person_3).exists())
|
||||
|
Loading…
Reference in New Issue
Block a user