src/server/server.py
def on_duplicate_race_class(data):
    '''Adds new race class by duplicating an existing one.'''
    source_class_id = data['class']
    source_class = Database.RaceClass.query.get(source_class_id)

    if source_class.name:
        all_class_names = [race_class.name for race_class in Database.RaceClass.query.all()]
        new_class_name = uniqueName(source_class.name, all_class_names)
    else:
        new_class_name = ''

    new_class = Database.RaceClass(name=new_class_name,
        description=source_class.description,
        format_id=source_class.format_id,
        results=None,
        cacheStatus=Results.CacheStatus.INVALID)

    DB.session.add(new_class)
    DB.session.flush()
    DB.session.refresh(new_class)

    for heat in Database.Heat.query.filter_by(class_id=source_class.id).all():
        duplicate_heat(heat.id, dest_class=new_class.id)

    DB.session.commit()

    Events.trigger(Evt.CLASS_DUPLICATE, {
        'class_id': new_class.id,
        })

    logger.info('Class {0} duplicated to class {1}'.format(source_class.id, new_class.id))
    emit_class_data()
    emit_heat_data()
Adds new race class by duplicating an existing one.
Adds new race class by duplicating an existing one.
Adds new race class by duplicating an existing one .
def on_duplicate_race_class(data):
    source_class_id = data['class']
    source_class = Database.RaceClass.query.get(source_class_id)
    if source_class.name:
        all_class_names = [race_class.name for race_class in Database.RaceClass.query.all()]
        new_class_name = uniqueName(source_class.name, all_class_names)
    else:
        new_class_name = ''
    new_class = Database.RaceClass(name=new_class_name,
        description=source_class.description,
        format_id=source_class.format_id,
        results=None,
        cacheStatus=Results.CacheStatus.INVALID)
    DB.session.add(new_class)
    DB.session.flush()
    DB.session.refresh(new_class)
    for heat in Database.Heat.query.filter_by(class_id=source_class.id).all():
        duplicate_heat(heat.id, dest_class=new_class.id)
    DB.session.commit()
    Events.trigger(Evt.CLASS_DUPLICATE, {
        'class_id': new_class.id,
        })
    logger.info('Class {0} duplicated to class {1}'.format(source_class.id, new_class.id))
    emit_class_data()
    emit_heat_data()
def on_duplicate_race_class ( data ) : source_class_id = data [ 'class' ] source_class = Database . RaceClass . query . get ( source_class_id ) if source_class . name : all_class_names = [ race_class . name for race_class in Database . RaceClass . query . all ( ) ] new_class_name = uniqueName ( source_class . name , all_class_names ) else : new_class_name = '' new_class = Database . RaceClass ( name = new_class_name , description = source_class . description , format_id = source_class . format_id , results = None , cacheStatus = Results . CacheStatus . INVALID ) DB . session . add ( new_class ) DB . session . flush ( ) DB . session . refresh ( new_class ) for heat in Database . Heat . query . filter_by ( class_id = source_class . id ) . all ( ) : duplicate_heat ( heat . id , dest_class = new_class . id ) DB . session . commit ( ) Events . trigger ( Evt . CLASS_DUPLICATE , { 'class_id' : new_class . id , } ) logger . info ( 'Class {0} duplicated to class {1}' . format ( source_class . id , new_class . id ) ) emit_class_data ( ) emit_heat_data ( )
Adds new race class by duplicating an existing one.
Adds new race class by duplicating an existing one .
'''Adds new race class by duplicating an existing one.'''
data