use spejstore-labelmaker v2 api
This commit is contained in:
parent
cba1e2fd86
commit
c0d805781b
|
@ -39,13 +39,6 @@ class LabelViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Label.objects.all()
|
queryset = Label.objects.all()
|
||||||
serializer_class = LabelSerializer
|
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):
|
class ItemViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -25,8 +25,15 @@ STATES = (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def api_print(id):
|
def api_print(item):
|
||||||
resp = requests.post("{}/api/1/print/{}".format(settings.LABEL_API, id))
|
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()
|
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)
|
return next((c for c in self.categories.all() if c.icon_id), None)
|
||||||
|
|
||||||
def print(self):
|
def print(self):
|
||||||
api_print(self.short_id())
|
api_print(self)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ("path",)
|
ordering = ("path",)
|
||||||
|
@ -158,6 +165,3 @@ class Label(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{}".format(self.id)
|
return "{}".format(self.id)
|
||||||
|
|
||||||
def print(self):
|
|
||||||
api_print(self.id)
|
|
||||||
|
|
Loading…
Reference in New Issue