use spejstore-labelmaker v2 api

pull/2/head
radex 2024-01-31 00:27:48 +01:00
parent cba1e2fd86
commit c0d805781b
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
2 changed files with 10 additions and 13 deletions

View File

@ -39,13 +39,6 @@ class LabelViewSet(viewsets.ModelViewSet):
queryset = Label.objects.all()
serializer_class = LabelSerializer
@action(
detail=True,
methods=["post"],
)
def print(self, request, pk):
return api_print(request.query_params.get("quantity", 1), self.get_object())
class ItemViewSet(viewsets.ModelViewSet):
"""

View File

@ -25,8 +25,15 @@ STATES = (
)
def api_print(id):
resp = requests.post("{}/api/1/print/{}".format(settings.LABEL_API, id))
def api_print(item):
resp = requests.post(
"{}/api/2/print".format(settings.LABEL_API),
params={
"id": item.short_id,
"name": item.name,
"owner": item.owner,
}
)
resp.raise_for_status()
@ -124,7 +131,7 @@ class Item(models.Model, TreeModelMixin):
return next((c for c in self.categories.all() if c.icon_id), None)
def print(self):
api_print(self.short_id())
api_print(self)
class Meta:
ordering = ("path",)
@ -158,6 +165,3 @@ class Label(models.Model):
def __str__(self):
return "{}".format(self.id)
def print(self):
api_print(self.id)