From c1cada3de7e13d343840aa0ba1ffbe897db383dd Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Wed, 13 Dec 2017 21:21:13 +0100 Subject: [PATCH] item: Fix label printing --- spejstore/settings.py | 2 +- static/css/custom.css | 10 ++++++++++ storage/apiviews.py | 7 +++++++ storage/templates/item.html | 8 ++++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/spejstore/settings.py b/spejstore/settings.py index afbc249..2e5eebd 100644 --- a/spejstore/settings.py +++ b/spejstore/settings.py @@ -189,4 +189,4 @@ REST_FRAMEWORK = { ] } -LABEL_API = 'http://label.waw.hackerspace.pl:5678' +LABEL_API = 'http://label.waw.hackerspace.pl:4567' diff --git a/static/css/custom.css b/static/css/custom.css index 7b23a1a..d8f7f12 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -20,3 +20,13 @@ padding-left: 0.5rem; font-weight: bold; } + +.label-item { + background: #f5f5f5; + border-radius: 3px; + display: inline-block; +} + +.label-item code { + margin: 0em 1em; +} diff --git a/storage/apiviews.py b/storage/apiviews.py index 4331d24..a043542 100644 --- a/storage/apiviews.py +++ b/storage/apiviews.py @@ -1,6 +1,7 @@ from rest_framework import viewsets, generics, filters from rest_framework.response import Response from rest_framework.decorators import detail_route +from rest_framework.permissions import AllowAny from storage.models import Item, Label from storage.serializers import ItemSerializer, LabelSerializer @@ -29,6 +30,12 @@ class LabelViewSet(viewsets.ModelViewSet): queryset = Label.objects serializer_class = LabelSerializer + @detail_route(methods=['post'], permission_classes=[AllowAny]) + def print(self, request, pk): + obj = self.get_object() + obj.print() + return obj + class ItemViewSet(viewsets.ModelViewSet): """ diff --git a/storage/templates/item.html b/storage/templates/item.html index e8fa57d..8c0c988 100644 --- a/storage/templates/item.html +++ b/storage/templates/item.html @@ -84,8 +84,12 @@

Labels

{% for label in labels %} -
- + + {% csrf_token %} +
+ + {{ label.id }} +
{% endfor %} {% endif %}