示例#1
0
def get_serialno(series=None,
                 efield=None,
                 register=True,
                 start_seed='100A',
                 create_series=False,
                 session=None):
    series = series.upper()
    try:
        series_obj = controller.get_series_obj(series=series, session=session)
    except controller.SeriesNotFound:
        if not create_series:
            raise
        series_obj = None
    if series_obj is not None:
        last_seed = series_obj.last_seed
        logger.debug("Found last seed for series " + str(series) + " : " +
                     str(last_seed))
        generator = idstring.IDstring(seed=last_seed)
        new_sno = generator + 1
        if register is True:
            logger.debug("Updating seed for series " + series + " : " +
                         str(new_sno.get_seed()))
            series_obj.last_seed = new_sno.get_seed()
            register_serialno(sno=series + '-' + new_sno,
                              efield=efield,
                              session=session)
        else:
            logger.info("Not updating seed for series " + series + " : " +
                        str(new_sno.get_seed()))
        return series + '-' + new_sno
    else:
        logger.info("Could not find series in db : " + series)
        generator = idstring.IDstring(seed=start_seed)
        if register is True:
            logger.info("Creating series in db : " + series)
            controller.create_series_obj(series=series,
                                         start_seed=start_seed,
                                         session=session)
            register_serialno(sno=series + '-' + generator,
                              efield=efield,
                              session=session)
        else:
            logger.info("NOT Creating series in db : " + series)
        return series + '-' + generator
示例#2
0
def get_serialno(series=None, efield=None, register=True,
                 start_seed='100A', create_series=False, session=None):
    series = series.upper()
    try:
        series_obj = controller.get_series_obj(series=series, session=session)
    except controller.SeriesNotFound:
        if not create_series:
            raise
        series_obj = None
    if series_obj is not None:
        last_seed = series_obj.last_seed
        logger.debug("Found last seed for series " + str(series) +
                     " : " + str(last_seed))
        generator = idstring.IDstring(seed=last_seed)
        new_sno = generator + 1
        if register is True:
            logger.debug("Updating seed for series " + series +
                         " : " + str(new_sno.get_seed()))
            series_obj.last_seed = new_sno.get_seed()
            register_serialno(
                sno=series + '-' + new_sno,
                efield=efield, session=session
            )
        else:
            logger.info("Not updating seed for series " + series +
                        " : " + str(new_sno.get_seed()))
        return series + '-' + new_sno
    else:
        logger.info("Could not find series in db : " + series)
        generator = idstring.IDstring(seed=start_seed)
        if register is True:
            logger.info("Creating series in db : " + series)
            controller.create_series_obj(
                series=series, start_seed=start_seed, session=session
            )
            register_serialno(
                sno=series + '-' + generator,
                efield=efield, session=session
            )
        else:
            logger.info("NOT Creating series in db : " + series)
        return series + '-' + generator
示例#3
0
def get_all_series(session=None):
    return controller.get_series_obj(session=session)
示例#4
0
def get_all_series(session=None):
    return controller.get_series_obj(session=session)