コード例 #1
0
ファイル: api.py プロジェクト: tresbailey/wrestlio
def update_school_match(match_id):
    json_data = request.data
    match = Match( **json_data )
    match._id = ObjectId( match_id )
    match.schools = [ prepare_school(school) for school in match.schools ]
    match.individual_bouts = [ reassign_bout(bout) for bout in match.individual_bouts ]
    match.match_date = datetime.strptime(match.match_date, '%m/%d/%Y')
    match.save()
    return json.dumps( match, default=remove_OIDs)
コード例 #2
0
ファイル: api.py プロジェクト: tresbailey/wrestlio
def create_school_match():
    match = Match(**request.data)
    match.match_date = datetime.strptime(match.match_date, '%Y-%m-%d')
    match.home_school = prepare_school(match.home_school, ObjectId)
    match.visit_school = prepare_school(match.visit_school, ObjectId)
    match._id = ObjectId()
    bouts = []
    for bout in match.individual_bouts:
        bout = Bout( **bout )
        bout.bout_date =  datetime.strptime( bout.bout_date, '%Y-%m-%d' )
        bouts.append(bout)
    match.individual_bouts = bouts
    match.save()
    return json.dumps( match, default=remove_OIDs )