コード例 #1
0
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()
コード例 #2
0
ファイル: log.py プロジェクト: rafagonc/ReadingList-Server
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()
コード例 #3
0
ファイル: helper.py プロジェクト: rafagonc/ReadingList-Server
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
コード例 #4
0
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