def toggleCardLockStatus(self, cardId, consumerId): millis = SSUtil.getMillis() cacheService = CacheService() statusFlag = 0 try: consumer = Consumer.objects.get(id=consumerId) consumerCard = ConsumerCard.objects.get(id=cardId) if SSUtil.isIdinList(consumer.blockedCards, cardId): consumer.blockedCards = SSUtil.removeIdFromList( consumer.blockedCards, cardId) statusFlag = 1 consumerCard.status = 1 else: consumer.blockedCards = SSUtil.addIdToList( consumer.blockedCards, cardId) statusFlag = 0 consumerCard.status = 0 consumer.updated = millis consumerCard.updated = millis consumer.save() cacheService.setConsumer(consumer.id) consumerCard.save() cacheService.setCard(consumerCard.id) return statusFlag except: raise Exception(SSException.PROCESSING_FAILED)
def manageTags(self, txnId, selected, newOne): millis = SSUtil.getMillis() txn = ConsumerTxn.objects.get(id=txnId) if not selected is None: txnTags = TxnTag.objects.all().filter(consumerTxn_id=txnId) for txnTag in txnTags: if not SSUtil.isIdinList(selected, txnTag.consumerTag_id): self.removeTag(txnId, txnTag.consumerTag_id) else: selected = SSUtil.removeIdFromList(selected, txnTag.consumerTag_id) # Now check what remains, and tag to them if not selected is None and selected != '': lst = selected.split(",") for tagId in lst: txnTag = TxnTag() txnTag.cardId = txn.cardId txnTag.consumerTag_id = tagId txnTag.consumerTxn_id = txnId txnTag.created = millis txnTag.updated = millis txnTag.save() else: #Remove all txnTags = TxnTag.objects.filter(consumerTxn_id=txnId) for txnTag in txnTags: self.removeTag(txnId, txnTag.consumerTag_id) #Create new one if sent if not newOne is None and newOne != '': consumerTag = self.addTag(txnId, newOne)
def unlockTxTypeStatus(self, cardId, txType): millis = SSUtil.getMillis() statusFlag = 1 cacheService = CacheService() try: consumerCard = ConsumerCard.objects.get(id=cardId) if SSUtil.isIdinList(consumerCard.blockedTxTypes,txType): consumerCard.blockedTxTypes = SSUtil.removeIdFromList(consumerCard.blockedTxTypes,txType) statusFlag = 1 consumerCard.updated = millis consumerCard.save() cacheService.setCard(cardId) return statusFlag except: raise Exception(SSException.PROCESSING_FAILED)
def unlockMerchantStatus(self, merchantId, consumerId): millis = SSUtil.getMillis() statusFlag = 1 cacheService = CacheService() try: consumer = Consumer.objects.get(id=consumerId) if SSUtil.isIdinList(consumer.blockedMerchants, merchantId): consumer.blockedMerchants = SSUtil.removeIdFromList( consumer.blockedMerchants, merchantId) statusFlag = 1 consumer.updated = millis consumer.save() cacheService.setConsumer(consumer.id) merchServ = MerchantService() merchServ.toggleStatus(merchantId, consumerId, statusFlag) return statusFlag except: raise Exception(SSException.PROCESSING_FAILED)