Commit 4a347884 authored by Felix Schlösser / TinTin's avatar Felix Schlösser / TinTin
Browse files

added agenda item convenience methods

parent 9b77857e
Pipeline #145393 failed with stages
in 8 seconds
......@@ -542,9 +542,46 @@ class AbstractAgendaItem(TimeStampedModel):
def adjurn(self):
self.motion.status = "ADJURNED"
return self.motion
def move_up(self):
items = self.meeting.agenda_items
with transaction.atomic():
item_directly_above = items.filter(sort_order=self.sort_order + 1).first()
if item_directly_above:
item_directly_above.sort_order = self.sort_order
item_directly_above.save()
self.sort_order += 1
self.save()
def move_down(self):
items = self.meeting.agenda_items
with transaction.atomic():
item_directly_below = items.filter(sort_order=self.sort_order - 1).first()
if item_directly_below:
item_directly_below.sort_order = self.sort_order
item_directly_below.save()
self.sort_order -= 1
self.save()
def get_next(self):
items = self.meeting.agenda_items
nubmer_of_items = items.count()
for index in range(nubmer_of_items):
item = items.filter(sort_order=self.sort_order + index + 1).first()
if item:
return item
return None
def get_previous(self):
items = self.meeting.agenda_items
nubmer_of_items = items.count()
for index in range(nubmer_of_items):
item = items.filter(sort_order=self.sort_order - (index + 1)).first()
if item:
return item
return None
def clean(self):
motion_list = []
for item in self.meeting.agenda_items.all():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment