Ejemplo n.º 1
0
def read():

    mylogger.debug(message='request.vars:%s' % request.vars)

    exposure_card_mapper = EXPOSURE_CARD_MAPPER()
    product_mapper = PRODUCT_MAPPER()
    error = ''

    # getting the exposure card
    exposure_card = exposure_card_mapper.find(exposure_card_id=request.args[0])[0]

    if 'cas_number' in request.vars:
        _product_id = request.vars.cas_number

        # duclicity check not performed by the field validator
        #_value, _error =  db.exposure_item.product.validate(_product_id)
        #mylogger.debug(message='_error, _value:%s, %s' % (_error, _value))

        # but in the c_exposure_card.py class with an exceptions.AssertionError
        _product = product_mapper.find(product_id=_product_id)[0]

        try:
            exposure_card.add_exposure_item_for_product(_product)
            exposure_card_mapper.update(exposure_card)
        except AssertionError, e:
            error = cc.get_string('EXPOSURE_CARD_PRODUCT_ALREADY_PRESENT_ERROR')
Ejemplo n.º 2
0
def create_stock(form):

    _product = PRODUCT_MAPPER().find(form.vars['product'])[0]
    _store_location = STORE_LOCATION_MAPPER().find(
        form.vars['store_location'])[0]
    _entity_id = _store_location.entity.id
    if db((db.stock.product == _product.id)
          & (db.stock.entity == _entity_id)).count() == 0:
        db.stock.insert(product=_product.id, entity=_entity_id)
        db.commit()
    def _exposure_item_from_row(self, _exposure_item_row):
        """Return an EXPOSURE_ITEM instance from a row.
        """
        from c_product_mapper import PRODUCT_MAPPER
        self.__product_mapper = PRODUCT_MAPPER()

        return EXPOSURE_ITEM(id=_exposure_item_row['id'],
                             creation_datetime=_exposure_item_row['creation_datetime'],
                             product=lambda: self.__product_mapper.find(product_id=_exposure_item_row['product'])[0],
                             kind_of_work=_exposure_item_row['kind_of_work'],
                             cpe=_exposure_item_row['cpe'],
                             ppe=_exposure_item_row['ppe'],
                             nb_exposure=_exposure_item_row['nb_exposure'],
                             exposure_time=_exposure_item_row['exposure_time'],
                             simultaneous_risk=_exposure_item_row['simultaneous_risk'])
Ejemplo n.º 4
0
 def __init__(self):
     self.__product_mapper = PRODUCT_MAPPER()
     self.__person_mapper = PERSON_MAPPER()
     self.__store_location_mapper = STORE_LOCATION_MAPPER()
     self.__supplier_mapper = SUPPLIER_MAPPER()
     self.__unit_mapper = UNIT_MAPPER()
 def __init__(self):
     self.__product_mapper = PRODUCT_MAPPER()
     self.__store_location_mapper = STORE_LOCATION_MAPPER()
     self.__storage_mapper = STORAGE_MAPPER()
     self.__unit_mapper = UNIT_MAPPER()
Ejemplo n.º 6
0
    def __init__(self):

        self.__product_mapper = PRODUCT_MAPPER()
        self.__entity_mapper = ENTITY_MAPPER()
        self.__unit_mapper = UNIT_MAPPER()