diff --git a/src/budy/controllers/api/order.py b/src/budy/controllers/api/order.py index d28a71b5..6c54d113 100644 --- a/src/budy/controllers/api/order.py +++ b/src/budy/controllers/api/order.py @@ -342,6 +342,16 @@ def set_voucher(self, key): order = order.reload(map = True) return order + @appier.route("/api/orders//meta", "PUT", json = True) + @appier.ensure(token = "user") + def set_meta(self, key): + name = self.field("name", mandatory = True, not_empty = True) + value = self.field("value", mandatory = True) + order = budy.Order.get(key = key, rules = False) + order.set_meta_s(name, value) + order = order.reload(map = True) + return order + @appier.route("/api/orders//wait_payment", "PUT", json = True) @appier.ensure(token = "user") def wait_payment(self, key): diff --git a/src/budy/models/order.py b/src/budy/models/order.py index f869c754..cd57ae15 100644 --- a/src/budy/models/order.py +++ b/src/budy/models/order.py @@ -345,6 +345,10 @@ def refresh_vouchers_s(self): self.empty_vouchers_s() for voucher in vouchers: self.add_voucher_s(voucher) + def set_meta_s(self, name, value): + self.meta[name] = value + self.save() + def refresh_s(self, *args, **kwargs): if self.paid: return refreshed = bundle.Bundle.refresh_s(self, *args, **kwargs)