Progress with component handling

This commit is contained in:
2021-11-09 18:44:28 +01:00
parent ed733b8bb7
commit 7eb2652433
9 changed files with 101 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError, ObjectDoesNotExist
from django.urls import reverse as url_reverse
import re
from .models import Storage
from .models import Storage, Component
class QrCode:
prefix = ''
@@ -17,7 +17,8 @@ class QrCode:
class QrCodeValidator:
qr_patterns = {
'stor_uuid': QrCode('stor_uuid', 'parts-stocks-detail', Storage)
'stor_uuid': QrCode('stor_uuid', 'parts-stocks-detail', Storage),
'comp_uuid': QrCode('comp_uuid', 'parts-components-detail', Component),
}
def __init__(self):

View File

@@ -10,4 +10,5 @@ urlpatterns = [
path('changepw/', parts_views.ChangePasswordView.as_view(), name='change-pw'),
path('stocks/<slug:uuid>/', parts_views.StockViewDetail.as_view(), name='parts-stocks-detail'),
path('components/<slug:uuid>/', parts_views.ComponentDetailView.as_view(), name='parts-components-detail'),
path('packages/<slug:uuid>/', parts_views.PackageDetailView.as_view(), name='parts-packages-detail'),
]

View File

@@ -392,7 +392,20 @@ class ComponentDetailView(LoginRequiredMixin, BaseTemplateMixin, DetailView):
context = super().get_context_data(**kwargs)
context['component'] = self.object
return context
class PackageDetailView(LoginRequiredMixin, BaseTemplateMixin, DetailView):
template_name = 'parts/packages-detail.html'
model = Package
pk_url_kwarg = 'uuid'
base_title = ''
navbar_selected = 'Components'
def get_context_data(self, **kwargs):
self.base_title = 'Package / '+self.object.name
context = super().get_context_data(**kwargs)
context['package'] = self.object
return context