Esempio n. 1
0
    def Post(self, car_id, expense_id = None):
        if expense_id:
            _expense = ndb.Key(Car, int(car_id), Expense, int(expense_id)).get()
        else:
            _expense = Expense(
                parent = self.rootKey(car_id),
            )
        _expense.type = self.request.get('type')
        _expense.amount = float(self.request.get('amount'))
        _expense.date = datetime.strptime(self.request.get('date'), "%Y-%m-%d")
        _expense.address = self.request.get('address')

        _lng = self.request.get('lng')
        _lat = self.request.get('lat')

        if _lng and _lat:
            _expense.location = ndb.GeoPt(_lat, _lng)

        self.response.write(_expense.put())
        if not self.request.get('ajax'):
            self.redirect('/car')