def delete(self): customer_id = self.request.matchdict.get('customer_id') customer = Customer.load(customer_id) self.forbid_if(not customer or customer.campaign.company.enterprise_id != self.enterprise_id) customer.mod_dt = util.now() customer.delete_dt = util.now() Status.add(customer, customer, StatusEvent.find(self.enterprise_id, 'Customer', 'DELETED'), 'Customer Deleted') return 'True'
def delete(self): product_id = self.request.matchdict.get('product_id') product = Product.load(product_id) self.forbid_if(not product or str(product.company.enterprise_id) != str(self.enterprise_id)) product.mod_dt = util.now() product.delete_dt = util.now() Status.add(None, product, StatusEvent.find(self.enterprise_id, 'Product', 'DELETED'), 'Product Deleted') product.invalidate_caches() return 'True'
def test_save_status(self): ent = Enterprise.find_by_name('Healthy U Store') evt = StatusEvent.find(ent.enterprise_id, 'PurchaseOrder', 'TESTEVENT_PO') purchase_order_id = self._create_new() R = self.post(str('/crm/purchase/save_status/%s' % purchase_order_id), {'event_id' : evt.event_id, 'note' : 'Note Note'}) assert R.status_int == 200 self._delete_new(purchase_order_id)
def find_event(enterprise_id, obj, short_name): return StatusEvent.find(enterprise_id, type(obj).__name__, short_name)