forked from wiktor/spejstore-new
item: Fix label printing
This commit is contained in:
parent
0fa55f7bd1
commit
c1cada3de7
|
@ -189,4 +189,4 @@ REST_FRAMEWORK = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
LABEL_API = 'http://label.waw.hackerspace.pl:5678'
|
LABEL_API = 'http://label.waw.hackerspace.pl:4567'
|
||||||
|
|
|
@ -20,3 +20,13 @@
|
||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.label-item {
|
||||||
|
background: #f5f5f5;
|
||||||
|
border-radius: 3px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-item code {
|
||||||
|
margin: 0em 1em;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from rest_framework import viewsets, generics, filters
|
from rest_framework import viewsets, generics, filters
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.decorators import detail_route
|
from rest_framework.decorators import detail_route
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
|
|
||||||
from storage.models import Item, Label
|
from storage.models import Item, Label
|
||||||
from storage.serializers import ItemSerializer, LabelSerializer
|
from storage.serializers import ItemSerializer, LabelSerializer
|
||||||
|
@ -29,6 +30,12 @@ class LabelViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Label.objects
|
queryset = Label.objects
|
||||||
serializer_class = LabelSerializer
|
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):
|
class ItemViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -84,8 +84,12 @@
|
||||||
<h3>Labels</h3>
|
<h3>Labels</h3>
|
||||||
<iframe name="printframe" style="display: none"></iframe>
|
<iframe name="printframe" style="display: none"></iframe>
|
||||||
{% for label in labels %}
|
{% 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?')">
|
<form action="/api/1/labels/{{ label.id }}/print/" method="POST" target="printframe" onsubmit="return confirm('Want to print this label?')">
|
||||||
<button class="btn btn-xs btn-default" title="Print">{{label.id}}</button>
|
{% 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>
|
</form>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue