def append_log_impl(args): try: user = user_by_user_id(args['user_id']) logs = [] if args['logs'] is None: return Response(True, "Logs Appended", LogSchema(many=True).dumps(logs).data).output() for log_dict in args['logs']: validate(log_dict) log = None if log_dict.has_key('id') and log_dict['id'] is not None: log = log_by_id(log_dict['id']) if log is None: log = ReadingLog() else: log = ReadingLog() log.book = find_book_with_name(log_dict['book_name']).id log.date = parse(log_dict['date']) log.pages = log_dict['pages'] log.uuid = log_dict['uuid'] log.user = user.user_id db.session.add(log) logs.append(log) db.session.commit() return Response(True, "Logs Appended", LogSchema(many=True).dumps(logs).data).output() except Exception as e: return Response(False, str(e), None).output()
def create_log(book_name, user_id): log = ReadingLog() log.user = user_id log.pages = 30; log.date = "12/12/2014" db.session.add(log) db.session.commit() return log
def create_log(book_name, user_id): log = ReadingLog() log.user = user_id log.pages = 30 log.date = "12/12/2014" db.session.add(log) db.session.commit() return log