Esempio n. 1
0
def create_school(competition, area, size, conference, school_name):
    school = Schools( **dict(request.data.items() + request.view_args.items()) )
    school._id = ObjectId()
    school.wrestlers = dict([ ( wrestler.get('wrestler_id'), wrestler_object(Wrestler(**wrestler))) for wrestler in school.wrestlers])
    school.save()
    redis_save(remove_OIDs(school), school.school_name, value_fields=(school.competition, school.area, school.size, 
        school.conference), store_func='rpush')
    defined_school = redis_cli.hset('coach_confirmation', uuid.uuid4(), school.mongo_id)
    return json.dumps( school, default=remove_OIDs )
Esempio n. 2
0
def create_wrestler(competition, area, size, conference, school_name):
    school = find_school(**request.view_args)
    json_data = request.data
    wrestler = Wrestler( **json_data )
    wrestler = wrestler_object(wrestler)
    try:
        school.__getattribute__("wrestlers")
    except AttributeError: 
        school.wrestlers = {}
    wrestler_dict = school.wrestlers
    wrestler_dict[wrestler.wrestler_id] = wrestler
    school.wrestlers = wrestler_dict
    school.save()
    return json.dumps( school, default=remove_OIDs )