def _get_recipients(self, data: InwardDraftModel, conf): user_device_list = [] params: ParamsObject = ParamsObject() params_list = [] for each_rec in conf: notification_default_recipients: NotificationDefaultRecipientsModel = each_rec if notification_default_recipients.procedure_config == None or notification_default_recipients.procedure_config == "": pass else: procedure_config_str = notification_default_recipients.procedure_config procedure_config_lst = [] if procedure_config_str != "" and procedure_config_str is not None: procedure_config_lst = json.loads(procedure_config_str) for each_config in procedure_config_lst: _property = each_config["property"] _from = each_config["from"] if _from == "session": params_list.append(self.ext_params.get(_property)) else: params_list.append(data.__getattribute__(_property)) params1: ParamsObject = ParamsObject() params1.set_params_list([data.state_id]) zone = self.get_direct("sGetZoneByStateID", params1, False) zone = zone[0] zone_id = zone["Zone_ID"] params_manager_id = ParamsObject() params_manager_id.set_params_list([zone_id]) zone_manager = self.get_direct("sGetZoneManagerByID", params_manager_id, False) manager_id = zone_manager[0]["Manager_ID"] params_list.append(manager_id) params.set_params_list(params_list) recipient_list = params.get_params_list() for id in recipient_list: params_obj = ParamsObject() params_obj.set_params_list([id]) device_list = self.get_direct("sUserDeviceByIDGet", params_obj, False) if device_list != "" and device_list is not None: if isinstance(device_list, list): if len(device_list) > 0: user_device_list.append(device_list) return user_device_list
def _build_description(self, action, data, template, conf): params = ParamsObject() params.set_params_list([]) if conf == "COLLECTION": sw = 0 ne = 0 """ Get Data """ collection = self.get_direct("sNotificationEODCollection", params, False) if collection is None: template = "No Collection" else: if isinstance(collection, list): if len(collection) > 0: for each_collection in collection: if each_collection["Zone_ID"] == 1: sw = each_collection["Total"] else: ne = each_collection["Total"] template = template.replace("<TOTAL>", str(sw + ne) + os.linesep) template = template.replace("<NE_QTY>", str(ne) + os.linesep) template = template.replace("<SW_QTY>", str(sw) + os.linesep) else: template = "No Collection" else: template = "No Collection" elif conf == "ALLOCATION": allocation = self.get_direct("sNotificationEODAllocation", params, False) if allocation is None: template = "No Allocation" else: if isinstance(allocation, list): if len(allocation) > 0: CONST_NAME = template template_list = [] for each_allocation in allocation: brand = each_allocation["Entity_Name"] item = each_allocation["Category_Name"] quantity = each_allocation["Total"] temp = CONST_NAME temp = temp.replace("<BRAND>", brand) temp = temp.replace("<ITEM>", item) temp = temp.replace("<QTY>", str(quantity)) template_list.append(temp + os.linesep) list_to_str = ''.join(map(str, template_list)) template = list_to_str else: template = "No Allocation" else: template = "No Allocation" else: recycle = self.get_direct("sNotificationEODRecycled", params, False) if recycle is None: template = "No Recycle" else: if isinstance(recycle, list): if len(recycle) > 0: template_list = [] CONST_NAME = template for each_recycler in recycle: brand = each_recycler["Entity_Name"] item = each_recycler["Category_Name"] quantity = each_recycler["Total"] temp = CONST_NAME temp = temp.replace("<RECYCLER>", brand) temp = temp.replace("<ITEM>", item) temp = temp.replace("<QTY>", str(quantity)) template_list.append(temp + os.linesep) list_to_str = ''.join(map(str, template_list)) template = list_to_str else: template = "No Recycle" else: template = "No Recycle" return template