2011-07-31 10:46:29 +02:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
openslides.agenda.models
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Models for the agenda app.
|
|
|
|
|
|
2013-04-25 16:18:16 +02:00
|
|
|
|
:copyright: 2011–2013 by OpenSlides team, see AUTHORS.
|
2011-07-31 10:46:29 +02:00
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
|
"""
|
|
|
|
|
|
2013-03-18 12:34:47 +01:00
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
|
from django.db import models
|
2012-06-03 09:35:26 +02:00
|
|
|
|
from django.core.urlresolvers import reverse
|
2013-04-22 19:59:05 +02:00
|
|
|
|
from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
2012-02-20 00:14:54 +01:00
|
|
|
|
from mptt.models import MPTTModel, TreeForeignKey
|
|
|
|
|
|
2013-03-18 12:34:47 +01:00
|
|
|
|
from openslides.utils.exceptions import OpenSlidesError
|
2013-03-01 17:13:12 +01:00
|
|
|
|
from openslides.config.api import config
|
2012-07-04 12:50:33 +02:00
|
|
|
|
from openslides.projector.projector import SlideMixin
|
2012-11-24 14:01:21 +01:00
|
|
|
|
from openslides.projector.api import (
|
|
|
|
|
register_slidemodel, get_slide_from_sid, register_slidefunc)
|
2013-03-18 12:34:47 +01:00
|
|
|
|
from openslides.utils.person.models import PersonField
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
2012-04-14 11:18:47 +02:00
|
|
|
|
|
2012-03-03 09:11:56 +01:00
|
|
|
|
class Item(MPTTModel, SlideMixin):
|
2011-07-31 10:46:29 +02:00
|
|
|
|
"""
|
2012-02-03 23:12:28 +01:00
|
|
|
|
An Agenda Item
|
2012-02-21 13:17:42 +01:00
|
|
|
|
|
|
|
|
|
MPTT-model. See http://django-mptt.github.com/django-mptt/
|
2011-07-31 10:46:29 +02:00
|
|
|
|
"""
|
2012-02-09 02:29:38 +01:00
|
|
|
|
prefix = 'item'
|
|
|
|
|
|
2013-02-01 15:13:40 +01:00
|
|
|
|
AGENDA_ITEM = 1
|
|
|
|
|
ORGANIZATIONAL_ITEM = 2
|
|
|
|
|
|
2013-01-05 23:52:29 +01:00
|
|
|
|
ITEM_TYPE = (
|
2013-04-22 19:59:05 +02:00
|
|
|
|
(AGENDA_ITEM, ugettext_lazy('Agenda item')),
|
|
|
|
|
(ORGANIZATIONAL_ITEM, ugettext_lazy('Organizational item')))
|
2013-01-05 23:52:29 +01:00
|
|
|
|
|
2013-04-22 19:59:05 +02:00
|
|
|
|
title = models.CharField(null=True, max_length=255, verbose_name=ugettext_lazy("Title"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Title of the agenda item.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
2013-04-22 19:59:05 +02:00
|
|
|
|
text = models.TextField(null=True, blank=True, verbose_name=ugettext_lazy("Text"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
The optional text of the agenda item.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
2013-04-22 19:59:05 +02:00
|
|
|
|
comment = models.TextField(null=True, blank=True, verbose_name=ugettext_lazy("Comment"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Optional comment to the agenda item. Will not be shoun to normal users.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
2013-04-22 19:59:05 +02:00
|
|
|
|
closed = models.BooleanField(default=False, verbose_name=ugettext_lazy("Closed"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Flag, if the item is finished.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
2013-04-22 19:59:05 +02:00
|
|
|
|
weight = models.IntegerField(default=0, verbose_name=ugettext_lazy("Weight"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Weight to sort the item in the agenda.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
2012-07-04 12:50:33 +02:00
|
|
|
|
parent = TreeForeignKey('self', null=True, blank=True,
|
2012-11-24 14:01:21 +01:00
|
|
|
|
related_name='children')
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
The parent item in the agenda tree.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
|
|
|
|
type = models.IntegerField(max_length=1, choices=ITEM_TYPE,
|
2013-04-22 19:59:05 +02:00
|
|
|
|
default=AGENDA_ITEM, verbose_name=ugettext_lazy("Type"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Type of the agenda item.
|
|
|
|
|
|
|
|
|
|
See Agenda.ITEM_TYPE for more informations.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
duration = models.CharField(null=True, blank=True, max_length=5,
|
2013-04-22 19:59:05 +02:00
|
|
|
|
verbose_name=ugettext_lazy("Duration (hh:mm)"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
The intended duration for the topic.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
2012-07-04 12:50:33 +02:00
|
|
|
|
related_sid = models.CharField(null=True, blank=True, max_length=63)
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Slide-ID to another object to show it in the agenda.
|
|
|
|
|
|
|
|
|
|
For example a motion or assignment.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
speaker_list_closed = models.BooleanField(
|
2013-04-22 19:59:05 +02:00
|
|
|
|
default=False, verbose_name=ugettext_lazy("List of speakers is closed"))
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
True, if the list of speakers is closed.
|
|
|
|
|
"""
|
2012-04-19 12:46:04 +02:00
|
|
|
|
|
2013-04-29 20:03:50 +02:00
|
|
|
|
class Meta:
|
|
|
|
|
permissions = (
|
|
|
|
|
('can_see_agenda', ugettext_noop("Can see agenda")),
|
|
|
|
|
('can_manage_agenda', ugettext_noop("Can manage agenda")),
|
|
|
|
|
('can_see_orga_items', ugettext_noop("Can see orga items and time scheduling of agenda")))
|
|
|
|
|
|
|
|
|
|
class MPTTMeta:
|
|
|
|
|
order_insertion_by = ['weight']
|
|
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
|
return self.get_title()
|
|
|
|
|
|
|
|
|
|
def get_absolute_url(self, link='view'):
|
|
|
|
|
"""
|
|
|
|
|
Return the URL to this item. By default it is the link to its
|
|
|
|
|
view or the view of a related object.
|
|
|
|
|
|
|
|
|
|
The link can be:
|
|
|
|
|
* view
|
|
|
|
|
* edit
|
|
|
|
|
* delete
|
|
|
|
|
"""
|
|
|
|
|
if link == 'view':
|
|
|
|
|
if self.related_sid:
|
|
|
|
|
return self.get_related_slide().get_absolute_url(link)
|
|
|
|
|
return reverse('item_view', args=[str(self.id)])
|
|
|
|
|
if link == 'edit':
|
|
|
|
|
if self.related_sid:
|
|
|
|
|
return self.get_related_slide().get_absolute_url(link)
|
|
|
|
|
return reverse('item_edit', args=[str(self.id)])
|
|
|
|
|
if link == 'delete':
|
|
|
|
|
return reverse('item_delete', args=[str(self.id)])
|
|
|
|
|
|
2012-07-04 11:00:58 +02:00
|
|
|
|
def get_related_slide(self):
|
2012-07-04 12:50:33 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
Return the object at which the item points.
|
2012-07-04 12:50:33 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
# TODO: Rename it to 'get_related_object'
|
2012-08-05 11:28:56 +02:00
|
|
|
|
object = get_slide_from_sid(self.related_sid, element=True)
|
|
|
|
|
if object is None:
|
|
|
|
|
self.title = 'Item for deleted slide: %s' % self.related_sid
|
|
|
|
|
self.related_sid = None
|
|
|
|
|
self.save()
|
|
|
|
|
return self
|
|
|
|
|
else:
|
|
|
|
|
return object
|
2012-04-19 12:46:04 +02:00
|
|
|
|
|
2012-07-04 11:00:58 +02:00
|
|
|
|
def get_related_type(self):
|
2012-07-04 12:50:33 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
Return the type of the releated slide.
|
2012-07-04 12:50:33 +02:00
|
|
|
|
"""
|
2012-07-04 11:00:58 +02:00
|
|
|
|
return self.get_related_slide().prefix
|
2012-06-03 09:35:26 +02:00
|
|
|
|
|
2012-07-04 11:00:58 +02:00
|
|
|
|
def print_related_type(self):
|
2012-06-30 11:06:32 +02:00
|
|
|
|
"""
|
2012-07-04 11:00:58 +02:00
|
|
|
|
Print the type of the related item.
|
2012-06-30 11:06:32 +02:00
|
|
|
|
|
|
|
|
|
For use in Template
|
2012-07-04 11:00:58 +02:00
|
|
|
|
??Why does {% trans item.print_related_type|capfirst %} not work??
|
2012-06-30 11:06:32 +02:00
|
|
|
|
"""
|
2013-04-22 19:59:05 +02:00
|
|
|
|
return _(self.get_related_type().capitalize())
|
2012-06-30 11:06:32 +02:00
|
|
|
|
|
2012-04-19 12:46:04 +02:00
|
|
|
|
def get_title(self):
|
2012-07-04 12:50:33 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
Return the title of this item.
|
2012-07-04 12:50:33 +02:00
|
|
|
|
"""
|
2012-07-04 11:00:58 +02:00
|
|
|
|
if self.related_sid is None:
|
2012-04-19 12:46:04 +02:00
|
|
|
|
return self.title
|
2012-07-04 11:00:58 +02:00
|
|
|
|
return self.get_related_slide().get_agenda_title()
|
2012-04-19 12:46:04 +02:00
|
|
|
|
|
2012-07-20 11:22:09 +02:00
|
|
|
|
def get_title_supplement(self):
|
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
Return a supplement for the title.
|
2012-07-20 11:22:09 +02:00
|
|
|
|
"""
|
|
|
|
|
if self.related_sid is None:
|
|
|
|
|
return ''
|
|
|
|
|
try:
|
|
|
|
|
return self.get_related_slide().get_agenda_title_supplement()
|
|
|
|
|
except AttributeError:
|
|
|
|
|
return '(%s)' % self.print_related_type()
|
|
|
|
|
|
2012-02-06 22:08:08 +01:00
|
|
|
|
def slide(self):
|
2011-07-31 10:46:29 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
Return a map with all data for the slide.
|
2013-04-25 16:18:16 +02:00
|
|
|
|
|
2013-04-29 20:03:50 +02:00
|
|
|
|
There are four cases:
|
|
|
|
|
* summary slide
|
|
|
|
|
* list of speakers
|
|
|
|
|
* related slide, i. e. the slide of the related object
|
|
|
|
|
* normal slide of the item
|
2013-04-25 16:18:16 +02:00
|
|
|
|
|
2013-04-29 20:03:50 +02:00
|
|
|
|
The method returns only one of them according to the config value
|
|
|
|
|
'presentation_argument' and the attribut 'related_sid'.
|
|
|
|
|
"""
|
|
|
|
|
if config['presentation_argument'] == 'summary':
|
|
|
|
|
data = {'title': self.get_title(),
|
|
|
|
|
'items': self.get_children(),
|
|
|
|
|
'template': 'projector/AgendaSummary.html'}
|
2013-04-27 10:16:32 +02:00
|
|
|
|
|
2013-04-29 20:03:50 +02:00
|
|
|
|
elif config['presentation_argument'] == 'show_list_of_speakers':
|
|
|
|
|
list_of_speakers = self.get_list_of_speakers(
|
|
|
|
|
old_speakers_count=config['agenda_show_last_speakers'])
|
2013-04-22 19:59:05 +02:00
|
|
|
|
data = {'title': self.get_title(),
|
2013-03-18 12:34:47 +01:00
|
|
|
|
'template': 'projector/agenda_list_of_speaker.html',
|
2013-04-29 20:03:50 +02:00
|
|
|
|
'list_of_speakers': list_of_speakers}
|
2012-07-04 11:00:58 +02:00
|
|
|
|
elif self.related_sid:
|
|
|
|
|
data = self.get_related_slide().slide()
|
2013-04-29 20:03:50 +02:00
|
|
|
|
|
2012-07-01 16:10:26 +02:00
|
|
|
|
else:
|
2013-04-29 20:03:50 +02:00
|
|
|
|
data = {'item': self,
|
|
|
|
|
'title': self.get_title(),
|
|
|
|
|
'template': 'projector/AgendaText.html'}
|
|
|
|
|
|
2012-02-09 01:46:58 +01:00
|
|
|
|
return data
|
|
|
|
|
|
2011-07-31 10:46:29 +02:00
|
|
|
|
def set_closed(self, closed=True):
|
|
|
|
|
"""
|
|
|
|
|
Changes the closed-status of the item.
|
|
|
|
|
"""
|
|
|
|
|
self.closed = closed
|
|
|
|
|
self.save()
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def weight_form(self):
|
|
|
|
|
"""
|
|
|
|
|
Return the WeightForm for this item.
|
|
|
|
|
"""
|
2012-07-10 14:00:51 +02:00
|
|
|
|
from openslides.agenda.forms import ItemOrderForm
|
2011-07-31 10:46:29 +02:00
|
|
|
|
try:
|
|
|
|
|
parent = self.parent.id
|
|
|
|
|
except AttributeError:
|
|
|
|
|
parent = 0
|
|
|
|
|
initial = {
|
|
|
|
|
'weight': self.weight,
|
|
|
|
|
'self': self.id,
|
|
|
|
|
'parent': parent,
|
|
|
|
|
}
|
2012-02-06 22:22:16 +01:00
|
|
|
|
return ItemOrderForm(initial=initial, prefix="i%d" % self.id)
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
2012-06-23 11:41:32 +02:00
|
|
|
|
def delete(self, with_children=False):
|
|
|
|
|
"""
|
|
|
|
|
Delete the Item.
|
|
|
|
|
"""
|
|
|
|
|
if not with_children:
|
|
|
|
|
for child in self.get_children():
|
|
|
|
|
child.move_to(self.parent)
|
|
|
|
|
child.save()
|
|
|
|
|
super(Item, self).delete()
|
|
|
|
|
Item.objects.rebuild()
|
|
|
|
|
|
2013-04-29 20:03:50 +02:00
|
|
|
|
def get_list_of_speakers(self, old_speakers_count=None, coming_speakers_count=None):
|
2011-07-31 10:46:29 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
Returns the list of speakers as a list of dictionaries. Each
|
|
|
|
|
dictionary contains a prefix, the speaker and its type. Types
|
|
|
|
|
are old_speaker, actual_speaker and coming_speaker.
|
2011-07-31 10:46:29 +02:00
|
|
|
|
"""
|
2013-04-29 20:03:50 +02:00
|
|
|
|
speaker_query = Speaker.objects.filter(item=self)
|
|
|
|
|
list_of_speakers = []
|
|
|
|
|
|
|
|
|
|
# Parse old speakers
|
|
|
|
|
old_speakers = speaker_query.exclude(begin_time=None).exclude(end_time=None).order_by('end_time')
|
|
|
|
|
if old_speakers_count is None:
|
|
|
|
|
old_speakers_count = old_speakers.count()
|
|
|
|
|
last_old_speakers_count = max(0, old_speakers.count() - old_speakers_count)
|
|
|
|
|
old_speakers = old_speakers[last_old_speakers_count:]
|
|
|
|
|
for number, speaker in enumerate(old_speakers):
|
|
|
|
|
prefix = old_speakers_count - number
|
|
|
|
|
speaker_dict = {
|
|
|
|
|
'prefix': '-%d' % prefix,
|
|
|
|
|
'speaker': speaker,
|
|
|
|
|
'type': 'old_speaker',
|
|
|
|
|
'first_in_group': False,
|
|
|
|
|
'last_in_group': False}
|
|
|
|
|
if number == 0:
|
|
|
|
|
speaker_dict['first_in_group'] = True
|
|
|
|
|
if number == old_speakers_count - 1:
|
|
|
|
|
speaker_dict['last_in_group'] = True
|
|
|
|
|
list_of_speakers.append(speaker_dict)
|
|
|
|
|
|
|
|
|
|
# Parse actual speaker
|
|
|
|
|
try:
|
|
|
|
|
actual_speaker = speaker_query.filter(end_time=None).exclude(begin_time=None).get()
|
|
|
|
|
except Speaker.DoesNotExist:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
list_of_speakers.append({
|
|
|
|
|
'prefix': '0',
|
|
|
|
|
'speaker': actual_speaker,
|
|
|
|
|
'type': 'actual_speaker',
|
|
|
|
|
'first_in_group': True,
|
|
|
|
|
'last_in_group': True})
|
|
|
|
|
|
|
|
|
|
# Parse coming speakers
|
|
|
|
|
coming_speakers = speaker_query.filter(begin_time=None).order_by('weight')
|
|
|
|
|
if coming_speakers_count is None:
|
|
|
|
|
coming_speakers_count = coming_speakers.count()
|
|
|
|
|
coming_speakers = coming_speakers[:max(0, coming_speakers_count)]
|
|
|
|
|
for number, speaker in enumerate(coming_speakers):
|
|
|
|
|
speaker_dict = {
|
|
|
|
|
'prefix': number + 1,
|
|
|
|
|
'speaker': speaker,
|
|
|
|
|
'type': 'coming_speaker',
|
|
|
|
|
'first_in_group': False,
|
|
|
|
|
'last_in_group': False}
|
|
|
|
|
if number == 0:
|
|
|
|
|
speaker_dict['first_in_group'] = True
|
|
|
|
|
if number == coming_speakers_count - 1:
|
|
|
|
|
speaker_dict['last_in_group'] = True
|
|
|
|
|
list_of_speakers.append(speaker_dict)
|
|
|
|
|
|
|
|
|
|
return list_of_speakers
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
2013-03-18 12:34:47 +01:00
|
|
|
|
class SpeakerManager(models.Manager):
|
|
|
|
|
def add(self, person, item):
|
2013-04-25 16:18:16 +02:00
|
|
|
|
if self.filter(person=person, item=item, begin_time=None).exists():
|
2013-04-22 19:59:05 +02:00
|
|
|
|
raise OpenSlidesError(_('%(person)s is already on the list of speakers of item %(id)s.') % {'person': person, 'id': item.id})
|
2013-03-18 12:34:47 +01:00
|
|
|
|
weight = (self.filter(item=item).aggregate(
|
|
|
|
|
models.Max('weight'))['weight__max'] or 0)
|
|
|
|
|
return self.create(item=item, person=person, weight=weight + 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Speaker(models.Model):
|
|
|
|
|
"""
|
|
|
|
|
Model for the Speaker list.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
objects = SpeakerManager()
|
|
|
|
|
|
|
|
|
|
person = PersonField()
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
ForeinKey to the person who speaks.
|
|
|
|
|
"""
|
|
|
|
|
|
2013-03-18 12:34:47 +01:00
|
|
|
|
item = models.ForeignKey(Item)
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
ForeinKey to the AgendaItem to which the person want to speak.
|
|
|
|
|
"""
|
|
|
|
|
|
2013-04-25 16:18:16 +02:00
|
|
|
|
begin_time = models.DateTimeField(null=True)
|
|
|
|
|
"""
|
|
|
|
|
Saves the time, when the speaker begins to speak. None, if he has not spoken yet.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
end_time = models.DateTimeField(null=True)
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
2013-04-25 16:18:16 +02:00
|
|
|
|
Saves the time, when the speaker ends his speach. None, if he is not finished yet.
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
|
2013-03-18 12:34:47 +01:00
|
|
|
|
weight = models.IntegerField(null=True)
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
The sort order of the list of speakers. None, if he has already spoken.
|
|
|
|
|
"""
|
2013-03-18 12:34:47 +01:00
|
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
permissions = (
|
2013-04-22 19:59:05 +02:00
|
|
|
|
('can_be_speaker', ugettext_noop('Can put oneself on the list of speakers')),
|
2013-03-18 12:34:47 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
|
return unicode(self.person)
|
|
|
|
|
|
|
|
|
|
def get_absolute_url(self, link='detail'):
|
|
|
|
|
if link == 'detail' or link == 'view':
|
|
|
|
|
return self.person.get_absolute_url('detail')
|
|
|
|
|
if link == 'delete':
|
|
|
|
|
return reverse('agenda_speaker_delete',
|
|
|
|
|
args=[self.item.pk, self.pk])
|
|
|
|
|
|
2013-04-25 16:18:16 +02:00
|
|
|
|
def begin_speach(self):
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
|
|
|
|
Let the person speak.
|
|
|
|
|
|
2013-04-25 16:18:16 +02:00
|
|
|
|
Set the weight to None and the time to now. If anyone is still
|
|
|
|
|
speaking, end his speach.
|
2013-03-18 12:34:47 +01:00
|
|
|
|
"""
|
2013-04-25 16:18:16 +02:00
|
|
|
|
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()
|
2013-03-18 12:34:47 +01:00
|
|
|
|
self.weight = None
|
2013-04-25 16:18:16 +02:00
|
|
|
|
self.begin_time = datetime.now()
|
|
|
|
|
self.save()
|
|
|
|
|
|
|
|
|
|
def end_speach(self):
|
|
|
|
|
"""
|
|
|
|
|
The speach is finished. Set the time to now.
|
|
|
|
|
"""
|
|
|
|
|
self.end_time = datetime.now()
|
2013-03-18 12:34:47 +01:00
|
|
|
|
self.save()
|