def begin_speach(self): """ Let the person speak. Set the weight to None and the time to now. If anyone is still speaking, end his speach. """ try: actual_speaker = Speaker.objects.filter( item=self.item, end_time=None).exclude(begin_time=None).get() except Speaker.DoesNotExist: pass else: actual_speaker.end_speach() self.weight = None self.begin_time = datetime.now() self.save() # start countdown if config['agenda_couple_countdown_and_speakers']: reset_countdown() start_countdown() if self.item.is_active_slide(): # TODO: only update the overlay if the overlay is active and # slide type is None. update_projector_overlay('projector_countdown')
def get(self, request, *args, **kwargs): if self.test_poll(): self.result = stop_voting() update_personal_votes(poll=self.poll) # Reset overlay message update_projector_overlay('votecollector_message') return super(StopVoting, self).get(request, *args, **kwargs)
def check_and_update_projector(self): """ Checks, if the agenda item, or parts of it, is on the projector. If yes, it updates the projector. """ if self.item.is_active_slide(): if get_active_slide().get('type', None) == 'list_of_speakers': update_projector() else: update_projector_overlay('agenda_speaker')
def check_and_update_projector(self): """ Checks, if the agenda item, or parts of it, is on the projector. If yes, it updates the projector. """ if self.item.is_active_slide(): if get_active_slide().get('type', None) == 'list_of_speakers': update_projector() else: update_projector_overlay('agenda_speaker')
def end_speach(self): """ The speach is finished. Set the time to now. """ self.end_time = datetime.now() self.save() # stop countdown if config['agenda_couple_countdown_and_speakers']: stop_countdown() if self.item.is_active_slide(): # TODO: only update the overlay if the overlay is active and # slide type is None. update_projector_overlay('projector_countdown')
def end_speach(self): """ The speach is finished. Set the time to now. """ self.end_time = datetime.now() self.save() # stop countdown if config['agenda_couple_countdown_and_speakers']: stop_countdown() if self.item.is_active_slide(): # TODO: only update the overlay if the overlay is active and # slide type is None. update_projector_overlay('projector_countdown')
def test_update_projector_overlay(self, mock_ProjectorSocketHandler, mock_get_overlays): mock_overlay = MagicMock() mock_overlay.name = 'mock_overlay_name' mock_overlay.get_projector_html.return_value = 'mock_html_code' mock_overlay.get_javascript.return_value = 'mock_javascript' mock_get_overlays.return_value = {'mock_overlay': mock_overlay} # Test with active overlay mock_overlay.is_active.return_value = False projector_api.update_projector_overlay(None) mock_ProjectorSocketHandler.send_updates.assert_called_with( {'overlays': {'mock_overlay_name': None}}) # Test with active overlay mock_overlay.is_active.return_value = True projector_api.update_projector_overlay(None) expected_data = {'overlays': {'mock_overlay_name': { 'html': 'mock_html_code', 'javascript': 'mock_javascript'}}} mock_ProjectorSocketHandler.send_updates.assert_called_with(expected_data) # Test with overlay name as argument projector_api.update_projector_overlay('mock_overlay') mock_ProjectorSocketHandler.send_updates.assert_called_with(expected_data) # Test with overlay object as argument projector_api.update_projector_overlay(mock_overlay) mock_ProjectorSocketHandler.send_updates.assert_called_with(expected_data)
def test_update_projector_overlay(self, mock_ProjectorSocketHandler, mock_get_overlays): mock_overlay = MagicMock() mock_overlay.name = 'mock_overlay_name' mock_overlay.get_projector_html.return_value = 'mock_html_code' mock_overlay.get_javascript.return_value = 'mock_javascript' mock_get_overlays.return_value = {'mock_overlay': mock_overlay} # Test with active overlay mock_overlay.is_active.return_value = False projector_api.update_projector_overlay(None) mock_ProjectorSocketHandler.send_updates.assert_called_with( {'overlays': {'mock_overlay_name': None}}) # Test with active overlay mock_overlay.is_active.return_value = True projector_api.update_projector_overlay(None) expected_data = {'overlays': {'mock_overlay_name': { 'html': 'mock_html_code', 'javascript': 'mock_javascript'}}} mock_ProjectorSocketHandler.send_updates.assert_called_with(expected_data) # Test with overlay name as argument projector_api.update_projector_overlay('mock_overlay') mock_ProjectorSocketHandler.send_updates.assert_called_with(expected_data) # Test with overlay object as argument projector_api.update_projector_overlay(mock_overlay) mock_ProjectorSocketHandler.send_updates.assert_called_with(expected_data)
def check_and_update_projector(self): """ Checks, if the agenda item, or parts of it, is on the projector. If yes, it updates the projector. """ active_slide = get_active_slide() active_slide_pk = active_slide.get('pk', None) slide_type = active_slide.get('type', None) if (active_slide['callback'] == 'agenda' and unicode(self.item_id) == unicode(active_slide_pk)): if slide_type == 'list_of_speakers': update_projector() elif slide_type is None: update_projector_overlay('agenda_speaker')
def begin_speach(self): """ Let the user speak. Set the weight to None and the time to now. If anyone is still speaking, end his speach. """ try: actual_speaker = Speaker.objects.filter(item=self.item, end_time=None).exclude(begin_time=None).get() except Speaker.DoesNotExist: pass else: actual_speaker.end_speach() self.weight = None self.begin_time = datetime.now() self.save() # start countdown if config['agenda_couple_countdown_and_speakers']: reset_countdown() start_countdown() if self.item.is_active_slide(): # TODO: only update the overlay if the overlay is active and # slide type is None. update_projector_overlay('projector_countdown')
poll = self.get_poll() if poll is None: self.error = _('Unknown poll.') elif config['votecollector_in_vote'] == poll.id: self.error = _('Poll already started.') elif config['votecollector_in_vote']: self.error = _('Another poll is running.') else: self.error = None try: self.result = start_voting(poll.id) except VoteCollectorError, err: self.error = err.value else: # Refresh the overlay message. update_projector_overlay('votecollector_message') # Clear poll results (only Yes, No and Abstain are cleared, not VotesValid, VotsInvalid, VotesCast) poll.get_votes().delete() return super(StartVoting, self).get(request, *args, **kwargs) def no_error_context(self): return {'count': self.result} class StopVoting(VotingView): """ Stops a poll. """ def get(self, request, *args, **kwargs): if self.test_poll(): self.result = stop_voting()