changed the prefix of stock uuid qr codes
This commit is contained in:
parent
171b6b83f4
commit
f6a878460d
@ -316,7 +316,7 @@ class Stock(models.Model):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_qr_code(self):
|
def get_qr_code(self):
|
||||||
qr_data = '[stock]'+str(self.id)
|
qr_data = '[stck_uuid]'+str(self.id)
|
||||||
return qr_data
|
return qr_data
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError, ObjectDoesNotExist
|
|||||||
from django.urls import reverse as url_reverse
|
from django.urls import reverse as url_reverse
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .models import Storage, Component
|
from .models import Storage, Component, Stock
|
||||||
|
|
||||||
class QrCode:
|
class QrCode:
|
||||||
prefix = ''
|
prefix = ''
|
||||||
@ -19,6 +19,7 @@ class QrCodeValidator:
|
|||||||
qr_patterns = {
|
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),
|
'comp_uuid': QrCode('comp_uuid', 'parts-components-detail', Component),
|
||||||
|
'stck_uuid': QrCode('stck_uuid', 'parts-stock-detail', Stock),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -32,16 +33,13 @@ class QrCodeValidator:
|
|||||||
|
|
||||||
qr_type = matches.group('prefix')
|
qr_type = matches.group('prefix')
|
||||||
qr_uuid = matches.group('uuid')
|
qr_uuid = matches.group('uuid')
|
||||||
url_name = self.qr_patterns[qr_type].detail_view
|
|
||||||
|
|
||||||
model = None
|
|
||||||
try:
|
try:
|
||||||
|
url_name = self.qr_patterns[qr_type].detail_view
|
||||||
model = self.qr_patterns[qr_type].model
|
model = self.qr_patterns[qr_type].model
|
||||||
except:
|
except KeyError as ex:
|
||||||
model = None
|
raise ValidationError('QR Pattern not registered') from ex
|
||||||
if model is None:
|
return (model, qr_uuid, url_name)
|
||||||
raise ValidationError('QR Pattern not registered')
|
|
||||||
return (model,qr_uuid, url_name)
|
|
||||||
|
|
||||||
def get_redirect_url(self, data):
|
def get_redirect_url(self, data):
|
||||||
model, uuid, url_name = self._get_model_from_qr(data)
|
model, uuid, url_name = self._get_model_from_qr(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user