def add_checklist(self): clist = DataChecklist(card=self.parent.data) database.session.flush() ck = Checklist(clist.id, clist) ck.edit_title() ck.set_index(len(self.checklists)) self.checklists.append(component.Component(ck))
def reorder_items(self, data): data = json.loads(data) item_id = int(data['id'].split('_')[-1]) checklist_id = int(data['target'].split('_')[-1]) item = DataChecklistItem.get(item_id) checklist = DataChecklist.get(checklist_id) source = item.checklist item.checklist = None checklist.items.insert(data['index'], item) source.reorder_items() checklist.reorder_items() self.parent.reload()
def data(self): return DataChecklist.get(self.id)