def update_item_details(item_dict): """For updating item obj.""" item_dict['item'] = inventory_dal.get_item_by_id(item_dict['item_id']) item_dict['action'] = 'item ' item_dict = inventory_dal.update_item_data(item_dict) item_dict['status'] = USER_ACTION_STATUS_UPDATED inventory_dal.create_user_action(item_dict) return {'success': True}
def delete_variant(variant_dict): """For deleting variant.""" variant = inventory_dal.get_variant_by_id(variant_dict['variant_id']) variant_dict['action'] = 'variant ' + variant_dict['variant'].name variant_dict['status'] = USER_ACTION_STATUS_DELETED inventory_dal.create_user_action(variant_dict) data = inventory_dal.delete_variant_obj(variant) return data
def update_variants(variant_dict): """For updating variant details.""" variant_dict['variant'] = inventory_dal.get_variant_by_id( variant_dict['variant_id']) inventory_dal.update_variant_obj(variant_dict) variant_dict['action'] = 'variant ' + variant_dict['variant'].name variant_dict['status'] = USER_ACTION_STATUS_UPDATED inventory_dal.create_user_action(variant_dict) return {'success': True}
def delete_item(item_dict): """For deleting item.""" item = inventory_dal.get_item_by_id(item_dict['item_id']) item_dict['action'] = 'item ' + item.name item_dict['status'] = USER_ACTION_STATUS_DELETED inventory_dal.create_user_action(item_dict) data = inventory_dal.delete_item_obj(item) return data
def create_item(item_dict): """For creating items.""" item_dict['brand'] = inventory_dal.get_brand_by_id(item_dict['brand_id']) item_dict['category'] = inventory_dal.get_category_by_id( item_dict['category_id']) item = inventory_dal.create_item_obj(item_dict) item_dict['action'] = 'item ' + item.name item_dict['status'] = USER_ACTION_STATUS_CREATED inventory_dal.create_user_action(item_dict) return {'success': True, 'item_id': item.id}
def delete_variant_property(variant_dict): """For deleting variant property.""" variant_property = inventory_dal.get_variant_property_by_id( variant_dict['variant_property_id']) variant_dict['action'] = 'variant property ' + \ variant_dict['variant_property'].property_value + ' of variant ' + \ variant_dict['variant'].name variant_dict['status'] = USER_ACTION_STATUS_DELETED inventory_dal.create_user_action(variant_dict) data = inventory_dal.delete_variant_property_obj(variant_property) return data
def update_variant_property_details(variant_dict): """For updaing variant property details.""" variant_dict['variant_property'] = \ inventory_dal.get_variant_property_by_id( variant_dict['variant_property_id']) data = inventory_dal.update_variant_property_data(variant_dict) variant_dict['action'] = 'variant property ' + \ variant_dict['variant_property'].property_value + ' of variant ' + \ variant_dict['variant'].name variant_dict['status'] = USER_ACTION_STATUS_UPDATED inventory_dal.create_user_action(variant_dict) return data
def create_variant_properties(variant_dict): """For creating variant properties.""" variant_dict['variant'] = inventory_dal.get_variant_by_id( variant_dict['variant_id']) variant_dict['property'] = inventory_dal.get_property_by_id( variant_dict['property_id']) variant_property = inventory_dal.create_variant_property_object( variant_dict) variant_dict['action'] = 'variant property ' + \ variant_property.property_value + ' of variant ' + \ variant_dict['variant'].name variant_dict['status'] = USER_ACTION_STATUS_CREATED inventory_dal.create_user_action(variant_dict) return {'variant_property': variant_property.id}
def create_item_variants(item_dict): """For creating item variants.""" item = inventory_dal.get_item_by_id(item_dict['item_id']) item_dict['item'] = item variant = inventory_dal.create_variant_object(item_dict) item_dict['action'] = 'variant ' + variant.name item_dict['status'] = USER_ACTION_STATUS_CREATED inventory_dal.create_user_action(item_dict) for variant_property_dict in item_dict['variant_properties']: variant_property_dict['variant'] = variant variant_property_dict['property'] = inventory_dal.get_property_by_id( variant_property_dict['property_id']) variant_property = inventory_dal.create_variant_property_object( variant_property_dict) item_dict['action'] = 'variant property ' + \ variant_property.property_value + ' of variant ' + variant.name inventory_dal.create_user_action(item_dict) return {'success': True}