def post(self, request, *args, **kwargs): if not request.user.has_perm('agenda.can_manage_agenda'): messages.error( request, _('You are not authorized to manage the agenda.')) context = self.get_context_data(**kwargs) return self.render_to_response(context) transaction.commit() for item in Item.objects.all(): form = ItemOrderForm(request.POST, prefix="i%d" % item.id) if form.is_valid(): try: parent = Item.objects.get(id=form.cleaned_data['parent']) except Item.DoesNotExist: parent = None item.weight = form.cleaned_data['weight'] item.parent = parent Model.save(item) else: transaction.rollback() messages.error( request, _('Errors when reordering of the agenda')) break else: Item.objects.rebuild() # TODO: assure, that it is a valid tree context = self.get_context_data(**kwargs) transaction.commit() if get_active_slide()['callback'] == 'agenda': update_projector() context = self.get_context_data(**kwargs) transaction.commit() return self.render_to_response(context)
def post(self, request, *args, **kwargs): if not request.user.has_perm('agenda.can_manage_agenda'): messages.error(request, _('You are not authorized to manage the agenda.')) context = self.get_context_data(**kwargs) return self.render_to_response(context) transaction.commit() for item in Item.objects.all(): form = ItemOrderForm(request.POST, prefix="i%d" % item.id) if form.is_valid(): try: parent = Item.objects.get(id=form.cleaned_data['parent']) except Item.DoesNotExist: parent = None item.weight = form.cleaned_data['weight'] item.parent = parent Model.save(item) else: transaction.rollback() messages.error(request, _('Errors when reordering of the agenda')) break else: Item.objects.rebuild() # TODO: assure, that it is a valid tree context = self.get_context_data(**kwargs) transaction.commit() if get_active_slide()['callback'] == 'agenda': update_projector() context = self.get_context_data(**kwargs) transaction.commit() return self.render_to_response(context)
def save(self, *args, **kwargs): super(Item, self).save(*args, **kwargs) active_slide = get_active_slide() active_slide_pk = active_slide.get('pk', None) if (active_slide['callback'] == 'agenda' and unicode(self.parent_id) == unicode(active_slide_pk)): update_projector()
def delete(self, *args, **kwargs): """ Updates the projector, if the object is on the projector and is deleted. """ from openslides.projector.api import update_projector value = super(SlideMixin, self).delete(*args, **kwargs) if self.is_active_slide(): update_projector() return value
def set_elected(self, person, value=True): candidate = self.assignment_candidates.get(person=person) candidate.elected = value candidate.save() # update projector if assignment or assignmentpoll slide is active active_object = get_active_object() if (type(active_object) is type(self) and active_object.pk == self.pk) or \ (type(active_object) is AssignmentPoll and active_object.assignment_id == self.pk): update_projector()
def delete(self, *args, **kwargs): """ Deletes the model and updates the projector, if the motion in on it. """ from .api import update_projector value = super(RelatedModelMixin, self).delete(*args, **kwargs) if self.get_related_model().is_active_slide(): update_projector() return value
def save(self, *args, **kwargs): """ Updates the projector if a topicvoting slide is on it. """ value = super(Category, self).save(*args, **kwargs) callback = get_active_slide()['callback'] if callback == 'topicvoting_category_list' or callback == 'topicvoting_result': update_projector() return value
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 save(self, *args, **kwargs): """ Updates the projector if a topicvoting slide is on it. """ # TODO: Look for all cases and switch off unused update value = super(Topic, self).save(*args, **kwargs) callback = get_active_slide()['callback'] if callback and callback.startswith('topicvoting'): update_projector() return value
def form_valid(self, form): """ Saves the CreateForm or UpdateForm into a motion object. """ self.object = form.save(commit=False) try: self.object.category = form.cleaned_data['category'] except KeyError: pass try: self.object.identifier = form.cleaned_data['identifier'] except KeyError: pass self.manipulate_object(form) for attr in ['title', 'text', 'reason']: setattr(self.version, attr, form.cleaned_data[attr]) self.object.save(use_version=self.version) # Save the submitter an the supporter so the motion. # TODO: Only delete and save neccessary submitters and supporters if 'submitter' in form.cleaned_data: self.object.submitter.all().delete() MotionSubmitter.objects.bulk_create([ MotionSubmitter(motion=self.object, person=person) for person in form.cleaned_data['submitter'] ]) if 'supporter' in form.cleaned_data: self.object.supporter.all().delete() MotionSupporter.objects.bulk_create([ MotionSupporter(motion=self.object, person=person) for person in form.cleaned_data['supporter'] ]) # Save the attachments self.object.attachments.clear() self.object.attachments.add(*form.cleaned_data['attachments']) # Update the projector if the motion is on it. This can not be done in # the model, because bulk_create does not call the save method. active_slide = get_active_slide() active_slide_pk = active_slide.get('pk', None) if (active_slide['callback'] == 'motion' and str(self.object.pk) == str(active_slide_pk)): update_projector() messages.success(self.request, self.get_success_message()) return HttpResponseRedirect(self.get_success_url())
def form_valid(self, form): """ Saves the CreateForm or UpdateForm into a motion object. """ self.object = form.save(commit=False) try: self.object.category = form.cleaned_data['category'] except KeyError: pass try: self.object.identifier = form.cleaned_data['identifier'] except KeyError: pass self.manipulate_object(form) for attr in ['title', 'text', 'reason']: setattr(self.version, attr, form.cleaned_data[attr]) self.object.save(use_version=self.version) # Save the submitter an the supporter so the motion. # TODO: Only delete and save neccessary submitters and supporters if 'submitter' in form.cleaned_data: self.object.submitter.all().delete() MotionSubmitter.objects.bulk_create( [MotionSubmitter(motion=self.object, person=person) for person in form.cleaned_data['submitter']]) if 'supporter' in form.cleaned_data: self.object.supporter.all().delete() MotionSupporter.objects.bulk_create( [MotionSupporter(motion=self.object, person=person) for person in form.cleaned_data['supporter']]) # Save the attachments self.object.attachments.clear() self.object.attachments.add(*form.cleaned_data['attachments']) # Update the projector if the motion is on it. This can not be done in # the model, because bulk_create does not call the save method. active_slide = get_active_slide() active_slide_pk = active_slide.get('pk', None) if (active_slide['callback'] == 'motion' and unicode(self.object.pk) == unicode(active_slide_pk)): update_projector() messages.success(self.request, self.get_success_message()) return HttpResponseRedirect(self.get_success_url())
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 update_personal_votes(poll): """ Loads all personal vote results and saves them into the database. """ server = get_server() votelog_json = server.voteCollector.getVoteLog() votelog = json.loads(votelog_json) keypad_dict = {} for keypad in Keypad.objects.all(): # Be careful: Don't mix up keypad.pk and keypad_id. It is tricky. keypad_dict[keypad.keypad_id] = keypad.pk with transaction.atomic(): MotionPollKeypadConnection.objects.filter(poll=poll).delete() connection_objects = [] for item in votelog: if item['value'] not in ('Y', 'N', 'A'): raise VoteCollectorError(nr=-1) # TODO: Check this. connection_objects.append(MotionPollKeypadConnection( poll=poll, keypad_id=keypad_dict[int(item['id'])], value=item['value'], serial_number=item['sn'])) MotionPollKeypadConnection.objects.bulk_create(connection_objects) update_projector() # TODO: Only update when motion poll slide is active
def on_clicked_yes(self): self.get_object().keypad_data_list.update(keypad=None) update_projector()
def save(self, *args, **kwargs): super(Item, self).save(*args, **kwargs) if self.parent and self.parent.is_active_slide(): update_projector()
def test_update_projector(self, mock_ProjectorSocketHandler, mock_get_projector_content): mock_get_projector_content.return_value = 'mock_string' projector_api.update_projector() mock_ProjectorSocketHandler.send_updates.assert_called_with( {'content': 'mock_string'})