def writeAll(self, user): ''' Get all teh ledger Items ''' lquery = Ledger.gql("WHERE user = :1", user) if lquery.count()>500: self.trace() ledgerItems = lquery.fetch(500); self.response.headers['Content-Type'] = 'application/json' jsonData = { "success" : True, "data" : ledgerItems } self.response.out.write(json.encode(jsonData))
def delete(self, id): user = users.get_current_user() if user: jsonOut = { "success":True, "message":"Deleted "+id } ledgerItemQuery = Ledger.gql("WHERE user = :1 AND __key__ = :2", user, db.Key.from_path('Ledger',int(id))) ledgerItem = ledgerItemQuery.fetch(1) if ledgerItem and len(ledgerItem)>0: ledgerItem[0].delete() self.response.out.write(json.encode(jsonOut)) else: jsonOut['success'] = False jsonOut['message'] = "Unable to find the ledger item to delete" self.response.out.write(json.encode(jsonOut)) else: self.redirect(users.create_login_url(self.request.uri))