def select_dialog(sender, recipient): dialog = Dialog.query.filter_by( sender=sender, recipient=recipient ).first() if not dialog: dialog = Dialog(sender=sender, recipient=recipient) db.session.add(dialog) commit_changes() return dialog
def test_dialog_model(self): dialog = Dialog() db.session.add(dialog) db.session.commit() self.assertEqual(Dialog.query.count(), 1)
def create_dialog(self, u1, u2, **kwargs): d = Dialog(users=[u1, u2], **kwargs) db.session.add(d) db.session.commit() return d