summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-12-13 21:21:13 +0100
committerPiotr Dobrowolski <admin@tastycode.pl>2017-12-13 21:21:13 +0100
commitc1cada3de7e13d343840aa0ba1ffbe897db383dd (patch)
tree26ed17c86d49881c78917c360493f1b397851f71
parent0fa55f7bd162eed021b49f1438f952b8ef63cdae (diff)
downloadspejstore-c1cada3de7e13d343840aa0ba1ffbe897db383dd.tar.gz
spejstore-c1cada3de7e13d343840aa0ba1ffbe897db383dd.tar.bz2
spejstore-c1cada3de7e13d343840aa0ba1ffbe897db383dd.zip
item: Fix label printing
-rw-r--r--spejstore/settings.py2
-rw-r--r--static/css/custom.css10
-rw-r--r--storage/apiviews.py7
-rw-r--r--storage/templates/item.html8
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 @@
<h3>Labels</h3>
<iframe name="printframe" style="display: none"></iframe>
{% for label in labels %}
- <form action="http://label.waw.hackerspace.pl:4567/api/1/print/{{ label.id }}" method="POST" target="printframe" onsubmit="return confirm('Want to print this label?')">
- <button class="btn btn-xs btn-default" title="Print">{{label.id}}</button>
+ <form action="/api/1/labels/{{ label.id }}/print/" method="POST" target="printframe" onsubmit="return confirm('Want to print this label?')">
+ {% csrf_token %}
+ <div class="label-item">
+ <button class="btn btn-default btn-sm"><i class="glyphicon glyphicon-print"></i></button>
+ <code>{{ label.id }}</code>
+ </div>
</form>
{% endfor %}
{% endif %}